/* Admin Panel Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --admin-bg: #f0f2f5;
    --admin-sidebar: #1a1a2e;
    --admin-sidebar-hover: #16213e;
    --admin-primary: #4A90D9;
    --admin-primary-dark: #3A7BC8;
    --admin-card: #ffffff;
    --admin-text: #333333;
    --admin-text-light: #666666;
    --admin-border: #e0e0e0;
    --admin-danger: #e74c3c;
    --admin-success: #27ae60;
    --admin-warning: #f39c12;
    --admin-radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    min-height: 100vh;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.login-box {
    background: var(--admin-card);
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.login-box p {
    color: var(--admin-text-light);
    margin-bottom: 24px;
    font-size: 14px;
}

.login-box input {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: var(--admin-primary);
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--admin-primary);
    color: white;
    border: none;
    border-radius: var(--admin-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: var(--admin-primary-dark);
}

.error-msg {
    color: var(--admin-danger);
    margin-top: 12px;
    font-size: 13px;
    min-height: 20px;
}

/* Admin Panel Layout */
.admin-panel {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--admin-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 20px;
}

.admin-user {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.nav-list {
    list-style: none;
    flex: 1;
    padding-top: 8px;
}

.nav-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}

.nav-item:hover {
    background: var(--admin-sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--admin-sidebar-hover);
    color: white;
    border-left: 3px solid var(--admin-primary);
}

.nav-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    border-radius: var(--admin-radius);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
    min-height: 100vh;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section h1 {
    font-size: 24px;
    margin-bottom: 20px;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--admin-card);
    padding: 20px;
    border-radius: var(--admin-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--admin-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--admin-text-light);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Panel */
.panel {
    background: var(--admin-card);
    border-radius: var(--admin-radius);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

.panel h3 {
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--admin-text);
}

/* Two Columns */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--admin-border);
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--admin-text-light);
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: #f0f4ff;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mini-table th,
.mini-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--admin-border);
}

.mini-table th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--admin-text-light);
}

/* Search */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h1 {
    margin-bottom: 0;
}

.search-bar {
    display: flex;
    gap: 8px;
}

.search-bar input {
    padding: 8px 14px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    font-size: 13px;
    width: 250px;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--admin-primary);
}

.search-bar button {
    padding: 8px 16px;
    background: var(--admin-primary);
    color: white;
    border: none;
    border-radius: var(--admin-radius);
    cursor: pointer;
    font-size: 13px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-yes { background: #d4edda; color: #155724; }
.badge-no { background: #f8f9fa; color: #999; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-pro { background: #fff3cd; color: #856404; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 13px;
}

.pagination button.active {
    background: var(--admin-primary);
    color: white;
    border-color: var(--admin-primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* User Detail */
.back-btn {
    background: none;
    border: none;
    color: var(--admin-primary);
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 16px;
    padding: 4px 0;
}

.back-btn:hover {
    text-decoration: underline;
}

.user-detail-header {
    margin-bottom: 20px;
}

.user-detail-header h2 {
    font-size: 22px;
}

.user-detail-header p {
    color: var(--admin-text-light);
    font-size: 13px;
}

.user-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Action Buttons */
.action-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    border: none;
    border-radius: var(--admin-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: white;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 0.85;
}

.action-btn.pro { background: var(--admin-warning); }
.action-btn.credits { background: var(--admin-success); }
.action-btn.xp { background: var(--admin-primary); }
.action-btn.ban { background: var(--admin-danger); }
.action-btn.password { background: #6c757d; }

/* Log table wrap */
.log-table-wrap {
    max-height: 500px;
    overflow-y: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--admin-border);
}

.modal-header h3 {
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--admin-text-light);
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--admin-text-light);
}

.modal-body input,
.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--admin-border);
    border-radius: var(--admin-radius);
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
}

