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

:root {
  --primary: #1a3a5c;
  --primary-light: #2a5a8c;
  --primary-dark: #0f2440;
  --accent: #f0883e;
  --accent-light: #fef3e8;
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

.btn-full {
  width: 100%;
}

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

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition);
  background: white;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.1);
}

/* Utilities */
.text-center { text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.error-msg { color: var(--error); font-size: 0.9rem; margin-top: 0.75rem; }
.warning-text { color: var(--warning); font-size: 0.9rem; margin-bottom: 0.75rem; }

/* ============ LOGIN ============ */
.login-container {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}

.logo-area {
  text-align: center;
  margin-bottom: 1.5rem;
}

.logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-size: 1.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 16px rgba(26, 58, 92, 0.3);
}

.logo-area h1 {
  font-size: 1.6rem;
  color: var(--primary-dark);
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.footer-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1rem;
}

.privacy {
  margin-top: 0.75rem;
  max-width: 420px;
  width: 100%;
  text-align: left;
  font-size: 0.82rem;
}

.privacy > summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
  list-style-position: inside;
}

.privacy > summary:hover {
  text-decoration: underline;
}

.privacy-body {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.privacy-body p {
  margin-bottom: 0.6rem;
}

.privacy-body p:last-child {
  margin-bottom: 0;
}

.privacy-body strong {
  color: var(--text);
}

/* ============ ALREADY DONE ============ */
.center-container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
}

.status-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}

.done-icon {
  background: var(--success-bg);
  color: var(--success);
}

.score-display {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.75rem 0;
}

/* ============ QUIZ ============ */
.quiz-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 2rem;
}

.quiz-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.75rem 0;
  z-index: 10;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

#progress-text {
  font-weight: 600;
  font-size: 0.9rem;
}

.section-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  white-space: nowrap;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.question-card {
  margin-top: 0.5rem;
  min-height: 280px;
}

.question-number {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  color: var(--primary-dark);
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.option-btn:hover {
  border-color: var(--primary-light);
  background: #f8fafc;
}

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

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--border);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all var(--transition);
}

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

.option-text {
  padding-top: 0.15rem;
}

/* Quiz Navigation */
.quiz-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  gap: 0.5rem;
}

.question-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 200px;
}

.q-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--transition);
  cursor: pointer;
}

.q-dot.answered { background: var(--primary); opacity: 0.5; }
.q-dot.current { background: var(--primary); opacity: 1; transform: scale(1.3); }

.submit-area {
  margin-top: 1rem;
}

/* ============ RESULTS ============ */
.results-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.score-card {
  padding: 2rem 1.5rem;
}

.big-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
}

.percentage-display {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0.25rem 0 1rem;
}

.percentage-display.high { color: var(--success); }
.percentage-display.medium { color: var(--warning); }
.percentage-display.low { color: var(--error); }

.result-bar-container {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  max-width: 300px;
  margin: 0 auto;
}

.result-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 1s ease;
}

.result-bar.high { background: var(--success); }
.result-bar.medium { background: var(--warning); }
.result-bar.low { background: var(--error); }

/* Section Scores */
.section-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.section-score-row:last-child {
  border-bottom: none;
}

.section-score-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.section-score-value {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-score-text {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 55px;
  text-align: right;
}

.section-minibar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.section-minibar-fill {
  height: 100%;
  border-radius: 3px;
}

/* Feedback */
.feedback-container {
  margin-top: 1rem;
}

.feedback-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

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

.feedback-question {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.feedback-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  margin-bottom: 0.5rem;
}

.feedback-status.correct {
  background: var(--success-bg);
  color: #15803d;
}

.feedback-status.incorrect {
  background: var(--error-bg);
  color: #b91c1c;
}

.feedback-status.skipped {
  background: var(--warning-bg);
  color: #92400e;
}

.feedback-answer {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.feedback-answer strong {
  color: var(--text);
}

/* ============ TEACHER ============ */
.teacher-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.teacher-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.teacher-header h1 {
  font-size: 1.5rem;
  color: var(--primary-dark);
}

.filter-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.filter-row .form-group {
  flex: 1;
  min-width: 180px;
  margin-bottom: 0;
}

.results-summary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.summary-stat {
  text-align: center;
}

.summary-stat .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-stat .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead th {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

tbody td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #f8fafc;
}

.score-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.85rem;
}

.score-pill.high { background: var(--success-bg); color: #15803d; }
.score-pill.medium { background: var(--warning-bg); color: #92400e; }
.score-pill.low { background: var(--error-bg); color: #b91c1c; }

/* ============ TOGGLE SWITCH ============ */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toggle-label strong {
  font-size: 0.95rem;
}

.toggle-label .muted {
  font-size: 0.82rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  min-width: 52px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  transition: 0.25s;
  border-radius: 30px;
}

.slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
  background: var(--success);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* ============ SECTIE-RESULTAAT (student) ============ */
.section-result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.section-result-row:last-child {
  border-bottom: none;
}

.section-result-icon {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
}

.section-result-icon.passed { background: var(--success); }
.section-result-icon.failed { background: var(--error); }

.section-result-body {
  flex: 1;
  min-width: 0;
}

.section-result-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.section-result-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.section-result-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.section-result-pct {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 42px;
  text-align: right;
}

.review-hint {
  background: var(--warning-bg);
  border: 1px solid #fcd9a5;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  margin-top: 1rem;
  color: #92400e;
}

.review-hint.all-passed {
  background: var(--success-bg);
  border-color: #bbf7d0;
  color: #15803d;
}

/* ============ LOADING ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .card {
    padding: 1.1rem;
    border-radius: 10px;
  }

  .logo-area h1 {
    font-size: 1.35rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .option-btn {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .quiz-navigation {
    flex-wrap: wrap;
  }

  .question-dots {
    order: 3;
    max-width: 100%;
    width: 100%;
    margin-top: 0.5rem;
  }

  .big-score {
    font-size: 2.5rem;
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-row .btn {
    width: 100%;
  }

  .results-summary {
    gap: 1rem;
  }

  table {
    font-size: 0.82rem;
  }

  thead th, tbody td {
    padding: 0.5rem 0.35rem;
  }
}

@media (min-width: 768px) {
  .quiz-container {
    padding: 1.5rem;
  }

  .question-card {
    padding: 2rem;
  }

  .login-container .card {
    padding: 2rem;
  }
}
