/* ============================================================
   EXAM PAGE
   ============================================================ */

body.exam-page {
  background: var(--surface);
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ── Header ── */
.exam-header {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.exam-header-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; gap: 20px;
}

.exam-title-block {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
.exam-part-label {
  flex-shrink: 0;
  background: var(--red-light); color: var(--red);
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
}
.exam-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.exam-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Timer */
.timer-block {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 6px 14px;
  font-family: var(--font-en); font-size: 15px; font-weight: 700; color: var(--ink);
  transition: background .3s, color .3s, border-color .3s;
}
.timer-block svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.timer-block.warning { background: #FFF7ED; border-color: #F97316; color: #C2410C; }
.timer-block.warning svg { color: #F97316; }
.timer-block.danger  { background: #FFF1F2; border-color: var(--red); color: var(--red); animation: timerPulse 1s infinite; }
.timer-block.danger  svg { color: var(--red); }
@keyframes timerPulse { 0%,100%{opacity:1} 50%{opacity:.6} }

.exam-progress-pill {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 6px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.exam-progress-pill span:first-child { color: var(--red); font-weight: 800; }

/* Progress bar under header */
.exam-header-bar {
  height: 3px; background: var(--border); overflow: hidden;
}
.exam-header-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), #FF6B35);
  width: 0%; transition: width .4s ease;
  border-radius: 2px;
}

/* ── Layout ── */
.exam-layout {
  max-width: 1240px; margin: 0 auto;
  padding: 28px 28px 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Sidebar ── */
.exam-sidebar {
  position: sticky; top: 76px;
}
.sidebar-inner {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 20px;
}
.sidebar-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--muted);
  margin-bottom: 14px;
}

/* Question grid */
.q-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; margin-bottom: 18px;
}
.q-btn {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-family: var(--font-en); font-size: 13px; font-weight: 700;
  color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.q-btn:hover       { border-color: var(--red); color: var(--red); }
.q-btn.answered    { background: var(--red); border-color: var(--red); color: #fff; }
.q-btn.current     { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.q-btn.answered.current { background: var(--red-dark); border-color: var(--red-dark); box-shadow: 0 0 0 2px var(--red-dark); color: #fff; }

/* Legend */
.sidebar-legend {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.leg-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.leg-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.leg-answered   { background: var(--red); }
.leg-current    { background: var(--ink); }
.leg-unanswered { background: var(--border); }

/* Submit button in sidebar */
.btn-submit-exam {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #fff;
  border: none; border-radius: var(--r);
  padding: 12px;
  font-family: var(--font-th); font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .1s;
}
.btn-submit-exam svg { width: 17px; height: 17px; }
.btn-submit-exam:hover { background: #1a1a28; transform: translateY(-1px); }

/* ── Main exam area ── */
.exam-main {
  display: flex; flex-direction: column; gap: 16px;
  padding-bottom: 40px;
}

/* Section title card */
.section-title-card {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  border-radius: var(--r-lg); padding: 22px 28px;
  color: #fff;
}
.section-title-card h2 { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.section-title-card p  { font-size: 13px; color: rgba(255,255,255,.75); }

/* Question card */
.q-card {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 28px;
  scroll-margin-top: 90px;
  transition: border-color .2s;
}
.q-card.answered { border-color: rgba(232,36,60,.25); }
.q-card.active   { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232,36,60,.07); }

/* Question header */
.q-header {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
}
.q-num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); font-size: 13px; font-weight: 800; color: var(--muted);
  margin-top: 1px;
}
.q-card.answered .q-num { background: var(--red); border-color: var(--red); color: #fff; }
.q-body { font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.65; flex: 1; }

/* Choices */
.q-choices { display: flex; flex-direction: column; gap: 10px; }

.choice-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 13px 18px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r); cursor: pointer;
  font-family: var(--font-th); font-size: 15px; color: var(--ink);
  transition: all .15s;
}
.choice-btn:hover:not(.selected) {
  border-color: #c8c8d8; background: #fff;
  transform: translateX(2px);
}
.choice-btn.selected {
  background: var(--red-light); border-color: var(--red);
  color: var(--red);
}
.choice-btn.selected .choice-marker {
  background: var(--red); border-color: var(--red); color: #fff;
}

/* Correct/wrong states (post-submit) */
.choice-btn.correct {
  background: #F0FDF4; border-color: #22C55E; color: #15803D;
}
.choice-btn.correct .choice-marker { background: #22C55E; border-color: #22C55E; color: #fff; }
.choice-btn.wrong {
  background: #FFF1F2; border-color: var(--red); color: var(--red);
}
.choice-btn.wrong .choice-marker { background: var(--red); border-color: var(--red); color: #fff; }

.choice-marker {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); font-size: 12px; font-weight: 800; color: var(--muted);
  transition: all .15s;
}

/* Explanation (shown after submit) */
.q-explanation {
  margin-top: 18px; padding: 16px 18px;
  background: #F8FAFF; border: 1.5px solid #DBEAFE;
  border-radius: var(--r);
  font-size: 14px; color: #1E40AF; line-height: 1.7;
  display: none;
}
.q-explanation.show { display: block; }
.q-explanation strong { font-weight: 700; }

/* ── Mobile bottom bar ── */
.mobile-exam-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  padding: 12px 20px;
  align-items: center; justify-content: space-between; gap: 12px;
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.mob-btn {
  padding: 10px 20px; border-radius: var(--r);
  border: 1.5px solid var(--border); background: #fff;
  font-family: var(--font-th); font-size: 14px; font-weight: 700; color: var(--ink);
  cursor: pointer; transition: all .15s;
}
.mob-btn:hover { background: var(--surface); }
.mob-btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.mob-btn-red:hover { background: var(--red-dark); }
.mobile-exam-bar span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(13,13,20,.55);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff; border-radius: var(--r-lg);
  padding: 40px 36px; width: 100%; max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn { from{transform:scale(.9);opacity:0} to{transform:scale(1);opacity:1} }

.modal-icon { font-size: 40px; margin-bottom: 14px; }
.modal-box h2 { font-size: 22px; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.modal-box p  { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.modal-warn {
  background: #FFF7ED; border: 1px solid #FED7AA;
  border-radius: var(--r-sm); padding: 10px 14px;
  font-size: 13px; color: #9A3412;
  margin: 12px 0 0;
}
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-btn-cancel {
  flex: 1; padding: 12px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r); font-family: var(--font-th);
  font-size: 15px; font-weight: 700; color: var(--ink);
  cursor: pointer; transition: background .15s;
}
.modal-btn-cancel:hover { background: #ededf5; }
.modal-btn-confirm {
  flex: 1; padding: 12px;
  background: var(--red); border: none;
  border-radius: var(--r); font-family: var(--font-th);
  font-size: 15px; font-weight: 700; color: #fff;
  cursor: pointer; transition: background .15s;
}
.modal-btn-confirm:hover { background: var(--red-dark); }

/* ── Result overlay ── */
.result-overlay {
  position: fixed; inset: 0;
  background: var(--surface);
  z-index: 400; overflow-y: auto;
}
.result-box {
  max-width: 680px; margin: 0 auto;
  padding: 48px 28px 80px;
  display: flex; flex-direction: column; align-items: center; gap: 28px;
}

.result-header { text-align: center; }
.result-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; }
.result-header h2 { font-size: 28px; font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.result-subtitle { font-size: 14px; color: var(--muted); }

/* Score ring */
.result-score-ring { position: relative; display: flex; align-items: center; justify-content: center; }
.result-score-text {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  text-align: center;
}
.result-score-text strong { display: block; font-family: var(--font-en); font-size: 36px; font-weight: 900; color: var(--red); line-height: 1; }
.result-score-text span   { font-size: 14px; color: var(--muted); font-weight: 600; }

.result-stats {
  display: flex; gap: 16px; width: 100%;
}
.rs-item {
  flex: 1; text-align: center; padding: 18px;
  border-radius: var(--r-lg); border: 1.5px solid var(--border);
  background: #fff;
}
.rs-item strong { display: block; font-family: var(--font-en); font-size: 32px; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.rs-item span   { font-size: 13px; color: var(--muted); }
.rs-correct strong { color: #22C55E; }
.rs-wrong   strong { color: var(--red); }
.rs-skip    strong { color: var(--muted); }

/* Review cards */
.result-review { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.review-card {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px;
}
.review-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.review-num { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface); padding: 3px 10px; border-radius: 6px; }
.review-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 6px; }
.rb-correct { background: #F0FDF4; color: #15803D; }
.rb-wrong   { background: #FFF1F2; color: var(--red); }
.rb-skip    { background: var(--surface); color: var(--muted); }
.review-q   { font-size: 14px; color: var(--ink); line-height: 1.6; margin-bottom: 10px; font-weight: 600; }
.review-ans { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.ra-your    { color: var(--red); }
.ra-correct { color: #15803D; font-weight: 700; }
.ra-skip    { color: var(--muted); }

.result-actions { display: flex; gap: 14px; }
.btn-outline-red {
  padding: 13px 28px; border-radius: var(--r);
  border: 2px solid var(--red); background: #fff; color: var(--red);
  font-family: var(--font-th); font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all .18s;
}
.btn-outline-red:hover { background: var(--red); color: #fff; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-sidebar { position: static; }
  .sidebar-inner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
  .sidebar-label { width: 100%; }
  .q-grid { flex: 1; }
  .sidebar-legend { flex-direction: row; border: none; padding: 0; margin: 0; }
  .btn-submit-exam { width: auto; padding: 10px 20px; }
  .mobile-exam-bar { display: flex; }
  body.exam-page { padding-bottom: 80px; }
  .exam-title { display: none; }
}

@media (max-width: 480px) {
  .exam-layout { padding: 16px 16px 0; }
  .q-card { padding: 20px; }
  .modal-box { padding: 32px 20px; }
  .result-stats { flex-direction: row; }
  .rs-item strong { font-size: 26px; }
}
