/* ============================================
   CBT System - Global Styles
   Font: Inter from Google Fonts
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary:       #4f46e5;
    --primary-dark:  #3730a3;
    --primary-light: #818cf8;
    --accent:        #06b6d4;
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --bg-dark:       #0f172a;
    --bg-card:       #1e293b;
    --bg-sidebar:    #0f172a;
    --text-main:     #f1f5f9;
    --text-muted:    #94a3b8;
    --border:        #334155;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 4px 24px rgba(0,0,0,.4);
    --transition:    .2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Layout ─────────────────────────────────── */
.cbt-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────── */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--text-main);
}

.sidebar-brand .brand-sub {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: -2px;
}

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

.nav-section-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: .5rem 1.5rem .25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition);
    position: relative;
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: .9rem; }

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: var(--text-main);
    background: rgba(79,70,229,.15);
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.04);
}

.sidebar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
    flex-shrink: 0;
}

.sidebar-user-info .uname { font-size: .8rem; font-weight: 600; }
.sidebar-user-info .urole { font-size: .68rem; color: var(--text-muted); text-transform: capitalize; }

.btn-logout {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .75rem;
    background: rgba(239,68,68,.12);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    margin-top: .75rem;
    width: 100%;
    justify-content: center;
}
.btn-logout:hover { background: rgba(239,68,68,.22); color: var(--danger); }

/* ── Main Content ───────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* ── Top bar ────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Cards ──────────────────────────────────── */
.cbt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,.5); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.purple { background: rgba(79,70,229,.2); color: var(--primary-light); }
.stat-icon.cyan   { background: rgba(6,182,212,.2);  color: var(--accent); }
.stat-icon.green  { background: rgba(16,185,129,.2); color: var(--success); }
.stat-icon.amber  { background: rgba(245,158,11,.2); color: var(--warning); }

.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

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

table.cbt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

table.cbt-table thead tr {
    border-bottom: 1px solid var(--border);
}

table.cbt-table th {
    padding: .75rem 1rem;
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    white-space: nowrap;
}

table.cbt-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid rgba(51,65,85,.5);
    vertical-align: middle;
}

table.cbt-table tbody tr:hover { background: rgba(255,255,255,.03); }
table.cbt-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────── */
.badge-cbt {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .3px;
}

.badge-cbt.green  { background: rgba(16,185,129,.15); color: var(--success); border: 1px solid rgba(16,185,129,.3); }
.badge-cbt.red    { background: rgba(239,68,68,.15);  color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.badge-cbt.purple { background: rgba(79,70,229,.15);  color: var(--primary-light); border: 1px solid rgba(79,70,229,.3); }
.badge-cbt.cyan   { background: rgba(6,182,212,.15);  color: var(--accent);  border: 1px solid rgba(6,182,212,.3); }

/* ── Buttons ────────────────────────────────── */
.btn-primary-cbt {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(79,70,229,.35);
}
.btn-primary-cbt:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,.5); color: #fff; }

.btn-danger-cbt {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .85rem;
    background: rgba(239,68,68,.12);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}
.btn-danger-cbt:hover { background: rgba(239,68,68,.22); color: var(--danger); }

.btn-sm-cbt {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    background: rgba(79,70,229,.15);
    color: var(--primary-light);
    border: 1px solid rgba(79,70,229,.3);
    border-radius: 6px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}
.btn-sm-cbt:hover { background: rgba(79,70,229,.28); color: var(--primary-light); }

/* ── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .4rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

.form-control-cbt {
    width: 100%;
    padding: .6rem .9rem;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control-cbt:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.2);
}
.form-control-cbt option { background: var(--bg-card); color: var(--text-main); }

/* ── Alerts ─────────────────────────────────── */
.alert-cbt {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.alert-cbt.success { background: rgba(16,185,129,.12); color: var(--success); border: 1px solid rgba(16,185,129,.25); }
.alert-cbt.error   { background: rgba(239,68,68,.12);  color: var(--danger);  border: 1px solid rgba(239,68,68,.25); }
.alert-cbt.info    { background: rgba(6,182,212,.12);  color: var(--accent);  border: 1px solid rgba(6,182,212,.25); }

/* ── Login Page ─────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
}

.login-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}
.orb1 { width: 500px; height: 500px; background: rgba(79,70,229,.18); top: -150px; left: -100px; }
.orb2 { width: 400px; height: 400px; background: rgba(6,182,212,.12);  bottom: -100px; right: -80px; }

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
    position: relative;
    z-index: 1;
    animation: slideUp .5s ease;
}

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

.login-logo {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: 1.75rem;
}

.login-logo-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff;
    flex-shrink: 0;
}

.login-logo-text h1 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.4px; }
.login-logo-text p  { font-size: .75rem; color: var(--text-muted); }

.login-subtitle { font-size: .9rem; color: var(--text-muted); margin-bottom: 1.5rem; }

.input-icon-wrap { position: relative; }
.input-icon-wrap .input-icon {
    position: absolute;
    left: .85rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .85rem;
    pointer-events: none;
}
.input-icon-wrap .form-control-cbt { padding-left: 2.4rem; }

/* ── Exam Card (Student) ────────────────────── */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }

