/* =====================================================================
   SIMULADOR BUP — CAPACITACIÓN ELECTORAL · DG REFORMA POLÍTICA Y ELECTORAL
   ===================================================================== */

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

html {
  font-family: system-ui, -apple-system, 'Roboto', Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: #f0ebe0;
  color: #1a1a1a;
  min-height: 100dvh;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* --- Pantallas --- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

/* =====================================================================
   PANTALLA 1: INICIO
   ===================================================================== */

#screen-inicio {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
  gap: 2rem;
  background: #f0ebe0;
}

.inicio-cabecera {
  display: flex;
  justify-content: center;
}

.logo-ba {
  width: min(180px, 45vw);
  height: auto;
}

.inicio-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 520px;
}

#screen-inicio h1 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  color: #1a1a1a;
}

.subtitulo {
  font-size: 0.8em;
  font-weight: 600;
  color: #444;
}

.instrucciones {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: #444;
  line-height: 1.6;
}

/* =====================================================================
   BOTONES
   ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 44px;
  transition: filter 0.15s, transform 0.1s;
  white-space: nowrap;
}

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

.btn:focus-visible {
  outline: 3px solid #0057b7;
  outline-offset: 3px;
}

.btn-amarillo {
  background: #FFDD00;
  color: #1a1a1a;
}

.btn-amarillo:hover {
  filter: brightness(0.93);
}

.btn-gris {
  background: #e0dbd2;
  color: #333;
  border: 1.5px solid #b5b0a8;
}

.btn-gris:hover {
  filter: brightness(0.95);
}

.btn-gris:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-grande {
  font-size: 1.15rem;
  padding: 0.9rem 2.5rem;
  min-width: 200px;
}

.btn-emitir {
  background: #FFDD00;
  color: #1a1a1a;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.9rem 2rem;
  width: 100%;
  max-width: 420px;
  min-height: 52px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.btn-emitir:hover {
  filter: brightness(0.93);
}

/* =====================================================================
   PANTALLA 2: BOLETA — estructura general
   ===================================================================== */

/* La boleta ocupa exactamente el viewport y no genera scroll externo */
#screen-boleta {
  height: 100dvh;
  min-height: unset;
  overflow: hidden;
}

/* Cabecera de la boleta (logo + aviso) */
.boleta-cabecera {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border-bottom: 2px solid #c0bbb0;
  flex-shrink: 0;
}

