/* ================================================
   BIT2025 by Isaiah Admin Dashboard — Inherited Branding
   Same design DNA as bit2025.netlify.app
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* === BIT2025 by Isaiah Core Palette (inherited) === */
    --white: #ffffff;
    --black: #000000;
    --dark-gray: #2c3e50;
    --medium-gray: #7f8c8d;
    --light-gray: #ecf0f1;
    --lighter-gray: #f8f9fa;
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #2ecc71;
    --secondary-dark: #27ae60;
    --accent: #9b59b6;
    --accent-dark: #8e44ad;
    --danger: #DE3163;
    --warning: #f39c12;
    --success: var(--secondary);
    --info: var(--primary);

    /* RGB versions */
    --dark-gray-rgb: 44, 62, 80;
    --primary-rgb: 52, 152, 219;
    --secondary-rgb: 46, 204, 113;
    --accent-rgb: 155, 89, 182;
    --danger-rgb: 222, 49, 99;
    --warning-rgb: 243, 156, 18;

    /* === BIT2025 by Isaiah Design Tokens (inherited) === */
    --shadow-sm: 0 2px 6px rgba(var(--dark-gray-rgb), 0.07);
    --shadow: 0 4px 12px rgba(var(--dark-gray-rgb), 0.1);
    --shadow-lg: 0 8px 24px rgba(var(--dark-gray-rgb), 0.12);
    --border-radius-sm: 4px;
    --border-radius: 8px;
    --border-radius-lg: 16px;
    --font-primary: 'Playfair Display', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-blur: blur(12px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.6);

    /* === Admin-specific === */
    --sidebar-width: 260px;
    --sidebar-bg: var(--dark-gray);
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-active: var(--danger);
    --topbar-height: 64px;
}

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

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: var(--font-body);
    background: #f4f7f6; /* Modern off-white background */
    color: var(--dark-gray);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--danger);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #c82c59;
}

/* ===== ADMIN LAYOUT ===== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    -ms-overflow-style: none; /* IE/Edge */
    scrollbar-width: none;    /* Firefox */
}

.sidebar::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.sidebar-close:hover {
    opacity: 1;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
}

.sidebar-title {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    color: var(--white);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

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

.nav-item.active {
    background: rgba(222, 49, 99, 0.1);
    color: var(--danger);
    border-left-color: var(--danger);
    font-weight: 600;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.nav-section {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 0.5rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-footer .admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-footer .admin-name {
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
}

.sidebar-footer .logout-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    transition: color 0.2s;
}

.sidebar-footer .logout-link:hover {
    color: var(--danger);
}

/* ===== FOOTER ===== */
.admin-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: #f8f9fa; /* Lighter gray to differentiate from body */
    color: var(--dark-gray);
    padding: 0.8rem 2rem;
    text-align: center;
    z-index: 90;
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.03);
}

.admin-footer .footer-text {
    font-size: 0.85rem;
    font-weight: 500;
}

.admin-footer .fa-heart {
    color: var(--danger);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Modal Styles (same as profile) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--dark-gray-rgb), 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1010;
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out, visibility 0s 0.3s linear;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-out, visibility 0s 0s linear;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: translateY(-20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.3s ease-out;
    opacity: 0;
}

.modal.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Mobile: admin global modal (students subscription, alerts, etc.) */
@media (max-width: 768px) {
    .modal {
        align-items: flex-start;
        padding: 0.75rem;
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: min(88vh, calc(100vh - 1.5rem));
        margin: 0 auto;
        padding: 1.25rem 1rem 1.5rem;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content .close-modal {
        top: 0.5rem;
        right: 0.5rem;
    }

    #modalBody .data-table {
        display: table;
        font-size: 0.75rem;
    }

    #modalBody .data-table thead {
        display: table-header-group;
    }

    #modalBody .data-table tr {
        display: table-row;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    #modalBody .data-table td,
    #modalBody .data-table th {
        display: table-cell;
        padding: 0.45rem 0.35rem;
        border-bottom: 1px solid var(--light-gray);
    }

    #modalBody .data-table td::before {
        display: none;
    }

    #modalBody .admin-modal-scroll {
        max-height: min(42vh, 280px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #modalBody .d-flex.flex-wrap.gap-1 {
        flex-direction: column;
        align-items: stretch;
    }

    #modalBody .d-flex.flex-wrap.gap-1 .badge {
        justify-content: center;
    }
}

