/* ============================================================
   UNIR Tests Tutor – Design System & Styles
   ==========================================================
   Mobile-first • Dark/Light themes • CSS Variables
   ============================================================ */

/* ---------- CSS Custom Properties (Light theme default) ---------- */
:root,
[data-theme="light"] {
  /* Primary palette */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-glow: rgba(37, 99, 235, 0.15);

  /* Accent / secondary */
  --color-accent: #7c3aed;
  --color-accent-hover: #6d28d9;

  /* Semantic */
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-error: #dc2626;
  --color-error-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;

  /* Surfaces */
  --bg-body: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.82);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Borders & Shadows */
  --border-color: #e2e8f0;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 20px var(--color-primary-glow);

  /* Misc */
  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s ease;
  --max-width: 720px;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-light: #1e3a5f;
  --color-primary-glow: rgba(59, 130, 246, 0.2);

  --color-accent: #a78bfa;
  --color-accent-hover: #c4b5fd;

  --color-success: #4ade80;
  --color-success-bg: #14532d;
  --color-error: #f87171;
  --color-error-bg: #7f1d1d;
  --color-warning: #fbbf24;
  --color-warning-bg: #78350f;

  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #273548;
  --bg-input: #1e293b;
  --bg-header: rgba(15, 23, 42, 0.88);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-color: #334155;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition-normal), color var(--transition-normal);
  line-height: 1.6;
}

h1,
h2,
h3,
h4 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.25;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 1.2rem;
  color: var(--text-primary);
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 0.8rem;
  color: var(--text-primary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

/* ============================================================
   Header & Navigation
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-normal);
}

.header-brand {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.brand-icon {
  font-size: 1.4rem;
}

.app-header h1 {
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  background: transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.nav-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

#theme-toggle,
.theme-toggle-btn {
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

#theme-toggle:hover,
.theme-toggle-btn:hover {
  border-color: var(--color-primary);
  transform: rotate(20deg) scale(1.08);
}


/* ============================================================
   Main / Views
   ============================================================ */
#app-root {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.view {
  animation: fadeSlideIn 0.35s ease both;
}

.view.hidden {
  display: none !important;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

/* ============================================================
   Forms – General
   ============================================================ */
#config-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#config-form>label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

select,
input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

select:focus,
input[type="number"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
}

/* ---------- Fieldset ---------- */
fieldset {
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.85rem 1rem;
}

fieldset legend {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-secondary);
  padding: 0 0.4rem;
}

/* ---------- Radio & Checkbox wrappers ---------- */
.radio-wrapper,
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0;
  cursor: pointer;
}

.radio-wrapper label,
.checkbox-wrapper label {
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-primary);
  user-select: none;
}

/* Custom radio & checkbox styling */
input[type="radio"],
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Checkbox group (temas) ---------- */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  max-height: 220px;
  overflow-y: auto;
}

.checkbox-group::-webkit-scrollbar {
  width: 6px;
}

.checkbox-group::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

/* ============================================================
   Buttons
   ============================================================ */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
}

.primary-btn,
#config-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-sm);
  margin-top: 0.5rem;
}

.primary-btn:hover,
#config-form button[type="submit"]:hover {
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transform: translateY(-1px);
}

.primary-btn:active,
#config-form button[type="submit"]:active {
  transform: translateY(0);
}

.primary-btn:disabled,
#config-form button[type="submit"]:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary / action buttons */
.actions button,
.view>button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  border-radius: var(--border-radius-sm);
  margin-top: 0.75rem;
}

.actions button:hover,
.view>button:hover {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

/* ============================================================
   Quiz View
   ============================================================ */
.quiz-progress {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

/* Badge (tipo de pregunta) */
.badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  margin-bottom: 0.85rem;
}

.badge.tipo-verdadero_falso {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge.tipo-seleccion_unica {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge.tipo-seleccion_multiple {
  background: #ede9fe;
  color: var(--color-accent);
}

[data-theme="dark"] .badge.tipo-seleccion_multiple {
  background: #2e1065;
}

/* ---------- Question form ---------- */
#question-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.option-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.option-wrapper:hover {
  border-color: var(--color-primary);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-sm);
}

.option-wrapper:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.option-wrapper label {
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-primary);
  flex: 1;
}

.option-wrapper input {
  margin-top: 0.15rem;
}

