:root {
    --primary:        #A51C30;
    --primary-hover:  #8B1826;
    --primary-light:  #fdf2f4;
    --primary-border: #f2bdc4;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --border:         #e2e8f0;
    --bg:             #f1f5f9;
    --card:           #ffffff;
    --success:        #059669;
    --warning-color:  #d97706;
    --danger-color:   #dc2626;
    --radius:         10px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
    --shadow-lg:      0 4px 6px rgba(0,0,0,.06), 0 12px 24px rgba(0,0,0,.10);
}

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

body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
    background: var(--card) !important;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    height: 60px;
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary) !important;
    letter-spacing: .02em;
}
.nav-link { color: var(--text-muted) !important; font-size: .92rem; }
.nav-link.active { color: var(--primary) !important; font-weight: 600; }

/* ── Exam top bar (timer + progress) ────────────────── */
.exam-topbar {
    position: sticky;
    top: 60px;
    z-index: 900;
    background: var(--primary);
    color: #fff;
    padding: .55rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(165,28,48,.35);
}
.exam-topbar-title {
    font-weight: 600;
    font-size: .9rem;
    opacity: .92;
}
.exam-topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.progress-text {
    font-size: .85rem;
    opacity: .85;
}
.timer {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    background: rgba(255,255,255,.15);
    border-radius: 6px;
    padding: .2rem .6rem;
}
.timer.timer-warning { background: rgba(217,119,6,.55); }
.timer.timer-danger  { background: rgba(220,38,38,.65); animation: pulse 1s ease-in-out infinite; }

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

/* ── Page header ─────────────────────────────────────── */
.page-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 2rem 0 1.5rem;
    margin-bottom: 2rem;
}
.page-header .course-label {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: .25rem;
}
.page-header .exam-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
}
.page-header .exam-subtitle {
    font-size: .95rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

/* ── Login card ──────────────────────────────────────── */
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    max-width: 440px;
    margin: 0 auto;
}
.login-card .login-icon {
    width: 52px; height: 52px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 1.4rem;
}
.login-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .4rem;
    color: var(--text);
}
.login-card .login-hint {
    font-size: .88rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.75rem;
    line-height: 1.5;
}
.login-card .form-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .35rem;
    display: block;
}
.login-card .form-control {
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: .65rem .9rem;
    font-size: .95rem;
    color: var(--text);
    width: 100%;
    transition: border-color .2s, box-shadow .2s;
    background: var(--card);
}
.login-card .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(165,28,48,.15);
}
.login-card .btn-start {
    display: block;
    width: 100%;
    margin-top: .85rem;
    padding: .7rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: .97rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s, box-shadow .2s;
}
.login-card .btn-start:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 14px rgba(165,28,48,.35);
}
.login-card .btn-start:active:not(:disabled) { transform: translateY(1px); }
.login-card .btn-start:disabled { opacity: .65; cursor: not-allowed; }

/* ── Exam area ───────────────────────────────────────── */
#exam-container {
    animation: fadeIn .4s ease;
}

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

.question {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    transition: box-shadow .2s;
}
.question:hover { box-shadow: var(--shadow-lg); }

.question-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}
.q-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.q-pts {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: .15rem .55rem;
}
.question-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.55;
}

/* Options */
.options { margin-top: 1.1rem; display: flex; flex-direction: column; gap: .5rem; }
.options label {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    font-size: .93rem;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.options label:hover {
    border-color: var(--primary-border);
    background: var(--primary-light);
}
.options input[type="radio"] {
    width: 16px; height: 16px;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.options label:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
    color: var(--primary);
}

/* Short answer */
.short-answer { margin-top: 1rem; }
.short-answer textarea {
    width: 100%;
    padding: .75rem .9rem;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-family: inherit;
    font-size: .93rem;
    line-height: 1.6;
    color: var(--text);
    resize: vertical;
    background: var(--bg);
    transition: border-color .2s, box-shadow .2s;
}
.short-answer textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(165,28,48,.12);
}

/* Submit button */
.submit-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
}
.btn-submit {
    padding: .75rem 2.25rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, transform .1s;
}
.btn-submit:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(165,28,48,.38);
}
.btn-submit:active:not(:disabled) { transform: translateY(1px); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; }

/* ── Result / Confirmation card ──────────────────────── */
#result-container {
    animation: fadeIn .4s ease;
}
.result-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.75rem 2rem;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}
.result-icon {
    width: 64px; height: 64px;
    background: #d1fae5;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 1.8rem;
}
.result-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .5rem;
}
.result-card p {
    font-size: .93rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.submission-id {
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: .95rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: .6rem 1.1rem;
    display: inline-block;
    margin: .25rem 0 .75rem;
    user-select: all;
    word-break: break-all;
    color: var(--primary);
    font-weight: 600;
}
.result-note {
    font-size: .82rem;
    color: var(--text-muted);
}

/* ── Utilities ───────────────────────────────────────── */
.hidden { display: none !important; }

.text-danger { color: var(--danger-color) !important; font-size: .86rem; margin-top: .5rem; }

/* ── Footer ──────────────────────────────────────────── */
.site-footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .85rem;
    text-align: center;
    margin-top: 3rem;
}

/* ── Violation overlay ───────────────────────────────── */
#violation-warning {
    backdrop-filter: blur(4px);
    gap: .6rem;
}

/* ── Modal tweaks ────────────────────────────────────── */
.modal-content { border-radius: var(--radius); border: 1px solid var(--border); }
.modal-header  { border-bottom: 1px solid var(--border); }
.modal-footer  { border-top: 1px solid var(--border); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
    .page-header { padding: 1.5rem 0 1.25rem; }
    .page-header .exam-title { font-size: 1.35rem; }
    .login-card { padding: 2rem 1.25rem; }
    .question { padding: 1.25rem; }
    .exam-topbar { flex-direction: column; align-items: flex-start; gap: .3rem; }
    .exam-topbar-right { gap: 1rem; }
    .submit-row { justify-content: stretch; }
    .btn-submit { width: 100%; }
}
