@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap');

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2233;
    --bg-card-hover: #1f2a3f;
    --bg-input: #0f1623;
    --border: #2a3548;
    --border-focus: #3b82f6;
    --text-primary: #e8ecf4;
    --text-secondary: #8896ab;
    --text-muted: #5a6a80;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59,130,246,0.15);
    --success: #10b981;
    --success-bg: rgba(16,185,129,0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);
    --info: #06b6d4;
    --info-bg: rgba(6,182,212,0.1);
    --sidebar-w: 260px;
    --header-h: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 16px rgba(0,0,0,0.25);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- AUTH PAGES --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16,185,129,0.06) 0%, transparent 40%),
        var(--bg-primary);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.5s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
    font-family: 'Instrument Serif', serif;
    font-size: 32px;
    font-weight: 400;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-logo span { color: var(--accent); }

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 36px;
}

/* --- LAYOUT --- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    font-family: 'Instrument Serif', serif;
    font-size: 24px;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-role {
    padding: 12px 24px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--accent-glow);
    border-left-color: var(--accent);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-left-color: var(--accent);
    font-weight: 500;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.topbar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 14px;
}

.page-content { padding: 32px; }

.menu-toggle {
    display: none;
    background: none; border: none;
    color: var(--text-primary); cursor: pointer;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Instrument Serif', serif;
    font-size: 36px;
    font-weight: 400;
    color: var(--text-primary);
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 24px; }

/* --- FORMS --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-control, select.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-card); color: var(--text-primary); }

.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-control:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    max-width: 110px;
    border-right: none;
}

.input-group .form-control:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-glow); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { opacity: 0.9; }

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- TABLE --- */
.table-wrapper { overflow-x: auto; }

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

table th, table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    white-space: nowrap;
}

table tr:hover td { background: rgba(59,130,246,0.03); }

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

/* --- BADGES --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-approved, .badge-confirmed, .badge-completed, .badge-active { background: var(--success-bg); color: var(--success); }
.badge-rejected, .badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-scheduled { background: var(--info-bg); color: var(--info); }
.badge-setup { background: rgba(168,85,247,0.1); color: #a855f7; }
.badge-training { background: var(--accent-glow); color: var(--accent); }

/* --- MCQ OPTIONS --- */
.mcq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.mcq-option {
    position: relative;
    cursor: pointer;
}

.mcq-option input { position: absolute; opacity: 0; }

.mcq-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 14px;
}

.mcq-option input:checked + .mcq-label {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
}

.mcq-label:hover {
    border-color: var(--text-muted);
}

.mcq-dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
}

.mcq-option input:checked + .mcq-label .mcq-dot {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: inset 0 0 0 3px var(--bg-card);
}

/* --- STEPS --- */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 36px;
    padding: 0 10px;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.step-num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}

.step.active .step-num {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.step.active { color: var(--text-primary); font-weight: 500; }

.step.done .step-num {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 8px;
    min-width: 20px;
}

.step-content { display: none; animation: fadeUp 0.3s ease; }
.step-content.active { display: block; }

/* --- PRICING CARDS --- */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.pricing-card {
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.pricing-card:hover, .pricing-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.pricing-card .price {
    font-family: 'Instrument Serif', serif;
    font-size: 42px;
    color: var(--accent);
    margin: 12px 0 4px;
}

.pricing-card .price-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.pricing-card .price-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- TIMER --- */
.timer-display {
    text-align: center;
    padding: 48px;
}

.timer-circle {
    width: 200px; height: 200px;
    border-radius: 50%;
    border: 4px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}

.timer-circle.running { border-color: var(--success); animation: pulse 2s ease infinite; }
.timer-circle.warning { border-color: var(--warning); }
.timer-circle.ended { border-color: var(--danger); }

@keyframes pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.2); }
    50% { box-shadow: 0 0 0 20px rgba(16,185,129,0); }
}