#question-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--border-radius-sm);
  margin-top: 0.85rem;
  box-shadow: var(--shadow-sm);
}

#question-form button[type="submit"]:hover:not(:disabled) {
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transform: translateY(-1px);
}

/* ---------- Feedback ---------- */
.feedback {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 1rem;
  margin-top: 1rem;
  animation: fadeSlideIn 0.25s ease both;
}

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

.feedback.wrong {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
}

/* ---------- Explanation (details/summary) ---------- */
details {
  margin-top: 0.75rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

details summary {
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--color-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  list-style: none;
}

details summary::before {
  content: "▸ ";
}

details[open] summary::before {
  content: "▾ ";
}

details summary:hover {
  background: var(--bg-card-hover);
}

details p {
  padding: 0 0.9rem 0.75rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* "Siguiente" button inside quiz */
#view-quiz button:not([type="submit"]) {
  margin-top: 0.85rem;
}

/* ============================================================
   Results View
   ============================================================ */
.result-summary {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.result-summary p {
  padding: 0.3rem 0;
  font-size: 0.95rem;
}

.result-summary strong {
  color: var(--text-secondary);
}

/* Detail list */
.detalle-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  counter-reset: detalle;
}

.detalle-list li {
  padding: 0.6rem 0.85rem;
  border-radius: var(--border-radius-xs);
  font-size: 0.88rem;
  counter-increment: detalle;
}

.detalle-list li.correcta {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.detalle-list li.incorrecta {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* ============================================================
   Stats View
   ============================================================ */
.stats-aggregates {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stats-aggregates p {
  padding: 0.25rem 0;
  font-size: 0.92rem;
}

.stats-aggregates strong {
  color: var(--text-secondary);
}

/* Difficult questions */
.difficult-questions {
  margin-bottom: 1.5rem;
}

.difficult-questions h3 {
  color: var(--color-error);
}

.difficult-questions ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.difficult-questions li {
  padding: 0.5rem 0.85rem;
  background: var(--color-error-bg);
  color: var(--color-error);
  border-radius: var(--border-radius-xs);
  font-size: 0.85rem;
}

/* History table */
.history-list {
  margin-bottom: 1.25rem;
}

.history-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.history-table th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-table td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-primary);
}

.history-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ============================================================
   Fase 5 – Polish & Advanced UX Components
   ============================================================ */

/* ---------- Temas Quick Actions & Counter ---------- */
.temas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  margin-bottom: 0.15rem;
}

.temas-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.temas-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-text-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-text-action:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.temas-counter {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  padding: 0.45rem 0.75rem;
  border-radius: var(--border-radius-xs);
  margin-top: 0.2rem;
}

.theme-pregs-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

.radio-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-top: 0.1rem;
}

.filter-count-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
}

/* ---------- Progress Bar ---------- */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------- Quiz Meta Bar & Star Button ---------- */
.quiz-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.quiz-meta-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-star {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-star:hover {
  border-color: #f59e0b;
  color: #b45309;
  background: #fef3c7;
}

.btn-star.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}

[data-theme="dark"] .btn-star.active {
  background: #78350f;
  color: #fde68a;
  border-color: #f59e0b;
}

.star-icon {
  font-size: 1rem;
  color: #f59e0b;
}

.quiz-tema-tag {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.quiz-question-title {
  font-size: 1.2rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.notice-multiple {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
  background: rgba(124, 58, 237, 0.08);
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0.8rem;
  border-radius: 0 var(--border-radius-xs) var(--border-radius-xs) 0;
  margin-bottom: 0.85rem;
}

/* ---------- Keyboard Hints & Option Enhancements ---------- */
.opt-key-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: normal;
  float: right;
  opacity: 0.7;
}

.key-hint {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: normal;
  margin-left: 0.35rem;
}

.keyboard-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius-sm);
}

.keyboard-hints kbd {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-primary);
}

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

.option-wrapper.option-wrong {
  border-color: var(--color-error) !important;
  background: var(--color-error-bg) !important;
}

/* ---------- Results Screen Enhanced ---------- */
.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.result-score-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  border: 4px solid var(--border-color);
}

.result-score-circle.pass {
  border-color: var(--color-success);
  background: var(--color-success-bg);
  color: var(--color-success);
}

.result-score-circle.fail {
  border-color: var(--color-error);
  background: var(--color-error-bg);
  color: var(--color-error);
}

