/* ── Variables ─────────────────────────────────────────────── */
:root {
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --primary: #4f46e5;
    --primary-soft: #eef2ff;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --body-bg: #f8fafc;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: #c7d2fe;
    --sidebar-active: #6366f1;
    --card-radius: 12px;
    --border: #e2e8f0;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.1);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: #1e293b;
    margin: 0;
}

/* ── Auth Pages ────────────────────────────────────────────── */
.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 50%, #312e81 100%);
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.auth-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
    margin-bottom: .25rem;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav { padding: .75rem 0; list-style: none; margin: 0; }

.nav-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(199,210,254,.45);
    padding: 1rem 1.25rem .4rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem 1.25rem;
    color: var(--sidebar-text);
    font-size: .875rem;
    border-radius: 0;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(99,102,241,.18);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.sidebar-nav .nav-link i { font-size: 1rem; opacity: .8; }

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

.avatar-sm {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 600;
    flex-shrink: 0;
}

/* ── Main Content ──────────────────────────────────────────── */
#main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.page-body { padding: 1.5rem 2rem; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s, transform .2s;
}

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

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.green  { background: #f0fdf4; color: #22c55e; }
.stat-icon.orange { background: #fff7ed; color: #f97316; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-icon.teal   { background: #f0fdfa; color: #14b8a6; }

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

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border);
}
.table tbody tr:hover { background: #f8fafc; }
.table td { vertical-align: middle; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-size: .7rem; padding: .35em .7em; font-weight: 600; border-radius: 6px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; font-size: .875rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }

/* ── Form Controls ───────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: .875rem;
    padding: .5rem .75rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }

/* ── Exam Engine ─────────────────────────────────────────────── */
.exam-container {
    max-width: 900px;
    margin: 0 auto;
}

.exam-topbar {
    background: #1e1b4b;
    color: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.exam-timer {
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(255,255,255,.1);
    padding: .25rem .75rem;
    border-radius: 8px;
}

.exam-timer.warning  { color: #fbbf24; }
.exam-timer.critical { color: #f87171; animation: pulse 1s infinite; }

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

.question-card {
    border: 2px solid var(--border);
    border-radius: var(--card-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color .2s;
}

.question-card.answered { border-color: #86efac; background: #f0fdf4; }
.question-card.current  { border-color: var(--primary); }

.question-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.q-nav-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #fff;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    display: flex; align-items: center; justify-content: center;
}
.q-nav-btn.answered { background: #22c55e; border-color: #22c55e; color: #fff; }
.q-nav-btn.current  { border-color: var(--primary); color: var(--primary); }

.option-label {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: .5rem;
}
.option-label:hover { border-color: var(--primary); background: var(--primary-soft); }
.option-label.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-letter {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
    flex-shrink: 0;
}

/* Proctoring overlay */
.violation-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--danger);
    color: #fff;
    text-align: center;
    padding: .6rem;
    font-weight: 600;
    z-index: 9999;
    animation: slideDown .3s ease;
}
@keyframes slideDown { from{transform:translateY(-100%)} to{transform:translateY(0)} }

/* Webcam pip */
.webcam-pip {
    position: fixed;
    bottom: 1rem; right: 1rem;
    width: 180px; height: 135px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    background: #000;
}
.webcam-pip video { width: 100%; height: 100%; object-fit: cover; }
.webcam-pip-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: .65rem;
    text-align: center;
    padding: .2rem;
}

/* Monitoring grid */
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.monitor-card {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--card-radius);
    padding: 1rem;
    position: relative;
}
.monitor-card.flagged { border-color: var(--danger); background: #fef2f2; }
.monitor-card.active  { border-color: var(--success); }
.monitor-status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: .4rem;
}
.dot-active   { background: var(--success); }
.dot-idle     { background: var(--warning); }
.dot-flagged  { background: var(--danger); }
.dot-complete { background: var(--text-muted); }

/* Progress ring */
.progress-ring { --r: 30; }
.progress-ring circle { fill: none; stroke-width: 4; }
.progress-ring .track { stroke: #e2e8f0; }
.progress-ring .fill  { stroke: var(--primary); stroke-linecap: round;
                         transform: rotate(-90deg); transform-origin: center;
                         transition: stroke-dashoffset 1s; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    .page-body { padding: 1rem; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background-color: var(--primary) !important; }
.rounded-xl   { border-radius: var(--card-radius) !important; }
.shadow-sm    { box-shadow: var(--shadow-sm) !important; }
.shadow-md    { box-shadow: var(--shadow-md) !important; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; }
.fw-600 { font-weight: 600; }
.fs-sm  { font-size: .875rem; }
.fs-xs  { font-size: .75rem; }
