:root {
    --bg-dark: #121826;
    --bg-panel: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Be Vietnam Pro', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.admin-layout {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    height: 100dvh;
    padding: 1rem;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.badge {
    background-color: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 20px 0;
    flex-grow: 1;
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.1);
    border-right: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: 70px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.header-search input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 6px;
    width: 300px;
}

.content-wrapper {
    padding: 30px;
    overflow-y: auto;
    flex-grow: 1;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

/* Data Tables */
.data-table-container {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table-container::-webkit-scrollbar {
    height: 8px;
}

.data-table-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.data-table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.data-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table th {
    background-color: rgba(0,0,0,0.25);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background: rgba(255,255,255,0.05);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ======================================== */
/* Users & Permissions Tab - Mockup Match   */
/* ======================================== */
#tab-users, #tab-settings {
    color: #1e293b;
}

.users-theme-wrapper, .settings-theme-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.users-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.users-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.users-page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0;
}

.users-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8e4dc;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 9999px;
    min-width: 28px;
}

.users-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #d1cdc5;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.users-info-btn:hover {
    color: #475569;
    border-color: #94a3b8;
    background: rgba(0,0,0,0.03);
}

.users-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 18px 0 20px 0;
    flex-wrap: wrap;
}

.filter-search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.filter-search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.95rem;
    pointer-events: none;
}

