/* ── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --border: #475569;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --radius: 10px;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
}

.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,.5);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .icon { font-size: 3rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; margin-top: .5rem; }
.login-logo p { color: var(--text-muted); font-size: .875rem; margin-top: .25rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .5rem; color: var(--text-muted); }
.form-group input {
    width: 100%; padding: .75rem 1rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface2);
    color: var(--text); font-size: 1rem; outline: none; transition: border-color .2s;
}
.form-group input:focus { border-color: var(--accent); }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.75rem; }
.password-toggle {
    position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; padding: 0;
    color: var(--text-muted); display: flex; align-items: center;
    transition: color .2s;
}
.password-toggle:hover { color: var(--text); }

.btn-primary {
    width: 100%; padding: .875rem; background: var(--accent); color: #fff;
    border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.alert-error {
    background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4);
    color: #fca5a5; border-radius: 8px; padding: .75rem 1rem;
    margin-bottom: 1.25rem; font-size: .875rem;
}

/* ── Exam Page ────────────────────────────────────────────────────────────── */
.exam-page { display: flex; flex-direction: column; min-height: 100vh; }

.exam-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0 1.5rem; height: 56px; display: flex; align-items: center;
    justify-content: space-between; gap: 1rem; flex-shrink: 0;
}

.exam-header-left { display: flex; align-items: center; gap: 1rem; }
.exam-header-left .logo { font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.exam-header-left .exam-title { font-size: .875rem; color: var(--text-muted); }

.exam-header-right { display: flex; align-items: center; gap: .75rem; }

.status-badge {
    display: flex; align-items: center; gap: .375rem;
    padding: .25rem .75rem; border-radius: 20px; font-size: .75rem; font-weight: 600;
    background: var(--surface2); border: 1px solid var(--border);
}
.status-badge.active   { border-color: var(--success); color: var(--success); }
.status-badge.warned   { border-color: var(--warning); color: var(--warning); }
.status-badge.paused   { border-color: var(--warning); color: var(--warning); }
.status-badge.locked   { border-color: var(--danger);  color: var(--danger);  }

.rec-indicator { display: flex; align-items: center; gap: .375rem; font-size: .75rem; color: var(--text-muted); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.rec-dot.active { background: var(--danger); animation: pulse 1.5s infinite; }

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

.timer { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn-logout {
    padding: .375rem .875rem; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); font-size: .8rem; cursor: pointer;
    transition: all .2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Exam Body ────────────────────────────────────────────────────────────── */
.exam-body { display: flex; flex: 1; overflow: hidden; }

.exam-sidebar {
    width: 220px; background: var(--surface); border-right: 1px solid var(--border);
    padding: 1.5rem 1rem; flex-shrink: 0; overflow-y: auto;
}

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section h3 { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: .75rem; }

.q-nav { list-style: none; display: flex; flex-wrap: wrap; gap: .375rem; }
.q-nav li {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; cursor: pointer; transition: all .15s;
}
.q-nav li.current { border-color: var(--accent); background: rgba(99,102,241,.2); color: var(--accent); }
.q-nav li.answered { border-color: var(--success); background: rgba(34,197,94,.1); color: var(--success); }
.q-nav li:hover { border-color: var(--text-muted); }

.sdk-status-panel { font-size: .75rem; }
.sdk-status-row { display: flex; justify-content: space-between; padding: .25rem 0; border-bottom: 1px solid var(--surface2); color: var(--text-muted); }
.sdk-status-row:last-child { border-bottom: none; }
.sdk-status-row span:last-child { color: var(--text); }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.exam-main { flex: 1; overflow-y: auto; padding: 2rem; }
#exam-container { max-width: 780px; margin: 0 auto; }

.question-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; margin-bottom: 1.5rem;
}
.question-card .q-num { font-size: .75rem; color: var(--text-muted); margin-bottom: .75rem; }
.question-card .q-text { font-size: 1.1rem; line-height: 1.7; margin-bottom: 1.5rem; }

.options { list-style: none; display: flex; flex-direction: column; gap: .625rem; }
.options li label {
    display: flex; align-items: flex-start; gap: .75rem; padding: .875rem 1rem;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface2);
    cursor: pointer; transition: all .15s; line-height: 1.5; font-size: .95rem;
}
.options li label:hover { border-color: var(--accent); }
.options li input[type=radio] { margin-top: .2rem; accent-color: var(--accent); flex-shrink: 0; }
.options li input[type=radio]:checked + span { color: var(--accent); }
.options li:has(input:checked) label { border-color: var(--accent); background: rgba(99,102,241,.1); }

.exam-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1rem; }
.btn-nav {
    padding: .625rem 1.5rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface2); color: var(--text); font-size: .9rem; cursor: pointer;
    transition: all .15s;
}
.btn-nav:hover { border-color: var(--accent); color: var(--accent); }
.btn-submit {
    padding: .625rem 1.5rem; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: background .2s;
}
.btn-submit:hover { background: var(--accent-hover); }

/* ── Overlay ──────────────────────────────────────────────────────────────── */
.exam-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center;
    z-index: 100; backdrop-filter: blur(4px);
}
.exam-overlay.visible { display: flex; }

.overlay-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2.5rem; max-width: 440px; width: 90%; text-align: center;
}
.overlay-card .overlay-icon { font-size: 3rem; margin-bottom: 1rem; }
.overlay-card h2 { font-size: 1.5rem; margin-bottom: .75rem; }
.overlay-card p { color: var(--text-muted); line-height: 1.6; margin-bottom: 1.5rem; }
.overlay-card .btn-resume {
    padding: .75rem 2rem; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; font-size: 1rem; font-weight: 600;
    cursor: pointer;
}

/* ── Submit spinner ──────────────────────────────────────────────────────── */
.submit-spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid var(--surface2);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.7);
    display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-backdrop.visible { display: flex; }
.modal-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 2rem; max-width: 420px; width: 90%;
}
.modal-card h3 { font-size: 1.2rem; margin-bottom: .75rem; }
.modal-card p { color: var(--text-muted); font-size: .9rem; line-height: 1.6; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.btn-allow  { padding: .6rem 1.25rem; border: none; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.btn-deny   { padding: .6rem 1.25rem; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--text-muted); cursor: pointer; }