.exam-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}
.exam-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,.5); }

.exam-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.exam-course-badge {
    font-size: .68rem; font-weight: 700; letter-spacing: .6px;
    text-transform: uppercase;
    padding: .25rem .65rem;
    border-radius: 6px;
    background: rgba(79,70,229,.15);
    color: var(--primary-light);
    border: 1px solid rgba(79,70,229,.25);
}
.exam-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .35rem; }
.exam-card .exam-meta { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 1rem; }
.exam-card .exam-meta i { color: var(--accent); }
.exam-card .start-btn { margin-top: auto; padding-top: 1rem; }

/* ── Exam Room ──────────────────────────────── */
.exam-room { max-width: 860px; margin: 0 auto; }

.exam-header-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    position: sticky;
    top: 1rem;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.exam-timer-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .9rem;
    border-radius: var(--radius-sm);
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.25);
    transition: background var(--transition), border-color var(--transition);
}
.exam-timer-wrap.warning {
    background: rgba(245,158,11,.1);
    border-color: rgba(245,158,11,.3);
}
.exam-timer-wrap.danger {
    background: rgba(239,68,68,.12);
    border-color: rgba(239,68,68,.35);
    animation: pulse 1s infinite;
}

.exam-timer {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--success);
    transition: color var(--transition);
}
.exam-timer-wrap.warning .exam-timer { color: var(--warning); }
.exam-timer-wrap.danger  .exam-timer { color: var(--danger); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.progress-indicator { font-size: .82rem; color: var(--text-muted); }

.question-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.question-number {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--primary-light);
    margin-bottom: .6rem;
}
.question-text { font-size: .95rem; font-weight: 500; margin-bottom: 1rem; line-height: 1.7; }

.options-list { display: flex; flex-direction: column; gap: .5rem; }

.option-label {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .75rem 1rem;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: .875rem;
}
.option-label:hover { background: rgba(79,70,229,.1); border-color: rgba(79,70,229,.4); }
.option-label input[type="radio"] { display: none; }
.option-label input[type="radio"]:checked + .option-letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-label:has(input:checked) { background: rgba(79,70,229,.12); border-color: rgba(79,70,229,.5); }

.option-letter {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
    flex-shrink: 0;
    transition: all var(--transition);
}

/* ── Result Page ────────────────────────────── */
.result-hero {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.score-ring {
    width: 140px; height: 140px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    position: relative;
    background: conic-gradient(var(--primary) var(--pct, 0%), var(--border) 0%);
}
.score-ring-inner {
    width: 110px; height: 110px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
}
.score-pct { font-size: 1.8rem; font-weight: 800; }
.score-label { font-size: .7rem; color: var(--text-muted); }

/* ── Sidebar Overlay & Toggle ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.4rem;
    cursor: pointer;
    margin-right: 1rem;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { 
        transform: translateX(-100%); 
        z-index: 150;
    }
    .sidebar.open { transform: translateX(0); }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    .main-content { margin-left: 0; padding: 1rem; }
    
    .mobile-sidebar-toggle { 
        display: flex;
        position: absolute;
        top: 1.25rem;
        left: 1rem;
        z-index: 10;
    }
    
    .topbar {
        padding-left: 2.5rem; /* Make room for the toggle button */
        flex-direction: column;
        align-items: flex-start;
        position: relative;
    }
    .topbar > div { width: 100%; margin-bottom: 1rem; }
    .topbar > button, .topbar > a { width: 100%; justify-content: center; }

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