/* ─── GOOGLE FONTS ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Nunito+Sans:wght@400;600;700&display=swap');

/* ─── CSS VARIABLES ──────────────────────────────────────────────────────── */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --accent: #F59E0B;
  --accent-light: #FEF3C7;
  --success: #10B981;
  --success-light: #D1FAE5;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --warning: #F59E0B;

  --bg: #EEF2FF;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;

  --text: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 2px 12px rgba(37, 99, 235, 0.08);
  --shadow-md: 0 4px 24px rgba(37, 99, 235, 0.12);
  --shadow-lg: 0 8px 40px rgba(37, 99, 235, 0.16);

  --font: 'Nunito', sans-serif;
}

/* ─── RESET & BASE ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(245, 158, 11, 0.06) 0%, transparent 50%);
}

button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ─── SCREENS ─────────────────────────────────────────────────────────────── */
.screen { display: none !important; min-height: 100vh; }
.screen.active { display: block !important; }
#screen-welcome.active { display: flex !important; }

/* ─── ALERT OVERLAY ──────────────────────────────────────────────────────── */
#alert-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.alert-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.alert-box p { font-size: 1.1rem; font-weight: 600; margin-bottom: 24px; color: var(--text); }

#alert-ok {
  background: var(--primary);
  color: white;
  padding: 12px 32px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  transition: background 0.2s;
}
#alert-ok:hover { background: var(--primary-dark); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* WELCOME SCREEN                                                              */
/* ═══════════════════════════════════════════════════════════════════════════ */
#screen-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

#screen-welcome.active { display: flex; }

.welcome-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeUp 0.4s ease;
}

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

.welcome-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 32px;
}

.welcome-card h1 {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 28px;
}

.test-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.test-info-item {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
}

.test-info-item .info-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--primary);
  display: block;
}

.test-info-item .info-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}

#last-result {
  display: none;
  margin-bottom: 20px;
}

.last-result-card {
  background: var(--accent-light);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #92400E;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.last-result-score { font-weight: 800; }

#btn-start {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 16px;
  border-radius: var(--radius);
  letter-spacing: 0.3px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  margin-bottom: 16px;
}

#btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45);
}
#btn-start:active { transform: translateY(0); }

.welcome-instructions {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.bank-count {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* TEST SCREEN                                                                 */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ─── TEST SCREEN ─────────────────────────────────────────────────────────── */
.test-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  min-height: 64px;
  flex-wrap: wrap;
}

.test-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.test-title-header {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary);
}

/* Timer */
.timer {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  background: var(--surface-2);
  border: 2px solid var(--border);
  padding: 4px 16px;
  border-radius: var(--radius-sm);
  min-width: 100px;
  text-align: center;
  transition: all 0.3s;
  font-variant-numeric: tabular-nums;
}

.timer.timer-warning {
  color: var(--warning);
  border-color: var(--warning);
  background: var(--accent-light);
}

.timer.timer-critical {
  color: var(--error);
  border-color: var(--error);
  background: var(--error-light);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* Progress bar */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 300px;
}

#progress-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

#progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7C3AED);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

#btn-palette-toggle {
  display: none;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
}

/* ── Test Body ───────────────────────────────────────────────────────────── */
.test-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px;
  align-items: start;
  min-height: calc(100vh - 64px);
}

/* ── Question Panel ──────────────────────────────────────────────────────── */
.question-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  margin-right: 20px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0.4; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

#question-number {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#question-category {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 99px;
}

#question-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* Options */
#options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s;
  cursor: pointer;
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(4px);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
}

.option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: all 0.15s;
}

.option-btn.selected .option-label {
  background: rgba(255,255,255,0.25);
  color: white;
}

.option-btn:hover:not(.selected) .option-label {
  background: var(--primary);
  color: white;
}

.option-text { flex: 1; }

/* Nav buttons */
.nav-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  transition: all 0.15s;
}

#btn-prev {
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text-muted);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  transition: all 0.15s;
}
#btn-prev:hover:not(:disabled) { background: var(--border); color: var(--text); }
#btn-prev:disabled { opacity: 0.35; cursor: not-allowed; }

