/* ─── Variables ─────────────────────────────────────────────────── */
:root {
    --primary: #0f766e;
    --primary-light: #14b8a6;
    --accent: #e6f6f3;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-25: #f8fafc;
    --gray-50: #f5f7fb;
    --gray-100: #eef1f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #0f172a;
    --surface: #ffffff;
    --sidebar-w: 240px;
    --radius: 10px;
    --shadow: 0 8px 30px rgba(0,0,0,.04);
    --shadow-md: 0 10px 40px rgba(0,0,0,.06);
}

/* ─── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    letter-spacing: -0.01em;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); text-decoration: none; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    box-shadow: none;
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
    border-radius: 10px;
    font-weight: 600;
}
.btn-outline-primary:hover { background: var(--primary); color: white; }

/* ─── Student Layout ─────────────────────────────────────────────── */
.student-body { background: radial-gradient(circle at 20% 20%, rgba(20,184,166,.08), transparent 38%), var(--gray-50); min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
    background: rgba(255,255,255,0.86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 20;
}
.site-title { font-size: 1.25rem; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.site-subtitle { font-size: 0.85rem; color: var(--gray-600); }

.main-content { flex: 1; }
.site-footer { background: var(--surface); border-top: 1px solid var(--gray-200); color: var(--gray-600); font-size: .82rem; }

/* ─── Session Cards ──────────────────────────────────────────────── */
.session-list { display: flex; flex-direction: column; gap: 12px; }
.session-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 18px 22px;
    gap: 16px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.session-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary-light); }
.session-card-body { flex: 1; }
.session-name { font-size: 1.12rem; font-weight: 700; margin: 0 0 6px; color: var(--gray-900); }
.session-subject { margin: 0 0 8px; color: var(--gray-600); font-size: .92rem; }
.session-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.meta-item { font-size: .82rem; color: var(--gray-600); background: var(--gray-100); padding: 4px 10px; border-radius: 999px; }
.session-desc { margin: 0; }
.btn-enter { white-space: nowrap; }

.empty-state { text-align: center; padding: 48px 0; }
.empty-text { font-size: 1.1rem; color: var(--gray-600); margin-bottom: 8px; }
.page-heading { font-size: 1.45rem; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }

/* ─── Form Card ──────────────────────────────────────────────────── */
.form-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.form-card-header {
    background: linear-gradient(120deg, rgba(20,184,166,0.12), rgba(15,118,110,0.08));
    color: var(--primary);
    padding: 18px 24px;
}
.form-card-header h4 { color: var(--primary); margin: 0; font-weight: 700; }
.form-card-body { padding: 24px; background: var(--surface); }

.required-label::after { content: " *"; color: var(--danger); }

/* ─── Camera Capture ─────────────────────────────────────────────── */
.camera-container { text-align: center; background: var(--gray-900); border-radius: var(--radius); overflow: hidden; min-height: 240px; display: flex; align-items: center; justify-content: center; }
.camera-video { max-width: 100%; max-height: 320px; display: block; width: 100%; }
.camera-canvas { display: none; }
.captured-photo { max-width: 100%; max-height: 280px; border-radius: 4px; }

/* ─── Exam Layout ────────────────────────────────────────────────── */
.exam-timer-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.92);
    color: var(--gray-700);
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
    backdrop-filter: blur(6px);
}
.exam-info-brief { font-size: .9rem; overflow: hidden; }
.timer-display { font-size: .95rem; white-space: nowrap; }
.timer-value { font-family: 'Be Vietnam Pro', monospace; font-size: 1.2rem; font-weight: 700; background: var(--accent); color: var(--primary); padding: 4px 12px; border-radius: 8px; }
.timer-value.warning { color: #d97706; }
.timer-value.danger { color: #f87171; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

/* Question Navigator */
.question-nav { max-height: calc(100vh - 120px); overflow-y: auto; }
.nav-header { font-size: .8rem; font-weight: 600; text-transform: uppercase; color: var(--gray-600); padding: 12px 0 8px; }
.nav-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.nav-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: var(--surface);
    font-size: .8rem;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all .15s;
}
.nav-btn:hover { border-color: var(--primary-light); color: var(--primary-light); text-decoration: none; }
.nav-btn.answered { background: var(--primary-light); color: white; border-color: var(--primary-light); box-shadow: var(--shadow); }
.nav-btn.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(20,184,166,0.35); }
.nav-btn.answered.current { box-shadow: 0 0 0 2px rgba(15,118,110,0.45); }
.nav-legend { font-size: .75rem; color: var(--gray-600); }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--gray-200); background: white; vertical-align: middle; }
.legend-dot.answered { background: var(--primary-light); border-color: var(--primary-light); }

