/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0F1117;
    --surface: #1A1D27;
    --surface-hover: #242833;
    --border: #2E3340;
    --primary: #D4A843;
    --primary-hover: #c49a35;
    --text: #F0F0F0;
    --text-secondary: #8B8FA3;
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --sidebar-width: 220px;
    --sidebar-collapsed: 60px;
    --topbar-height: 56px;
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #000; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled) { opacity: 0.85; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover:not(:disabled) { opacity: 0.85; }
.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--text-secondary); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; padding: 4px 8px; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }

/* === Login Screen === */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    margin: 16px;
}
.login-logo {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 28px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}
.form-group input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* === App Shell === */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.2s, transform 0.2s;
}
.sidebar-logo {
    padding: 16px 20px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}
.nav-item.active {
    color: var(--primary);
    background: rgba(212, 168, 67, 0.08);
    border-right: 3px solid var(--primary);
}
.nav-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    transition: margin-left 0.2s;
}

/* === Top Bar === */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 50;
}
.page-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-name {
    color: var(--text-secondary);
    font-size: 13px;
}

/* === Page Container === */
.page-container {
    padding: 24px;
    max-width: 1400px;
}

/* === Cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-card-value {
    font-size: 28px;
    font-weight: 700;
}
.stat-card-value.gold { color: var(--primary); }

/* === Section === */
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.section-title {
    font-size: 15px;
    font-weight: 600;
}
.section-body { padding: 0; }
.section-body.padded { padding: 20px; }

/* === Tables === */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
}
th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    position: relative;
}
th:hover { color: var(--text); }
th .sort-arrow { margin-left: 4px; font-size: 10px; }
th .sort-arrow.active { color: var(--primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }
td a { color: var(--primary); }
td a:hover { text-decoration: underline; }

/* === Tabs === */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Status Badges === */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-reviewed { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-resolved { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-dismissed { background: rgba(139, 143, 163, 0.15); color: var(--text-secondary); }
.badge-active { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-suspended { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-banned { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* === Actions Dropdown === */
.actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
    position: relative;
}
.dropdown-wrapper { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 150px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item.danger { color: var(--danger); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    margin: 16px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-body p { margin-bottom: 12px; color: var(--text-secondary); font-size: 14px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: toast-in 0.2s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--info); color: #fff; }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* === Search / Lookup === */
.lookup-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 500px;
}
.lookup-bar input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}
.lookup-bar input:focus { outline: none; border-color: var(--primary); }
.lookup-bar input::placeholder { color: var(--text-secondary); opacity: 0.6; }

/* === User Detail Panel === */
.user-detail {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
}
.user-info-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    overflow: hidden;
}
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.user-email { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; word-break: break-all; }
.user-meta { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.user-meta strong { color: var(--text); font-weight: 500; }
.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.user-right-panel { min-width: 0; }

/* === Loading / Empty === */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.error-state {
    text-align: center;
    padding: 40px;
    color: var(--danger);
    font-size: 14px;
}

/* === Placeholder pages === */
.placeholder-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}
.placeholder-page .icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-page h2 { font-size: 20px; margin-bottom: 8px; }
.placeholder-page p { color: var(--text-secondary); }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    .page-container { padding: 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .user-detail { grid-template-columns: 1fr; }
    .table-wrapper { font-size: 12px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; }
    .actions-cell { flex-wrap: wrap; }
}
