/* ===================================================
   LinguaQuest — Exam Mode Styles
   All-questions-at-once civil services exam layout
   =================================================== */

.exam-page {
  min-height: 100vh;
  background: var(--brand-surface);
  display: flex;
  flex-direction: column;
}

/* ── Top Bar ── */
.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248,245,239,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(107,123,141,0.15);
  padding: 0 24px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.exam-topbar .exam-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-dark);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-timer-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-primary);
  color: white;
  padding: 6px 16px;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.3s;
}
.exam-timer-badge.warning { background: var(--warning); }
.exam-timer-badge.danger { background: var(--error); animation: pulse-danger 1s infinite; }
.exam-timer-badge i { width: 16px; height: 16px; }

.exam-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.exam-lang-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 2px solid var(--brand-primary);
  background: transparent;
  color: var(--brand-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}
.exam-lang-toggle:hover { background: var(--brand-primary); color: white; }
.exam-lang-toggle.active { background: var(--brand-primary); color: white; }

/* ── Main Layout ── */
.exam-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - var(--nav-height) - 72px); /* minus topbar and bottom nav */
}

/* ── Question Panel (scrollable) ── */
.exam-questions {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 120px;
  scroll-behavior: smooth;
}

.exam-question-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  margin-bottom: 20px;
  transition: border-color 0.25s, box-shadow 0.25s;
  overflow: hidden;
  scroll-margin-top: 24px;
}

.exam-question-card.current {
  border-color: var(--brand-primary);
  box-shadow: 0 4px 24px rgba(27,73,101,0.12);
}

.exam-question-card.answered {
  border-color: var(--success);
}

.exam-question-card.flagged {
  border-color: var(--warning);
}

.exam-question-card.flagged.answered {
  border-color: var(--warning);
}

.exam-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(107,123,141,0.1);
}

.exam-q-number {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-q-number .q-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-light);
  border: 2px solid rgba(107,123,141,0.2);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand-dark);
  transition: all 0.2s;
}

.exam-card-header.answered .q-num-badge {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.exam-card-header.flagged .q-num-badge {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.exam-flag-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1.5px solid rgba(107,123,141,0.25);
  background: transparent;
  color: var(--brand-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}
.exam-flag-btn:hover { border-color: var(--warning); color: var(--warning); }
.exam-flag-btn.active {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}
.exam-flag-btn i { width: 12px; height: 12px; }

.exam-card-body {
  padding: 20px;
}

.exam-question-text {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--brand-dark);
  line-height: 1.6;
  margin-bottom: 4px;
}

.exam-question-text-en {
  margin-bottom: 4px;
}

.exam-question-text-ta {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--brand-muted);
  margin-bottom: 16px;
  font-style: italic;
}

.exam-passage {
  background: rgba(27,73,101,0.04);
  border: 1px solid rgba(107,123,141,0.12);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.exam-passage-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.exam-passage-label i { width: 14px; height: 14px; }
.exam-passage-text { font-size: 0.9375rem; line-height: 1.7; color: var(--brand-dark); }

.exam-image-wrap {
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.exam-image-wrap img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

/* ── Radio Option Cards ── */
.exam-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exam-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid rgba(107,123,141,0.2);
  border-radius: var(--radius-md);
  background: var(--brand-light);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--brand-dark);
  line-height: 1.5;
}

.exam-option:hover {
  border-color: var(--brand-primary);
  background: rgba(27,73,101,0.04);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27,73,101,0.08);
}

.exam-option.selected {
  border-color: var(--success);
  background: rgba(45,106,79,0.06);
  box-shadow: 0 2px 8px rgba(45,106,79,0.1);
}

.exam-option-marker {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(107,123,141,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-muted);
  background: white;
  transition: all 0.2s;
  margin-top: 1px;
}