.logo-ba-mini {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.aviso-boleta {
  font-size: clamp(0.55rem, 1.2vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #333;
  text-transform: uppercase;
}

/* Pie de la boleta (botón emitir) */
.boleta-pie {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 0.6rem 1rem;
  background: #fff;
  border-top: 2px solid #c0bbb0;
}

/* =====================================================================
   VISTA DESKTOP: grilla completa (≥ 1024px)
   ===================================================================== */

.boleta-desktop {
  flex: 1;
  min-height: 0;
  display: grid;
  /* col 0: etiquetas de categoría + cols 1-10: listas */
  grid-template-columns: 2.8rem repeat(10, 1fr);
  /* fila 0: encabezado de agrupación + filas 1-3: categorías */
  grid-template-rows: auto repeat(3, 1fr);
  border-left: 1px solid #b5b0a8;
  border-top: 1px solid #b5b0a8;
}

@media (max-width: 1023px) {
  .boleta-desktop {
    display: none;
  }
}

/* Celda esquina (0,0): vacía */
.celda-esquina {
  background: #e0dbd2;
  border-right: 1px solid #b5b0a8;
  border-bottom: 1px solid #b5b0a8;
}

/* Etiqueta de categoría (primera columna, filas 1-3) */
.etiqueta-cat {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e3d8;
  border-right: 2px solid #a09890;
  border-bottom: 1px solid #b5b0a8;
  padding: 0.25rem;
  overflow: hidden;
}

.etiqueta-cat span {
  writing-mode: vertical-lr;
  font-size: clamp(0.45rem, 0.85vw, 0.72rem);
  font-weight: 700;
  color: #333;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

/* Encabezado de lista (fila 0, cols 1-10) */
.lista-cabecera {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.4vh, 6px);
  padding: clamp(3px, 0.6vh, 8px) clamp(2px, 0.3vw, 6px);
  border-right: 1px solid rgba(0,0,0,0.2);
  border-bottom: 2px solid rgba(0,0,0,0.25);
  overflow: hidden;
}

.lista-escudo {
  width: clamp(20px, 3vw, 46px);
  height: clamp(20px, 3vw, 46px);
  flex-shrink: 0;
}

.lista-pais {
  font-size: clamp(0.45rem, 0.9vw, 0.72rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
}

.lista-numero {
  font-size: clamp(0.8rem, 2.2vw, 1.8rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  line-height: 1;
}

.lista-codigo {
  font-size: clamp(0.38rem, 0.65vw, 0.58rem);
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  letter-spacing: 0.06em;
}

/* Celda de candidato */
.celda-candidato {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(3px, 0.5vh, 8px) clamp(2px, 0.3vw, 6px);
  border-right: 1px solid #c0bbb0;
  border-bottom: 1px solid #c0bbb0;
  cursor: pointer;
  background: #faf8f4;
  transition: background 0.12s;
  overflow: hidden;
  gap: clamp(2px, 0.4vh, 5px);
  position: relative;
}

.celda-candidato:hover {
  background: #fffbe6;
}

.celda-candidato:focus-visible {
  outline: 3px solid #0057b7;
  outline-offset: -3px;
  z-index: 1;
}

.celda-candidato.seleccionada {
  background: #fffbd0;
  border-color: #888;
}

/* Celda NO PRESENTA */
.celda-no-presenta {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d8d4cc;
  border-right: 1px solid #c0bbb0;
  border-bottom: 1px solid #c0bbb0;
  cursor: default;
  padding: 0.3rem;
  overflow: hidden;
}

.no-presenta-texto {
  font-size: clamp(0.38rem, 0.7vw, 0.6rem);
  color: #666;
  font-style: italic;
  text-align: center;
  line-height: 1.3;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Casillero (checkbox cuadrado con X) */
.casillero {
  width: clamp(12px, 1.8vw, 20px);
  height: clamp(12px, 1.8vw, 20px);
  border: 2px solid #444;
  border-radius: 3px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: clamp(9px, 1.4vw, 15px);
  font-weight: 900;
  color: #111;
  line-height: 1;
}

.marca-x {
  display: none;
}

.seleccionada .marca-x {
  display: block;
}

/* Foto del candidato */
.foto-candidato {
  width: clamp(24px, 3.8vw, 56px);
  height: clamp(24px, 3.8vw, 56px);
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Placeholder foto (Cabo Verde) */
.foto-placeholder {
  width: clamp(24px, 3.8vw, 56px);
  height: clamp(24px, 3.8vw, 56px);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.foto-placeholder svg {
  width: 72%;
  height: 72%;
}

/* Nombres de candidatos (desktop) */
.candidato-nombres {
  font-size: clamp(0.4rem, 0.85vw, 0.68rem);
  line-height: 1.25;
  text-align: center;
  color: #222;
  width: 100%;
  overflow: hidden;
}

.nombre-titular {
  font-weight: 700;
  display: block;
}

.nombre-vice,
.nombre-extra {
  color: #555;
  display: block;
}

/* =====================================================================
   VISTA MOBILE: wizard por categoría (< 1024px)
   ===================================================================== */

.boleta-mobile {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* scroll ocurre solo dentro de wizard-contenido */
}

@media (min-width: 1024px) {
  .boleta-mobile {
    display: none;
  }
}

/* Contenido scrollable del wizard */
.wizard-contenido {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.25rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Indicador de progreso */
.wizard-progreso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.progreso-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
  transition: background 0.2s;
}

.progreso-dot.activo {
  background: #FFDD00;
  border: 2px solid #888;
  width: 12px;
  height: 12px;
}

.progreso-dot.completado {
  background: #888;
}

.progreso-label {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
}

/* Título del paso */
.wizard-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: #222;
  padding: 0.25rem 0;
}

/* Cards de listas */
.wizard-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.wizard-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 2px solid #ccc;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  background: #faf8f4;
  cursor: pointer;
  min-height: 64px;
  transition: border-color 0.12s, background 0.12s;
  text-align: left;
}

.wizard-card:hover {
  border-color: #999;
  background: #fffbe6;
}

.wizard-card:focus-visible {
  outline: 3px solid #0057b7;
}

.wizard-card.seleccionada {
  border-color: #555;
  background: #fffbd0;
}

.wizard-card.no-presenta {
  background: #e0dbd2;
  cursor: default;
  border-color: #ccc;
}

.wizard-card.no-presenta:hover {
  background: #e0dbd2;
  border-color: #ccc;
}

/* Casillero en wizard (más grande para táctil) */
.wizard-card .casillero {
  width: 28px;
  height: 28px;
  font-size: 18px;
  flex-shrink: 0;
}

.wizard-escudo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.wizard-card-info {
  flex: 1;
  min-width: 0;
}

.wizard-card-numero {
  font-size: 1.3rem;
  font-weight: 900;
  color: #1a1a1a;
  line-height: 1;
}

.wizard-card-pais {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.1rem;
}

.wizard-card-candidatos {
  font-size: 0.78rem;
  color: #333;
  margin-top: 0.25rem;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wizard-card-sin-candidatos {
  font-size: 0.78rem;
  color: #999;
  font-style: italic;
  margin-top: 0.25rem;
}

/* Navegación del wizard — fija al pie del área mobile */
.wizard-navegacion {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  flex-shrink: 0;
  border-top: 1px solid #d0cbc2;
  background: #f0ebe0;
}

.wizard-navegacion .btn {
  flex: 1;
}

/* =====================================================================
   PANTALLA 3: DETALLE DEL VOTO
   ===================================================================== */

#screen-detalle {
  background: #f0ebe0;
}

.pantalla-cabecera {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 2px solid #c0bbb0;
  flex-shrink: 0;
}

.pantalla-cabecera h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a1a;
}

.detalle-contenido {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.detalle-item {
  background: #fff;
  border: 1px solid #c8c3ba;
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.detalle-item-cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #777;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.detalle-item-voto {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.detalle-escudo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.detalle-lista-titulo {
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a1a;
}

.detalle-candidatos {
  font-size: 0.82rem;
  color: #555;
  margin-top: 0.2rem;
  line-height: 1.4;
}

.detalle-en-blanco {
  color: #999;
  font-weight: 700;
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.detalle-acciones {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border-top: 1px solid #c8c3ba;
  background: #fff;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.detalle-acciones .btn {
  width: 100%;
}

/* =====================================================================
   PANTALLA 4: VOTO EMITIDO
   ===================================================================== */

#screen-confirmacion {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
  gap: 1.5rem;
  background: #f0ebe0;
}

.confirmacion-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 480px;
  width: 100%;
}

.confirmacion-icono {
  font-size: 4.5rem;
  line-height: 1;
}

.confirmacion-titulo {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 800;
  color: #1a1a1a;
}

.confirmacion-resumen {
  background: #fff;
  border: 1px solid #c8c3ba;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  text-align: left;
  width: 100%;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #333;
}

.confirmacion-pie {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.kiosk-contador {
  font-size: 0.82rem;
  color: #888;
  min-height: 1.4em;
}

/* =====================================================================
   UTILIDADES
   ===================================================================== */

/* Accesibilidad: visible solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
