/* ─── VARIABLES ─────────────────────────────────────────── */
:root {
  --primary:       #15539B; /* Azul corporativo oscuro */
  --primary-light: #E8F0FE; /* Azul corporativo muy claro */
  --primary-dark:  #0F3B70; /* Azul corporativo profundo */
  --accent:        #2B81D6; /* Azul medio para acentos */
  --accent-light:  #E6F1FB;
  --danger:        #D93836;
  --danger-light:  #FBEAE9;
  --warning:       #E08E00;
  --warning-light: #FDF3E5;
  --gray-50:       #F8F9FA; /* Gris azulado muy suave */
  --gray-100:      #E0E4E8;
  --gray-400:      #8B95A5;
  --gray-600:      #5F6B7A;
  --gray-900:      #212B36; /* Texto principal oscuro */
  --white:         #ffffff;
  --radius-sm:     4px;  /* Bordes más rectos, más corporativos */
  --radius-md:     6px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(33,43,54,0.08), 0 1px 2px rgba(33,43,54,0.04);
  --shadow-md:     0 4px 12px rgba(33,43,54,0.08), 0 2px 4px rgba(33,43,54,0.04);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.6;
}

/* ─── TIPOGRAFÍA ─────────────────────────────────────────── */
h1 { font-size: 2rem;   font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.4rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--gray-600); }

/* ─── LAYOUT ─────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  width: 100%;
  max-width: 560px;
}

.card-wide {
  max-width: 720px;
}

/* ─── LOGO / CABECERA ────────────────────────────────────── */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* ─── BOTONES ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover  { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--gray-50);
  color: var(--gray-600);
  border: 1px solid var(--gray-100);
}
.btn-secondary:hover { background: var(--gray-100); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: #185FA5; }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.btn-danger:hover { background: #F7C1C1; }

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  width: auto;
}

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

/* ─── INPUTS ─────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1.25rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-600);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 83, 155, 0.15); /* Color azul transparente */
}

textarea { resize: vertical; min-height: 80px; }

/* ─── BARRA DE PROGRESO ──────────────────────────────────── */
.progress-wrap {
  margin-bottom: 2rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.progress-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}

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

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

/* ─── OPCIONES DE RESPUESTA ──────────────────────────────── */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 1.5rem 0;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

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

.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-item.correct {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
}

.option-letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-400);
  flex-shrink: 0;
  transition: all 0.15s;
}

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

.option-item.correct .option-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-item.wrong .option-letter {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.option-text {
  font-size: 0.95rem;
  color: var(--gray-900);
  flex: 1;
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green  { background: var(--primary-light); color: var(--primary-dark); }
.badge-red    { background: var(--danger-light);  color: var(--danger); }
.badge-blue   { background: var(--accent-light);  color: #0C447C; }
.badge-gray   { background: var(--gray-50);       color: var(--gray-600); }

/* ─── RESULTADO ──────────────────────────────────────────── */
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 6px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

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

.score-label {
  font-size: 0.7rem;
  color: var(--gray-400);
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.stat-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ─── TABLA ADMIN ────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-100);
}

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

th {
  background: var(--gray-50);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--gray-100);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gray-50);
  color: var(--gray-900);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td      { background: var(--gray-50); }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform 0.2s;
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--gray-900); }

/* ─── ALERTAS ────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show    { display: block; }
.alert-error   { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--primary-light); color: var(--primary-dark); }

/* ─── DIVISOR ────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gray-100);
  margin: 1.5rem 0;
}

/* ─── LOADER ─────────────────────────────────────────────── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .card     { padding: 1.5rem; }
  h1        { font-size: 1.6rem; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}