/* Question Cards — single view */
.question-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: none;
}
.question-card.active-q { display: block; }
.question-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--gray-100); }
.question-num { font-weight: 700; color: var(--primary); }
.question-type-badge { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.badge-mcq { background: #dbeafe; color: #1d4ed8; }
.badge-essay { background: #fef3c7; color: #92400e; }
.question-points { margin-left: auto; font-size: .82rem; color: var(--gray-600); }
.question-content { font-size: 1rem; line-height: 1.6; color: var(--gray-900); }

/* Options */
.options-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.option-item:hover { border-color: var(--primary-light); background: #f0f7ff; }
.option-item.selected { border-color: var(--primary-light); background: #eff6ff; }
.option-radio { display: none; }
.option-label {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; min-width: 28px;
    border-radius: 50%;
    background: var(--gray-100);
    font-weight: 700;
    font-size: .85rem;
    color: var(--gray-700);
}
.option-item.selected .option-label { background: var(--primary-light); color: white; }
.option-text { line-height: 1.5; }

/* Essay */
.essay-textarea { font-size: .95rem; line-height: 1.7; resize: vertical; min-height: 160px; }

/* Submit */
.submit-section { text-align: center; }
.submit-info { color: var(--gray-600); font-size: .9rem; }

/* Complete Page */
.complete-icon svg { display: block; margin: 0 auto; }
.result-info { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; text-align: left; }
.result-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: .92rem; }
.result-row:last-child { border-bottom: none; }
.result-label { color: var(--gray-600); }
.result-value { font-weight: 500; }
.score-row .result-value { font-size: 1.4rem; font-weight: 700; color: var(--primary); }

/* ─── Admin Layout ───────────────────────────────────────────────── */
.admin-body { background: var(--gray-50); }
.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    color: var(--gray-900);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--gray-200);
    box-shadow: 6px 0 30px rgba(0,0,0,.03);
}
.sidebar-brand { padding: 20px 16px; border-bottom: 1px solid var(--gray-200); }
.brand-text { font-weight: 700; font-size: 1rem; color: var(--primary); letter-spacing: -0.01em; }
.sidebar-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; }
.sidebar-nav .nav-item { margin: 1px 8px; }
.sidebar-nav .nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--gray-700);
    font-size: .9rem;
    transition: all .15s ease;
}
.sidebar-nav .nav-link:hover { background: var(--gray-100); color: var(--primary); text-decoration: none; }
.sidebar-nav .nav-link.active { background: var(--accent); color: var(--primary); font-weight: 700; border: 1px solid var(--primary-light); }
.sidebar-nav .nav-link-danger { color: #b91c1c; }
.sidebar-nav .nav-link-danger:hover { background: #fef2f2; }
.nav-section { padding: 16px 20px 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--gray-400); letter-spacing: .08em; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    background: rgba(255,255,255,0.9);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}
.topbar-title { font-weight: 600; color: var(--gray-700); }
.topbar-user { font-size: .85rem; color: var(--gray-600); }
.admin-content { flex: 1; }

/* Admin panels */
.admin-panel {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: .9rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    background: linear-gradient(120deg, rgba(20,184,166,0.08), rgba(15,118,110,0.05));
}

/* Stats */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: center;
}
.stat-card-primary { border-left: 3px solid var(--primary-light); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; }
.stat-mini { font-size: 1.3rem; font-weight: 700; color: var(--primary); }

/* Grading */
.question-grade-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    background: white;
}
.question-grade-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-100); }
.question-text { color: var(--gray-800); line-height: 1.6; }
.options-review { display: flex; flex-direction: column; gap: 6px; }
.option-review-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    font-size: .9rem;
}
.option-review-item.selected-answer { border-color: #93c5fd; background: #eff6ff; }
.option-review-item.correct-answer { border-color: #86efac; background: #f0fdf4; }
.option-review-item.selected-answer.correct-answer { border-color: #22c55e; background: #dcfce7; }
.essay-content { font-size: .9rem; line-height: 1.7; color: var(--gray-800); min-height: 60px; white-space: pre-wrap; }
.score-display { font-size: 2.5rem; font-weight: 700; color: var(--primary); }

/* Question form */
.option-input-row .option-label-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; min-width: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}

/* Login */
.login-body {
    background: radial-gradient(circle at 25% 20%, rgba(20,184,166,.12), transparent 38%), var(--gray-25);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 16px; }
.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 36px;
    border: 1px solid var(--gray-200);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-header h2 { color: var(--primary); font-size: 1.45rem; margin-bottom: 4px; letter-spacing: -0.02em; }

/* Responsive sidebar */
@media (max-width: 991px) {
    .admin-sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-w));
        z-index: 1000;
        transition: left .25s;
    }
    .admin-sidebar.show { left: 0; }
}

/* ─── Utilities ──────────────────────────────────────────────────── */
.table th { font-size: .82rem; font-weight: 600; color: var(--gray-600); white-space: nowrap; background: var(--gray-50); }
.table td { vertical-align: middle; font-size: .88rem; }
.badge { font-weight: 500; }

/* ─── Import DOCX ────────────────────────────────────────────────── */
.format-example {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-left: 3px solid var(--primary-light);
    border-radius: 4px;
    padding: 12px 14px;
    overflow-x: auto;
}
.format-example pre { margin: 0; color: var(--gray-800); font-size: .82rem; line-height: 1.6; }

/* ─── Mobile Side Navigation ─────────────────────────────────────── */
.mobile-side-nav {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 90;
    display: none;
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    background: rgba(255,255,255,0.95);
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 12px rgba(0,0,0,0.12);
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    backdrop-filter: blur(6px);
    scrollbar-width: none;
}
.mobile-side-nav::-webkit-scrollbar { display: none; }
.mobile-side-nav .nav-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: .7rem;
    border-radius: 6px;
}

@media (max-width: 991.98px) {
    .mobile-side-nav { display: flex; }
    .exam-layout .col-lg-9 { padding-right: 44px; }
}

/* ─── Quill Editor ───────────────────────────────────────────────── */
.quill-wrapper {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
}
.quill-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.quill-wrapper .ql-container {
    border: none;
    font-family: 'Be Vietnam Pro', sans-serif;
    font-size: .95rem;
}
.quill-wrapper .ql-editor {
    min-height: 160px;
    line-height: 1.7;
}
@media (max-width: 767px) {
    .quill-wrapper .ql-editor { min-height: 120px; }
    .quill-wrapper .ql-toolbar { padding: 4px; }
    .quill-wrapper .ql-toolbar .ql-formats { margin-right: 4px; }
}