.close-modal {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    font-size: 1.3rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lighter-gray);
    color: var(--medium-gray);
    transition: all 0.25s ease-out;
}

.close-modal:hover {
    background: var(--light-gray);
    color: var(--dark-gray);
    transform: rotate(90deg) scale(1.1);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding-bottom: 5rem; /* Increased padding for fixed footer */
    background: #ffffff; /* Clean white for content */
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* ===== TOP BAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
}

.topbar-title {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--dark-gray);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--lighter-gray);
    color: var(--medium-gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--dark-gray);
    cursor: pointer;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    padding: 2rem;
}

/* ===== FRONTEND-LIKE FOOTER FOR LOGIN ===== */
.profile-footer {
    background: #2c3e50;
    color: #e5e7eb;
    padding: 1.2rem 1rem;
    margin-top: auto;
}
.profile-footer .footer-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: .9rem;
}
.profile-footer .footer-center { text-align: center; }
@media (max-width: 768px) {
    .profile-footer .footer-inner { flex-direction: column; gap: 1rem; }
}

/* Heart pulse animation to match frontend */
.fa-heart.pulse {
    color: #ff6b6b;
    animation: pulseHeart 1.5s infinite cubic-bezier(0.215, 0.610, 0.355, 1);
}
@keyframes pulseHeart {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}
/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: clamp(1rem, 3vw, 1.5rem);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.stat-icon.blue {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(var(--secondary-rgb), 0.1);
    color: var(--secondary);
}

.stat-icon.red {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
}

.stat-icon.orange {
    background: rgba(var(--warning-rgb), 0.1);
    color: var(--warning);
}

.stat-icon.purple {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
}

.stat-value {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 700;
    color: var(--dark-gray);
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--medium-gray);
    margin-top: 0.2rem;
}

.admin-cv-stats-hint {
    font-size: 0.9rem;
}

/* ===== GLASS CARD ===== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto; /* Handle table overflow */
    width: 100%;
}

/* Ensure tables inside glass cards don't force parent width */
.glass-card table {
    width: 100%;
}

/* On medium screens, allow horizontal scroll for tables if they don't fit */
@media (min-width: 769px) and (max-width: 1100px) {
    .glass-card table {
        min-width: 700px;
    }
}

@media (max-width: 768px) {
    .glass-card {
        padding: 1rem;
        overflow-x: hidden; /* Disable horizontal scroll when stacked */
        max-width: 100%;
        width: 100%;
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--light-gray);
}

.card-title {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-gray);
}

/* ===== TABLES ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--lighter-gray);
}

.data-table th {
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--medium-gray);
    font-weight: 600;
    border-bottom: 2px solid var(--light-gray);
}

.data-table td {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--light-gray);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.03);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(var(--secondary-rgb), 0.1);
    color: var(--secondary);
}

.badge-danger {
    background: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(var(--warning-rgb), 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.badge-purple {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.admin-rich-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 34px;
    padding: 0;
    border-radius: var(--border-radius);
    border: 1.5px solid var(--light-gray);
    background: #fff;
    color: var(--dark-gray);
    cursor: pointer;
    transition: all 0.15s ease;
}

.admin-rich-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(var(--danger-rgb), 0.06);
    transform: translateY(-1px);
}

.admin-rich-btn.active {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(var(--danger-rgb), 0.1);
}

.admin-rich-btn i {
    font-size: 0.95rem;
    line-height: 1;
}

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

.btn-primary:hover {
    background: #c82c59;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--danger-rgb), 0.3);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--danger);
    color: var(--danger);
}

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.2rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    font-family: var(--font-body);
    color: var(--dark-gray);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
}

.form-input:focus {
    outline: none;
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.1);
}

.form-select {
    appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%237f8c8d' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    position: relative;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 0.7rem 1rem 0.7rem 2.5rem;
    border: 1.5px solid var(--light-gray);
    border-radius: var(--border-radius-lg);
    font-size: 0.9rem;
    background: var(--white);
    transition: border-color 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--danger);
}

.search-bar i {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--medium-gray);
    font-size: 0.9rem;
}

/* ===== AVATAR ===== */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--white);
    background: var(--danger);
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 1.2rem;
}

/* ===== ACTIVITY FEED ===== */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--light-gray);
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.activity-text {
    font-size: 0.9rem;
    color: var(--dark-gray);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--medium-gray);
}

/* ===== WEBHOOK JSON VIEWER ===== */
.json-viewer {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre;
    max-height: 400px;
    overflow-y: auto;
}