.score-number {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.result-badge-banner {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.badge-exam-excellent {
  background: #fef3c7;
  color: #b45309;
  border: 1.5px solid #f59e0b;
}

.badge-exam-pass {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1.5px solid var(--color-success);
}

.badge-exam-warning {
  background: #fef3c7;
  color: #d97706;
  border: 1.5px solid #d97706;
}

.badge-exam-fail {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
}

.result-meta-grid {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---------- Review Header & Filter Tabs ---------- */
.review-header-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .review-header-box {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.review-filter-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-card);
  padding: 0.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: var(--border-radius-xs);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--color-primary);
}

.tab-btn.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---------- Review Question Cards ---------- */
.review-item {
  padding: 1.15rem 1.25rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

.review-item.correct {
  border-left: 5px solid var(--color-success);
}

.review-item.wrong {
  border-left: 5px solid var(--color-error);
}

.review-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.review-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.review-status {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.status-pass {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-fail {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.review-tema {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-star-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-star-mini:hover,
.btn-star-mini.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}

[data-theme="dark"] .btn-star-mini:hover,
[data-theme="dark"] .btn-star-mini.active {
  background: #78350f;
  color: #fde68a;
}

.review-question-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
}

.q-num {
  color: var(--color-primary);
  font-weight: 700;
  margin-right: 0.35rem;
}

/* ---------- Answers Box & Comparison ---------- */
.review-answers-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.review-answer-block {
  padding: 0.65rem 0.85rem;
  border-radius: var(--border-radius-xs);
  font-size: 0.9rem;
  line-height: 1.45;
}

.answer-badge-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.user-answer.is-correct {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-left: 3px solid var(--color-success);
}

.user-answer.is-wrong {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-left: 3px solid var(--color-error);
}

.correct-answer {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-left: 3px solid var(--color-primary);
}

.answer-text strong {
  color: inherit;
}

/* ---------- Explanation / Justification Box ---------- */
.review-explanation {
  background: var(--bg-body);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  padding: 0.65rem 0.85rem;
  margin-top: 0.65rem;
}

.review-explanation summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary);
  user-select: none;
  outline: none;
}

.review-explanation summary:hover {
  text-decoration: underline;
}

.exp-hint {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--color-error);
  margin-left: 0.35rem;
}

.explanation-content {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}


.btn-retry-errors {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #ea580c;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-retry-errors:hover {
  background: #c2410c;
  transform: translateY(-1px);
}

/* ---------- Stats Screen Enhanced ---------- */
.stats-aggregates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .stats-aggregates-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem 0.75rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
}

.dificiles-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  border-radius: var(--border-radius-sm);
  color: #92400e;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .dificiles-box {
  background: #78350f;
  color: #fef3c7;
  border-color: #f59e0b;
}

.btn-sm {
  padding: 0.45rem 0.85rem !important;
  font-size: 0.85rem !important;
  width: auto !important;
  margin: 0 !important;
}

.difficult-questions-card {
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.25rem;
}

.difficult-list {
  list-style: none;
  margin-top: 0.65rem;
}

.difficult-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.difficult-list li:last-child {
  border-bottom: none;
}

.rate-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-error);
  background: var(--color-error-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.table-score-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
}

.table-score-badge.pass {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.table-score-badge.fail {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.data-management-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-error);
  background: var(--color-error-bg);
  border: 1.5px solid var(--color-error);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

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

.toast {
  padding: 0.75rem 1.15rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  color: #fff;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-info {
  background: #334155;
}

.toast-success {
  background: #15803d;
}

.toast-warning {
  background: #b45309;
}

.toast-danger {
  background: #b91c1c;
}

/* ============================================================
   Responsive – Tablet & Desktop
   ============================================================ */

@media (min-width: 640px) {
  #app-root {
    padding: 2rem 1.5rem 4rem;
  }

  h2 {
    font-size: 1.85rem;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }

  .actions {
    flex-direction: row;
  }

  .actions button,
  .view>button {
    width: auto;
  }
}

@media (min-width: 1024px) {
  :root {
    --max-width: 780px;
  }

  #app-root {
    padding: 2.5rem 2rem 5rem;
  }
}

/* ============================================================
   Utility: smooth scrollbar (WebKit)
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================================
   Print (optional – hide controls)
   ============================================================ */
@media print {

  .app-header,
  .app-footer,
  .actions,
  #theme-toggle,
  button {
    display: none !important;
  }
}