.timer-time {
    font-family: 'Instrument Serif', serif;
    font-size: 48px;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.timer-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

/* --- SESSION CODE --- */
.session-code-display {
    text-align: center;
    padding: 32px;
}

.session-code-value {
    font-family: 'DM Sans', monospace;
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--accent);
    margin: 16px 0;
    background: var(--accent-glow);
    padding: 16px 32px;
    border-radius: var(--radius);
    display: inline-block;
    border: 2px dashed var(--accent);
}

/* --- ALERTS --- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    border-left: 4px solid;
    animation: fadeUp 0.3s ease;
}

.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: var(--info); color: var(--info); }

/* --- STARS --- */
.stars { display: inline-flex; gap: 4px; }
.star {
    cursor: pointer;
    font-size: 24px;
    color: var(--border);
    transition: color 0.15s;
}
.star.filled, .star:hover { color: var(--warning); }

.stars-display .star { cursor: default; font-size: 14px; }

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeUp 0.3s ease;
}

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

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

.modal-close {
    background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    font-size: 20px; padding: 4px;
}

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

/* --- FILTER BAR --- */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control { min-width: 160px; }

/* --- NOTE BOX --- */
.note-box {
    background: var(--warning-bg);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 13px;
    color: var(--warning);
    margin: 16px 0;
}

/* --- SCREENSHOT THUMBNAIL --- */
.screenshot-thumb {
    width: 60px; height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.screenshot-thumb:hover { transform: scale(1.1); }

/* --- FILE INPUT --- */
.file-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-display {
    padding: 32px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    transition: var(--transition);
}

.file-input-display:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.5; }
.empty-state h4 { color: var(--text-secondary); margin-bottom: 8px; }

/* --- PAYMENT DETAILS BOX --- */
.payment-details-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

.payment-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.payment-detail-label { color: var(--text-muted); font-size: 13px; }

.payment-detail-value {
    font-family: monospace;
    font-size: 14px;
    color: var(--accent);
    cursor: pointer;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .page-content { padding: 20px; }
    .step-indicator { overflow-x: auto; }
    .auth-card { padding: 32px 24px; }
    .mcq-grid { grid-template-columns: 1fr; }
    .pricing-grid { grid-template-columns: 1fr; }
}

/* --- UTILITY --- */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- COMPLETED TOPICS --- */
.mcq-option.completed-topic .mcq-label {
    opacity: 0.45;
    cursor: not-allowed;
    position: relative;
    border-style: dashed;
}
.mcq-option.completed-topic .mcq-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 16px;
    right: 16px;
    height: 1px;
    background: var(--text-muted);
}
.mcq-option.completed-topic input { pointer-events: none; }

/* ============================================================
   GLOBAL ADMIN SEARCH (topbar)
   ============================================================ */
.topbar-search {
    flex: 1 1 auto;
    max-width: 540px;
    margin: 0 24px;
    position: relative;
}
.topbar-search form { position: relative; }
.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}
#admin-search-input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 38px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font: 14px 'DM Sans', sans-serif;
    outline: none;
    transition: var(--transition);
}
#admin-search-input::placeholder { color: var(--text-muted); }
#admin-search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-card);
}

#admin-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 100;
}

.search-group-header {
    padding: 10px 14px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}
.search-group-footer {
    padding: 10px 14px;
    font-size: 12px;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    bottom: 0;
}
.search-result {
    display: block;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.12s ease;
    cursor: pointer;
}
.search-result:hover,
.search-result.active {
    background: var(--accent-glow);
}
.search-result .title {
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result .badge {
    float: right;
    margin-left: 8px;
    font-size: 10px;
}
.search-empty {
    padding: 24px 14px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Mobile: shrink the search field, hide the user name (keep avatar). */
@media (max-width: 720px) {
    .topbar-search { margin: 0 8px; max-width: none; }
    .topbar-user span { display: none; }
}
@media (max-width: 480px) {
    #admin-search-input::placeholder { color: transparent; }
}