/* ===== LOGIN PAGE ===== */
.login-body {
    background: linear-gradient(135deg, #f4f7f6 0%, #e1e5e4 100%);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.login-wrapper {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header img {
    height: 48px;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    color: var(--dark-gray);
    margin-bottom: 0.3rem;
}

.login-header p {
    color: var(--medium-gray);
    font-size: 0.9rem;
}

.login-btn {
    width: 100%;
    padding: 0.9rem;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    background: #c82c59;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--danger-rgb), 0.35);
}

/* ===== MOBILE ===== */
@media (max-width: 992px) {
    /* Closed drawer must not steal taps meant for the topbar hamburger (iOS/Safari) */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        pointer-events: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0,0,0,0.3);
        pointer-events: auto;
        z-index: 140;
    }

    .sidebar-close {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100vw;
    }

    .topbar {
        padding: 0 1rem;
        z-index: 120;
        position: sticky;
    }

    .admin-footer {
        left: 0;
    }

    .mobile-toggle {
        display: block;
        position: relative;
        z-index: 130;
        touch-action: manipulation;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .topbar-title {
        font-size: 1.1rem;
    }

    .topbar-actions.hide-mobile {
        display: none;
    }

    .page-content {
        padding: 1rem;
    }

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

    .topbar {
        padding: 0 1rem;
    }

    /* Stack tables into cards (main content only — modals use #modalBody overrides) */
    .main-content .data-table thead {
        display: none;
    }

    .main-content .data-table tr {
        display: block;
        margin-bottom: 1rem;
        background: var(--white);
        border-radius: var(--border-radius);
        padding: 1rem;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--light-gray);
    }

    .main-content .data-table td {
        display: block;
        border-bottom: 1px solid var(--lighter-gray);
        padding: 0.6rem 0;
        text-align: left;
        min-width: 0;
        word-break: break-word;
    }

    .main-content .data-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: var(--medium-gray);
        font-size: 0.7rem;
        text-transform: uppercase;
        margin-bottom: 0.2rem;
    }
}

/* ===== UTILITIES ===== */
.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--secondary);
}

.text-warning {
    color: var(--warning);
}

.text-info {
    color: var(--primary);
}

.text-muted {
    color: var(--medium-gray);
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.d-flex {
    display: flex;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.flex-wrap {
    flex-wrap: wrap;
}

/* ===== Phase A: global modal + footer (no inline styles) ===== */
.admin-foot-heart {
    color: var(--danger);
}

.admin-modal-centered {
    text-align: center;
}

.admin-modal-brand-img {
    height: 40px;
    margin-bottom: 0.6rem;
}

.admin-modal-message {
    margin: 0 0 1rem 0;
    color: var(--dark-gray);
}

.admin-modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
}

.admin-modal-actions--single {
    justify-content: center;
}

.admin-modal-actions--split {
    justify-content: center;
}

.admin-alert-icon-success {
    color: var(--secondary);
    font-size: 1.5rem;
}

/* Phase B: stack modals (access grants, etc.) — no inline positioning */
.admin-stack-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    padding: 2rem;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.5);
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
}

.admin-stack-modal.is-open {
    display: flex;
}

.admin-stack-modal__panel {
    max-width: 420px;
    width: 100%;
    margin: 3rem auto;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.admin-stack-modal__title {
    font-family: var(--font-primary);
    margin-bottom: 1.2rem;
}

.admin-stack-modal__hint {
    font-size: 0.85rem;
    color: var(--medium-gray);
    margin-bottom: 1rem;
}

/* CV purge / danger accent in topbar (replaces inline color) */
.topbar-btn.topbar-btn--danger {
    color: var(--danger);
}

/* Access revoke button */
.btn-revoke-outline {
    color: var(--danger);
    border-color: var(--danger);
}

/* Phase C: shared list/modal utilities */
.admin-empty-cell {
    padding: 2rem;
}

.admin-pagination-bar {
    padding: 1rem;
    border-top: 1px solid var(--light-gray);
}

.admin-page-ellipsis {
    padding: 0 0.3rem;
}

.btn-pagination-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.admin-modal-block-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--light-gray);
    padding-bottom: 1rem;
}

.admin-modal-block-header--tight {
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
}

.admin-modal-title-text {
    font-family: var(--font-primary);
    color: var(--dark-gray);
}

.admin-modal-icon-danger {
    color: var(--danger);
}

.admin-detail-table {
    width: 100%;
    font-size: 0.9rem;
    border-collapse: collapse;
}