#btn-next {
  background: var(--primary-light);
  border: 2px solid var(--primary-light);
  color: var(--primary);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  transition: all 0.15s;
}
#btn-next:hover { background: var(--primary); color: white; }

#btn-submit {
  margin-left: auto;
  background: linear-gradient(135deg, #059669, #10B981);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 800;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
#btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

/* ── Question Palette ────────────────────────────────────────────────────── */
.question-palette {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.palette-title {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

#palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}

.palette-btn {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text-muted);
  transition: all 0.15s;
}
.palette-btn:hover { border-color: var(--primary); color: var(--primary); }
.palette-btn.answered { background: var(--success-light); border-color: var(--success); color: #065F46; }
.palette-btn.current { background: var(--primary); border-color: var(--primary); color: white; }

.palette-legend {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.legend-dot {
  width: 14px; height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.legend-dot.current { background: var(--primary); }
.legend-dot.answered { background: var(--success-light); border: 2px solid var(--success); }
.legend-dot.unanswered { background: var(--surface-2); border: 2px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* RESULTS SCREEN                                                              */
/* ═══════════════════════════════════════════════════════════════════════════ */

.results-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.results-header-card {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease;
}

.results-title {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 24px;
}

.score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

#score-number {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
}

#score-total-val {
  font-size: 2rem;
  font-weight: 700;
  opacity: 0.75;
  align-self: flex-end;
  padding-bottom: 8px;
}

#score-percentage {
  font-size: 1.6rem;
  font-weight: 800;
  opacity: 0.9;
  margin-bottom: 8px;
}

.score-grade {
  display: inline-block;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 8px 20px;
  border-radius: 99px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
}

/* Category breakdown */
.breakdown-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.breakdown-card h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
}

.cat-row { margin-bottom: 14px; }
.cat-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.cat-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.cat-score { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }
.cat-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7C3AED);
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Action buttons */
.results-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

#btn-review {
  background: var(--primary-light);
  color: var(--primary);
  padding: 13px 26px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 800;
  transition: all 0.15s;
  flex: 1;
  min-width: 140px;
}
#btn-review:hover { background: var(--primary); color: white; }

#btn-restart {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  padding: 13px 26px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 800;
  transition: all 0.15s;
  flex: 1;
  min-width: 140px;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}
#btn-restart:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4); }

/* ── Review Section ──────────────────────────────────────────────────────── */
.review-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 20px;
  padding-top: 8px;
}

.review-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  border-left: 5px solid var(--border);
  box-shadow: var(--shadow);
}
.review-card.review-correct { border-left-color: var(--success); }
.review-card.review-incorrect { border-left-color: var(--error); }

.review-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.review-qnum {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
}

.review-cat {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 99px;
}

.review-status {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 700;
}

.review-question {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.5;
}

.review-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.review-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 2px solid transparent;
}

.review-option.correct-answer {
  background: var(--success-light);
  border-color: var(--success);
  color: #065F46;
}

.review-option.wrong-answer {
  background: var(--error-light);
  border-color: var(--error);
  color: #991B1B;
}

.review-icon {
  margin-left: auto;
  font-weight: 800;
  font-size: 1rem;
}

.review-explanation {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #92400E;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* RESPONSIVE                                                                  */
/* ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .test-body {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .question-panel { margin-right: 0; margin-bottom: 16px; }

  .question-palette {
    position: static;
    max-height: none;
    display: none;
  }

  .question-palette.palette-open { display: block; }

  #btn-palette-toggle { display: flex; align-items: center; gap: 6px; }

  .test-header { padding: 0 16px; gap: 10px; }
  .test-title-header { display: none; }

  .progress-bar-wrap { display: none; }

  #question-text { font-size: 1.05rem; }
}

@media (max-width: 600px) {
  .welcome-card { padding: 32px 24px; }
  .welcome-card h1 { font-size: 1.4rem; }
  .test-info-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .nav-buttons { flex-direction: column; }
  #btn-submit { margin-left: 0; }
  .results-container { padding: 20px 16px 40px; }
  #score-number { font-size: 4rem; }
}