.modal-body input:focus {
    border-color: var(--admin-primary);
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--admin-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-footer button {
    padding: 8px 20px;
    border-radius: var(--admin-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border: none;
}

.btn-cancel {
    background: #f0f0f0;
    color: var(--admin-text);
}

.btn-confirm {
    background: var(--admin-primary);
    color: white;
}

.btn-danger {
    background: var(--admin-danger);
    color: white;
}

/* Detail info rows */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--admin-text-light);
}

.info-value {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h2,
    .admin-user,
    .nav-item span:not(.nav-icon),
    .sidebar-footer {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 14px;
    }

    .main-content {
        margin-left: 60px;
    }

    .two-columns {
        grid-template-columns: 1fr;
    }

    .user-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== BAR CHARTS (admin stats) ==================== */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 60px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.bar-label {
    color: var(--admin-text, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bar-track {
    background: #f3f4f6;
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--admin-primary, #3b82f6), #60a5fa);
    transition: width 0.4s ease-out;
}
.bar-value {
    text-align: right;
    font-weight: 600;
    color: var(--admin-text-muted, #6b7280);
}

/* Notifications form */
#notifForm label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--admin-text, #1f2937);
    margin: 10px 0 4px;
}
#notifForm input[type="text"],
#notifForm input[type="datetime-local"],
#notifForm select,
#notifForm textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: inherit;
}
#notifForm textarea { resize: vertical; min-height: 80px; }
#notifForm .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
#notifForm .form-row > div { display: flex; flex-direction: column; }

/* Chip input (multi-user picker) */
.chip-input {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    min-height: 40px;
    align-items: center;
    background: white;
}
.chip-input input {
    border: none !important;
    outline: none;
    flex: 1;
    min-width: 180px;
    padding: 4px 6px !important;
    font-size: 13px;
}
.chip-list { display: contents; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
}
.chip-x {
    background: transparent;
    border: none;
    color: #1e40af;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 0 0 4px;
    font-weight: 700;
}
.chip-x:hover { color: #ef4444; }

.suggestion-list {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
}
.suggestion-list:empty { display: none; }
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
}
.suggestion-item:hover { background: #f3f4f6; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-role { font-size: 16px; }
.suggestion-name { flex: 1; }
.suggestion-email { color: #6b7280; font-size: 12px; }
.suggestion-empty {
    padding: 10px 12px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

/* Markdown editor (admin notif form) */
.md-editor {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    background: white;
}
.md-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
}
.md-toolbar button {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--admin-text, #1f2937);
    line-height: 1.4;
    min-width: 32px;
}
.md-toolbar button:hover { background: #f3f4f6; border-color: #d1d5db; }
.md-spacer { flex: 1; }
.md-edit-wrap textarea#notifBody {
    border: none !important;
    border-radius: 0 !important;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}
.md-preview {
    padding: 12px;
    min-height: 120px;
    font-size: 14px;
    line-height: 1.5;
    background: white;
    color: var(--admin-text, #1f2937);
}
.md-preview strong { font-weight: 700; }
.md-preview em { font-style: italic; }
.md-preview a { color: #3b82f6; text-decoration: underline; }
.md-preview ul { padding-left: 20px; margin: 8px 0; }
.md-preview blockquote {
    border-left: 3px solid #d1d5db;
    padding-left: 10px;
    color: #6b7280;
    margin: 8px 0;
}
.md-counter {
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
    padding: 4px 8px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

/* Nav badge (Support open count) */
.nav-badge {
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
}
.nav-item { display: flex; align-items: center; gap: 8px; }

/* Support filter buttons */
.support-filter-btn {
    background: #f3f4f6 !important;
    color: var(--admin-text, #1f2937) !important;
    border: 1px solid #e5e7eb !important;
    padding: 6px 12px !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.support-filter-btn.active {
    background: var(--admin-primary, #3b82f6) !important;
    color: white !important;
    border-color: var(--admin-primary, #3b82f6) !important;
}

/* Clickable table rows (admin lists) */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #f9fafb; }