.filter-search-box input {
    width: 100%;
    padding: 10px 18px 10px 44px;
    background: #ece7de;
    border: 1px solid #dfdad0;
    border-radius: 9999px;
    color: #1e293b;
    font-size: 0.92rem;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-search-box input::placeholder {
    color: #94a3b8;
}

.filter-search-box input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.filter-role-select select {
    padding: 9px 20px;
    background: #ffffff;
    border: 1px solid #dfdad0;
    border-radius: 9999px;
    color: #334155;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-role-select select:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Users Card List Container */
.users-card-list {
    background: #ffffff;
    border: 1px solid #e7e3d8;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.users-loading {
    padding: 40px;
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
}

.user-card {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    gap: 16px;
    border-bottom: 1px solid #f0ece3;
    transition: background-color 0.15s;
}

.user-card:last-child {
    border-bottom: none;
}

.user-card:hover {
    background-color: #faf9f6;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e2e8f0;
}

.user-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    text-transform: uppercase;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info-name {
    font-weight: 700;
    font-size: 0.96rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    background: #f3e8ff;
    color: #7c3aed;
    border: 1px solid #ddd6fe;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.user-info-email {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 3px;
    word-break: break-all;
}

.user-info-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.user-info-meta .meta-dot {
    color: #cbd5e1;
    font-weight: bold;
}

.google-badge {
    display: inline-flex;
    align-items: center;
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.user-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    font-family: inherit;
}

.user-action-btn:hover {
    opacity: 0.8;
}

.user-action-btn:active {
    transform: scale(0.97);
}

.user-action-btn.edit-user {
    color: #2563eb;
}

.user-action-btn.grant-admin {
    color: #7c3aed;
}

.user-action-btn.revoke-admin {
    color: #b45309;
}

.user-action-btn.lock-user {
    color: #dc2626;
}

.user-action-btn.unlock-user {
    color: #d97706;
}

/* ======================================== */
/* Settings Tab - Mockup Match (Hình 2 & 3) */
/* ======================================== */
.settings-checks-container {
    background: #ffffff;
    border: 1px solid #e7e3d8;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.settings-loading {
    padding: 30px;
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
}

.settings-check-item {
    display: flex;
    align-items: flex-start;
    padding: 18px 24px;
    gap: 14px;
    border-bottom: 1px solid #f0ece3;
}

.settings-check-item:last-child {
    border-bottom: none;
}

.settings-check-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.72rem;
    margin-top: 3px;
}

.settings-check-icon.pass {
    background: #f0fdf4;
    color: #16a34a;
    border: 1.5px solid #16a34a;
}

.settings-check-icon.warn {
    background: #fffbeb;
    color: #d97706;
    border: 1.5px solid #d97706;
}

.settings-check-icon.fail {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #dc2626;
}

.settings-check-icon.unknown {
    background: #f8fafc;
    color: #94a3b8;
    border: 1.5px solid #cbd5e1;
}

.settings-check-content {
    flex: 1;
    min-width: 0;
}

.settings-check-label {
    font-weight: 700;
    font-size: 0.96rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-check-desc {
    font-size: 0.86rem;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.5;
}

.settings-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.settings-status-badge.status-pass {
    background: #dcfce7;
    color: #15803d;
}

.settings-status-badge.status-warn {
    background: #fef3c7;
    color: #92400e;
}

.settings-status-badge.status-fail {
    background: #fee2e2;
    color: #991b1b;
}

.settings-status-badge.status-unknown {
    background: #f1f5f9;
    color: #64748b;
}

.settings-section {
    background: #ffffff;
    border: 1px solid #e7e3d8;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.settings-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #f0ece3;
}

.settings-guide-content {
    padding: 24px;
}

.settings-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-steps li {
    color: #1e293b;
    font-size: 0.92rem;
    line-height: 1.55;
}

.settings-steps li p {
    color: #475569;
    font-size: 0.88rem;
    margin-top: 4px;
    line-height: 1.5;
}

.settings-steps .step-num {
    color: #6366f1;
    font-weight: 700;
    margin-right: 4px;
}

.settings-steps strong {
    font-weight: 700;
    color: #1e293b;
}

.settings-steps code {
    background: #f4efe6;
    color: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Courier New', monospace;
}

.settings-code-block {
    display: inline-block;
    background: #f4efe6;
    border: 1px solid #dfd8cb;
    padding: 6px 14px;
    border-radius: 6px;
    color: #1e293b;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.86rem;
    word-break: break-all;
}

.settings-url-chip {
    display: inline-block;
    background: #f4efe6;
    border: 1px solid #dfd8cb;
    padding: 5px 12px;
    border-radius: 6px;
    color: #1e293b;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.84rem;
}

/* ==========================================================================
   MOBILE & RESPONSIVE ADMIN DASHBOARD
   ========================================================================== */
.admin-mobile-toggle-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 1.1rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.admin-mobile-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
    color: #fff;
}

.admin-sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.admin-sidebar-close-btn:hover {
    color: #fff;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1099;
}
.sidebar-backdrop.active {
    display: block;
}

@media (max-width: 900px) {
    .admin-mobile-toggle-btn {
        display: inline-flex;
    }
    .admin-sidebar-close-btn {
        display: block;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 1100 !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .top-header {
        padding: 10px 14px !important;
    }
    .header-search input {
        width: 180px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .content-wrapper {
        padding: 14px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .data-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 10px;
    }

    /* Modals trên Mobile: Tràn viền an toàn, không bị vượt quá màn hình */
    #modal-edit-user > div,
    #modal-add-user > div,
    #modal-lesson > div,
    #modal-class > div,
    #modal-ai-fix-preview > div {
        width: 95vw !important;
        max-width: 600px !important;
        padding: 16px !important;
        max-height: 90vh !important;
        box-sizing: border-box !important;
    }

    #modal-ai-fix-preview div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .admin-fb-desktop-view {
        display: none !important;
    }

    .admin-fb-mobile-view {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }
}

.admin-fb-desktop-view {
    display: block;
}

.admin-fb-mobile-view {
    display: none;
}

.admin-fb-mobile-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

@media (max-width: 480px) {
    .header-search input {
        display: none !important;
    }
    .header-search svg {
        display: none !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 14px !important;
    }
    .stat-value {
        font-size: 1.5rem !important;
    }

    .page-title {
        font-size: 1.3rem !important;
    }
}