.exam-option.selected .exam-option-marker {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.exam-option-text-wrap { flex: 1; }
.exam-option-text-en { display: block; }
.exam-option-text-ta {
  display: block;
  font-size: 0.8125rem;
  color: var(--brand-muted);
  font-style: italic;
  margin-top: 2px;
}

/* ── Sidebar ── */
.exam-sidebar {
  width: 280px;
  min-width: 280px;
  background: white;
  border-left: 1px solid rgba(107,123,141,0.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.exam-sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(107,123,141,0.1);
  text-align: center;
}

.exam-sidebar-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.exam-sidebar-sub {
  font-size: 0.75rem;
  color: var(--brand-muted);
}

/* Question Grid */
.exam-q-grid-wrap {
  padding: 16px;
  flex: 1;
}

.exam-q-grid-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.exam-grid-item {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  background: white;
  color: var(--brand-muted);
}

.exam-grid-item:hover { transform: scale(1.1); }

.exam-grid-item.not-visited {
  background: white;
  border-color: rgba(107,123,141,0.25);
  color: var(--brand-muted);
}

.exam-grid-item.current {
  border-color: var(--brand-primary);
  background: white;
  color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(27,73,101,0.15);
}

.exam-grid-item.answered {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.exam-grid-item.flagged {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.exam-grid-item.answered.flagged {
  background: linear-gradient(135deg, var(--success) 50%, var(--warning) 50%);
  border-color: var(--success);
  color: white;
}

.exam-grid-item.wrong {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

/* Legend */
.exam-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(107,123,141,0.04);
  border-radius: var(--radius-md);
  margin: 0 16px 12px;
}

.exam-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6875rem;
  color: var(--brand-muted);
}

.exam-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}

.exam-legend-dot.answered { background: var(--success); border-color: var(--success); }
.exam-legend-dot.flagged { background: var(--warning); border-color: var(--warning); }
.exam-legend-dot.unanswered { background: white; border-color: rgba(107,123,141,0.3); }
.exam-legend-dot.current { background: white; border-color: var(--brand-primary); box-shadow: 0 0 0 2px rgba(27,73,101,0.15); }

/* Stats */
.exam-stats {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-bottom: 1px solid rgba(107,123,141,0.1);
}

.exam-stat-item {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  background: rgba(107,123,141,0.05);
}

.exam-stat-num {
  font-size: 1.125rem;
  font-weight: 800;
  font-family: var(--font-display);
  line-height: 1;
  margin-bottom: 3px;
}
.exam-stat-num.answered { color: var(--success); }
.exam-stat-num.unanswered { color: var(--brand-muted); }
.exam-stat-num.flagged { color: var(--warning); }
.exam-stat-label { font-size: 0.625rem; font-weight: 600; color: var(--brand-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Finish Button */
.exam-finish-section {
  padding: 16px;
}

.exam-finish-btn {
  width: 100%;
  padding: 14px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}
.exam-finish-btn:hover { background: #a30f1a; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(193,18,31,0.3); }
.exam-finish-btn i { width: 16px; height: 16px; }

/* ── Bottom Nav Bar ── */
.exam-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: rgba(248,245,239,0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(107,123,141,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  padding: 0 24px;
}

.exam-nav-btn {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.exam-nav-btn i { width: 16px; height: 16px; }

.exam-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.exam-nav-btn.skip {
  background: #2D8B8A;
  color: white;
}
.exam-nav-btn.skip:hover:not(:disabled) { background: #246869; transform: translateY(-1px); }

.exam-nav-btn.prev {
  background: var(--brand-primary);
  color: white;
}
.exam-nav-btn.prev:hover:not(:disabled) { background: #153d52; transform: translateY(-1px); }

.exam-nav-btn.next {
  background: var(--success);
  color: white;
}
.exam-nav-btn.next:hover:not(:disabled) { background: #245c46; transform: translateY(-1px); }

.exam-nav-btn.finish {
  background: var(--error);
  color: white;
}
.exam-nav-btn.finish:hover:not(:disabled) { background: #a30f1a; transform: translateY(-1px); }

/* Progress at bottom */
.exam-progress-bar-bottom {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(107,123,141,0.1);
  z-index: 99;
}
.exam-progress-bar-bottom .fill {
  height: 100%;
  background: var(--brand-primary);
  transition: width 0.3s ease;
}

/* ── Confirmation Modal ── */
.exam-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,37,53,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.exam-confirm-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.exam-confirm-box {
  background: white;
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-modal);
  text-align: center;
}
.exam-confirm-box h3 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  color: var(--brand-dark);
  margin-bottom: 12px;
}
.exam-confirm-box p {
  color: var(--brand-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 24px;
}
.exam-confirm-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}
.exam-confirm-stat {
  text-align: center;
}
.exam-confirm-stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--brand-dark);
}
.exam-confirm-stat-label {
  font-size: 0.75rem;
  color: var(--brand-muted);
  margin-top: 2px;
}
.exam-confirm-stat.answered .exam-confirm-stat-num { color: var(--success); }
.exam-confirm-stat.unanswered .exam-confirm-stat-num { color: var(--error); }
.exam-confirm-stat.flagged .exam-confirm-stat-num { color: var(--warning); }

.exam-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .exam-sidebar {
    position: fixed;
    right: 0;
    top: var(--nav-height);
    height: calc(100vh - var(--nav-height) - 72px);
    width: 260px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 150;
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  }
  .exam-sidebar.open { transform: translateX(0); }

  .exam-sidebar-toggle {
    display: flex;
  }

  .exam-body {
    height: calc(100vh - var(--nav-height) - 72px);
  }

  .exam-questions {
    padding: 20px 16px 100px;
  }

  .exam-question-text { font-size: 0.9375rem; }
  .exam-option { padding: 12px; font-size: 0.875rem; }

  .exam-nav-btn { padding: 10px 16px; font-size: 0.875rem; }
}

@media (min-width: 769px) {
  .exam-sidebar-toggle { display: none; }
}

/* Sidebar toggle FAB */
.exam-sidebar-toggle {
  position: fixed;
  bottom: 88px;
  right: 16px;
  z-index: 120;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s, box-shadow 0.2s;
}
.exam-sidebar-toggle:hover { transform: scale(1.1); }
.exam-sidebar-toggle i { width: 20px; height: 20px; }

/* Pulse animation */
@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Results screen */
.exam-results {
  max-width: 600px;
  margin: 60px auto;
  padding: 0 24px;
  text-align: center;
}

.exam-results-score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(27,73,101,0.12);
  background: white;
}
.exam-results-pct {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--brand-dark);
  line-height: 1;
}
.exam-results-label {
  font-size: 0.8125rem;
  color: var(--brand-muted);
  margin-top: 4px;
}

/* Audio player */
.exam-audio-wrap {
  background: rgba(27,73,101,0.04);
  border: 1px solid rgba(107,123,141,0.12);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.exam-audio-wrap audio {
  width: 100%;
  border-radius: var(--radius-sm);
}