.admin-detail-table td {
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
}

.admin-detail-table td:first-child {
    color: #7f8c8d;
    width: 40%;
}

.admin-detail-table tr:last-child td {
    border-bottom: none;
}

.admin-detail-code {
    font-size: 0.8rem;
}

.admin-json-pre {
    margin: 0;
    overflow: auto;
    max-height: 70vh;
}

.admin-ticket-quote {
    background: var(--lighter-gray);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.admin-ticket-reply-box {
    background: rgba(var(--primary-rgb), 0.05);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary);
}

.admin-ticket-reply-box p {
    margin-top: 0.5rem;
}

.admin-modal-scroll {
    overflow-x: auto;
}

.admin-students-section-title {
    font-size: 0.9rem;
    color: var(--medium-gray);
    margin-bottom: 0.5rem;
}

.admin-students-table-compact {
    font-size: 0.8rem;
    width: 100%;
}

/* ===== Students page desktop fit (no compressed cells) ===== */
@media (min-width: 992px) {
    .admin-students-table-wrap {
        overflow-x: hidden;
        overflow-y: visible;
    }

    .admin-students-main-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .admin-students-main-table th,
    .admin-students-main-table td {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        vertical-align: middle;
        padding: 0.62rem 0.55rem;
        font-size: 0.84rem;
    }

    .admin-students-main-table td[data-label="Student"] {
        width: 24%;
    }

    .admin-students-main-table td[data-label="Programme"] {
        width: 16%;
    }

    .admin-students-main-table td[data-label="Actions"] {
        width: 13%;
    }

    .admin-students-main-table th:nth-child(2),
    .admin-students-main-table td:nth-child(2) {
        width: 7%;
    }

    .admin-students-main-table th:nth-child(3),
    .admin-students-main-table td:nth-child(3) {
        width: 8%;
    }

    .admin-students-main-table th:nth-child(5),
    .admin-students-main-table td:nth-child(5) {
        width: 10%;
    }

    .admin-students-main-table th:nth-child(6),
    .admin-students-main-table td:nth-child(6) {
        width: 10%;
    }

    .admin-students-main-table th:nth-child(7),
    .admin-students-main-table td:nth-child(7) {
        width: 10%;
    }

    .admin-students-main-table th:nth-child(9),
    .admin-students-main-table td:nth-child(9) {
        width: 9%;
    }
}

/* ===== Students modals desktop polish ===== */
@media (min-width: 992px) {
    /* Global admin modal (subscription/details) */
    #adminModal .modal-content {
        max-width: 980px;
        width: min(96vw, 980px);
        padding: 1.5rem 1.5rem 1.25rem;
    }

    #adminModal .admin-student-subscription-modal .modal-body {
        max-height: 72vh;
        overflow-y: auto;
        padding-right: 0.25rem;
    }

    /* Student edit stack modal */
    #editStudentModal .admin-stack-modal__panel {
        max-width: 860px;
        width: min(94vw, 860px);
        margin: 2rem auto;
    }

    #editStudentModal form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.9rem 1rem;
    }

    #editStudentModal .form-group {
        margin-bottom: 0;
    }

    #editStudentModal .d-flex.gap-1 {
        grid-column: 1 / -1;
        justify-content: flex-end;
        margin-top: 0.2rem;
    }

    /* Access + details density inside subscription modal */
    #adminModal .admin-students-table-compact th,
    #adminModal .admin-students-table-compact td {
        padding: 0.55rem 0.6rem;
        font-size: 0.8rem;
    }
}

.admin-modal-loading {
    padding: 2rem;
    text-align: center;
}

.code-ref-sm {
    font-size: 0.75rem;
}

.link-check-ok {
    color: var(--secondary);
}

.link-check-bad {
    color: var(--danger);
}

.link-check-warn {
    color: var(--warning);
}

/* ===== Reports page (admin/reports.php) ===== */
.report-filter-select {
    min-width: 190px;
    max-width: 240px;
}

.report-filter-select-wide {
    min-width: 190px;
    max-width: 260px;
}

.report-empty-cell {
    padding: 2rem;
}

.report-pct-track {
    flex: 1;
    max-width: 120px;
    height: 6px;
    background: var(--light-gray);
    border-radius: 3px;
    overflow: hidden;
}

.report-pct-fill {
    height: 100%;
    background: var(--danger);
    border-radius: 3px;
}

.report-divider {
    color: var(--light-gray);
}
