/* ========================================================================
   ISTQB CT-AI Test Prep — Stylesheet
   ======================================================================== */

:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --primary-dark: #0d1442;
  --accent: #00897b;
  --accent-light: #4db6ac;
  --accent-dark: #00695c;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --error: #c62828;
  --error-bg: #ffebee;
  --warning: #f57f17;
  --warning-bg: #fff8e1;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #5a5a7a;
  --border: #e0e0e8;
  --shadow: 0 2px 8px rgba(26, 35, 126, 0.08);
  --shadow-lg: 0 4px 24px rgba(26, 35, 126, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ======================================================================
   Header / Navigation
   ====================================================================== */
#app-header {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  color: #fff;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.logo-icon {
  color: var(--accent-light);
  font-size: 1.4rem;
}

#main-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-link.active { color: #fff; background: var(--accent); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}

.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all var(--transition);
}

/* ======================================================================
   Main Content
   ====================================================================== */
#app-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

#view-container {
  animation: fadeIn 0.25s ease;
}

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

/* ======================================================================
   Footer
   ====================================================================== */
#app-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
}

.footer-shortcuts { margin-top: 0.25rem; }

.footer-shortcuts kbd {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ======================================================================
   Cards
   ====================================================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

/* ======================================================================
   Dashboard
   ====================================================================== */
.dashboard-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.dashboard-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.dashboard-hero h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.dashboard-hero p {
  font-size: 1.05rem;
  opacity: 0.85;
  max-width: 600px;
}

.exam-info-badges {
  display: flex;
  gap: 1rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.15);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.badge-number {
  font-weight: 700;
  font-size: 1rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.action-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.action-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.action-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.action-card-icon.exam { background: #e8eaf6; color: var(--primary); }
.action-card-icon.practice { background: #e0f2f1; color: var(--accent); }
.action-card-icon.study { background: #fff3e0; color: #e65100; }
.action-card-icon.review { background: #fce4ec; color: #c62828; }

.action-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.action-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ======================================================================
   Buttons
   ====================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-family: var(--font);
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-success { background: var(--success); color: #fff; }
.btn-error { background: var(--error); color: #fff; }

.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ======================================================================
   Forms / Inputs
   ====================================================================== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-select, .form-input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
  user-select: none;
}

.checkbox-label:hover { border-color: var(--accent-light); }

.checkbox-label input { display: none; }

.checkbox-label.checked {
  border-color: var(--accent);
  background: #e0f2f1;
  color: var(--accent-dark);
  font-weight: 600;
}

/* ======================================================================
   Progress Bar
   ====================================================================== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background: var(--accent);
}

.progress-fill.success { background: var(--success); }
.progress-fill.error { background: var(--error); }
.progress-fill.warning { background: var(--warning); }

/* ======================================================================
   Exam Mode
   ====================================================================== */
.exam-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

.exam-main { min-width: 0; }

.exam-sidebar {
  position: sticky;
  top: 76px;
}

.timer-display {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: center;
  padding: 1rem;
  color: var(--primary);
}

.timer-display.warning { color: var(--warning); }
.timer-display.danger { color: var(--error); animation: pulse 1s infinite; }

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

.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 0.75rem;
}

.q-nav-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}

.q-nav-btn:hover { border-color: var(--accent); }
.q-nav-btn.current { border-color: var(--primary); background: var(--primary); color: #fff; }
.q-nav-btn.answered { background: #e8eaf6; border-color: var(--primary-light); color: var(--primary); }
.q-nav-btn.flagged { border-color: var(--warning); background: var(--warning-bg); }
.q-nav-btn.flagged::after { content: ''; display: none; }

.nav-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid var(--border);
}

.legend-dot.current { background: var(--primary); border-color: var(--primary); }
.legend-dot.answered { background: #e8eaf6; border-color: var(--primary-light); }
.legend-dot.flagged { background: var(--warning-bg); border-color: var(--warning); }

/* ======================================================================
   Question Card
   ====================================================================== */
.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  border: 1px solid var(--border);
}

.question-meta {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-secondary);
}

.meta-tag.chapter { background: #e8eaf6; color: var(--primary); }
.meta-tag.klevel { background: #e0f2f1; color: var(--accent-dark); }
.meta-tag.points { background: #fff3e0; color: #e65100; }

.question-number {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.5;
  font-family: var(--font);
  width: 100%;
}

.option-btn:hover:not(:disabled):not(.correct):not(.incorrect) {
  border-color: var(--accent);
  background: #f5fffe;
}

.option-btn.selected {
  border-color: var(--primary);
  background: #e8eaf6;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.option-btn.incorrect {
  border-color: var(--error);
  background: var(--error-bg);
}

.option-btn.correct-answer {
  border-color: var(--success);
  background: var(--success-bg);
}

.option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.option-btn.selected .option-letter {
  background: var(--primary);
  color: #fff;
}

.option-btn.correct .option-letter {
  background: var(--success);
  color: #fff;
}

.option-btn.incorrect .option-letter {
  background: var(--error);
  color: #fff;
}

.option-btn.correct-answer .option-letter {
  background: var(--success);
  color: #fff;
}

.option-text { flex: 1; }

.question-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ======================================================================
   Feedback / Explanation
   ====================================================================== */
.feedback-box {
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
}

.feedback-box.correct {
  background: var(--success-bg);
  border-color: var(--success);
}

.feedback-box.incorrect {
  background: var(--error-bg);
  border-color: var(--error);
}

.feedback-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.feedback-title.motivational {
  font-size: 1.1rem;
  font-style: italic;
  letter-spacing: 0.01em;
}

.feedback-box.correct .feedback-title { color: var(--success); }
.feedback-box.incorrect .feedback-title { color: var(--error); }

.feedback-box.rare-message {
  background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
  border-color: #ff8f00;
  animation: rare-glow 1.5s ease-in-out;
}

.feedback-box.rare-message .feedback-title {
  color: #e65100;
  font-size: 1.15rem;
}

@keyframes rare-glow {
  0% { box-shadow: 0 0 0 0 rgba(255, 143, 0, 0.4); }
  50% { box-shadow: 0 0 16px 4px rgba(255, 143, 0, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(255, 143, 0, 0); }
}

.explanation-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

/* ======================================================================
   Results Page
   ====================================================================== */
.results-header {
  text-align: center;
  padding: 2.5rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  color: #fff;
}

.results-header.passed {
  background: linear-gradient(135deg, var(--success) 0%, #43a047 100%);
}

.results-header.failed {
  background: linear-gradient(135deg, var(--error) 0%, #e53935 100%);
}

.results-score {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1.1;
}

.results-label {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.results-verdict {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.breakdown-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.breakdown-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.breakdown-table tr:last-child td { border-bottom: none; }

/* ======================================================================
   Chapter Study
   ====================================================================== */
.chapter-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.chapter-sidebar {
  position: sticky;
  top: 76px;
}

.chapter-list {
  list-style: none;
}

.chapter-list-item {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.chapter-list-item:hover { background: var(--bg); }

.chapter-list-item.active {
  background: #e8eaf6;
  border-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.chapter-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chapter-list-item.active .chapter-number {
  background: var(--primary);
  color: #fff;
}

.chapter-content h2 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.keywords-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.keyword-tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border-radius: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.lo-list {
  list-style: none;
  margin: 1rem 0;
}

.lo-item {
  padding: 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  flex-direction: column;
}

.lo-item:last-child { border-bottom: none; }

.lo-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  cursor: pointer;
  user-select: none;
}

.lo-header:hover { background: var(--bg); border-radius: 6px; padding-left: 0.5rem; margin-left: -0.5rem; }

.lo-toggle {
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.lo-item.expanded .lo-toggle { transform: rotate(180deg); }

.lo-details {
  display: none;
  padding: 0.5rem 0 1rem 0;
  margin-left: 3.5rem;
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
}

.lo-item.expanded .lo-details { display: block; }

.lo-summary {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 0.5rem 0;
}

.lo-subsection {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.lo-subsection strong {
  font-size: 0.85rem;
  color: var(--text);
}

.lo-subsection p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0.25rem 0 0 0;
  font-size: 0.85rem;
}

.lo-id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* ======================================================================
   Practice Config
   ====================================================================== */
.config-panel {
  max-width: 600px;
}

.practice-score-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.score-display {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-mono);
}

/* ======================================================================
   Loading / Spinner
   ====================================================================== */
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-secondary);
}

/* ======================================================================
   Toast Notifications
   ====================================================================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--primary); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ======================================================================
   Flag Button
   ====================================================================== */
.flag-btn {
  background: none;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.flag-btn:hover { border-color: var(--warning); color: var(--warning); }
.flag-btn.flagged { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); }

/* ======================================================================
   Exam History
   ====================================================================== */
.history-list {
  list-style: none;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history-item:last-child { border-bottom: none; }

.history-score {
  font-weight: 700;
  font-family: var(--font-mono);
}

.history-score.passed { color: var(--success); }
.history-score.failed { color: var(--error); }

/* ======================================================================
   Section headers
   ====================================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

/* ======================================================================
   Review Mode
   ====================================================================== */
.review-question {
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--border);
  padding-left: 1.25rem;
}

.review-question.correct-review { border-color: var(--success); }
.review-question.incorrect-review { border-color: var(--error); }

/* ======================================================================
   Confirm Dialog
   ====================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-box h3 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

.modal-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ======================================================================
   Empty state
   ====================================================================== */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ======================================================================
   Nav Badge (wrong questions count)
   ====================================================================== */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--error);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.35rem;
  vertical-align: middle;
}

/* ======================================================================
   Multi-answer Questions
   ====================================================================== */
.multi-answer-hint {
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: inline-block;
}

.question-card.multi-answer {
  border-left: 4px solid var(--warning);
}

.option-btn.multi-answer-option .option-letter {
  border-radius: 4px;
}

.option-btn.multi-answer-option.selected .option-letter {
  background: var(--primary);
  color: #fff;
}

/* ======================================================================
   Weak Areas Banner
   ====================================================================== */
.weak-areas-banner h3 {
  font-size: 1.05rem;
}

/* ======================================================================
   Chapter Performance Row (Muted state)
   ====================================================================== */
.chapter-perf-row.muted {
  opacity: 0.6;
}

.chapter-perf-row.muted .progress-fill {
  background: var(--border);
}

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 900px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }

  .exam-sidebar {
    position: static;
    order: -1;
  }

  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .chapter-sidebar {
    position: static;
  }
}

@media (max-width: 640px) {
  #main-nav { display: none; }
  #main-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--primary);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
  }

  .mobile-menu-btn { display: flex; }

  .header-inner { height: 56px; }

  #app-content { padding: 1rem; }

  .dashboard-hero { padding: 1.5rem; }
  .dashboard-hero h1 { font-size: 1.4rem; }

  .question-card { padding: 1.25rem; }

  .question-nav-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .results-score { font-size: 3rem; }

  .footer-shortcuts { display: none; }
}
