/* Minuto 90 — estilos generales */

:root {
  --verde: #2E7D32;
  --verde-oscuro: #1B5E20;
  --verde-claro: #E3F0E4;
  --papel: #FAF7F0;
  --tinta: #1C202C;
  --gris: #6B7280;
  --borde: #E2E0DA;
  --blanco: #FFFFFF;
  --rojo: #C62828;
  --amarillo: #F9A825;
  --sombra: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --radio: 14px;
  --barra: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--papel);
  color: var(--tinta);
  font-size: 16px;
  line-height: 1.45;
}

/* ---------------------------------------------------------- estructura */

#app { display: flex; flex-direction: column; height: 100%; }

header.barra {
  background: var(--verde);
  color: var(--blanco);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

header.barra h1 { font-size: 1.15rem; margin: 0; font-weight: 600; flex: 1; }

header.barra .accion {
  background: rgba(255, 255, 255, .15);
  border: 0;
  color: var(--blanco);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: .9rem;
  cursor: pointer;
}

#vista {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(96px + env(safe-area-inset-bottom));
}

nav.pestanas {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--blanco);
  border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

nav.pestanas button {
  flex: 1;
  background: none;
  border: 0;
  padding: 8px 2px 10px;
  color: var(--gris);
  font-size: .68rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
}

nav.pestanas button svg { width: 24px; height: 24px; fill: currentColor; }
nav.pestanas button.activa { color: var(--verde); font-weight: 600; }

/* ------------------------------------------------------------ tarjetas */

.tarjeta {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--sombra);
}

.fila {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--sombra);
}

.fila:active { background: #F5F3EE; }

.insignia {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--verde);
  color: var(--blanco);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.insignia.g { background: var(--verde); }
.insignia.e { background: var(--gris); }
.insignia.p { background: var(--rojo); }

.fila .cuerpo { flex: 1; min-width: 0; }
.fila .titulo { font-weight: 600; }
.fila .sub { font-size: .82rem; color: var(--gris); }

.cabecera-grupo {
  font-size: .78rem;
  font-weight: 700;
  color: var(--verde);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 16px 2px 6px;
}

.vacio {
  text-align: center;
  color: var(--gris);
  padding: 48px 24px;
  line-height: 1.6;
}

/* ------------------------------------------------------------- botones */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--verde);
  color: var(--blanco);
  border: 0;
  border-radius: 11px;
  padding: 13px 18px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
}

.boton.secundario { background: var(--blanco); color: var(--verde); border: 1.5px solid var(--verde); }
.boton.plano { background: none; color: var(--verde); font-weight: 500; }
.boton.peligro { background: none; color: var(--rojo); border: 1.5px solid var(--rojo); }
.boton:disabled { opacity: .5; cursor: default; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--barra) + 16px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--verde);
  color: var(--blanco);
  border: 0;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
  cursor: pointer;
  z-index: 15;
}

/* ----------------------------------------------------------- formulario */

label.campo { display: block; margin-bottom: 12px; }
label.campo span { display: block; font-size: .8rem; color: var(--gris); margin-bottom: 4px; }

input, select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--borde);
  border-radius: 11px;
  font-size: 16px; /* 16px evita que el iPhone haga zoom al escribir */
  font-family: inherit;
  background: var(--blanco);
  color: var(--tinta);
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); border-color: var(--verde); }
textarea { min-height: 110px; resize: vertical; }

.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seccion {
  font-size: .78rem;
  font-weight: 700;
  color: var(--verde);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 22px 2px 8px;
}

.ayuda { font-size: .82rem; color: var(--gris); margin: -4px 2px 10px; }

/* --------------------------------------------------------------- chips */

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--borde);
  background: var(--blanco);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .85rem;
  font-family: inherit;
  color: var(--tinta);
  cursor: pointer;
}

.chip.activo { background: var(--verde); color: var(--blanco); border-color: var(--verde); }

/* ------------------------------------------------------------- diálogo */

dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  background: var(--papel);
  color: var(--tinta);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}

dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .contenido { padding: 20px; max-height: 80vh; overflow-y: auto; }
dialog h2 { margin: 0 0 12px; font-size: 1.15rem; }

.lista-opciones button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--borde);
  padding: 14px 4px;
  font-size: 1rem;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.lista-opciones button:last-child { border-bottom: 0; }

/* -------------------------------------------------------------- varios */

.estadisticas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.dato {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.dato .valor { font-size: 1.4rem; font-weight: 700; color: var(--verde); }
.dato .etiqueta { font-size: .72rem; color: var(--gris); }

.casilla { display: flex; align-items: center; gap: 11px; padding: 9px 2px; }
.casilla input { width: 22px; height: 22px; flex: none; }
.casilla label { flex: 1; }

.mitad {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  border-radius: 18px;
  border: 1px solid var(--borde);
  background: var(--blanco);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  padding: 20px;
}

.mitad.destacada { background: var(--verde-claro); border-color: var(--verde-claro); }
.mitad svg { width: 48px; height: 48px; fill: var(--verde); }
.mitad .nombre { font-size: 1.2rem; font-weight: 600; }
.mitad .detalle { font-size: .85rem; color: var(--gris); }

.imagen-ejercicio {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--borde);
  display: block;
  margin-bottom: 8px;
}

.aviso {
  background: var(--verde-claro);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .88rem;
  margin-bottom: 12px;
}

#mensaje {
  position: fixed;
  left: 50%;
  bottom: calc(var(--barra) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  background: var(--tinta);
  color: var(--blanco);
  padding: 11px 18px;
  border-radius: 11px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#mensaje.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------- pizarra */

dialog.pizarra {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  background: var(--papel);
}

dialog.pizarra::backdrop { background: var(--papel); }

/* -------------------------------------------------------------- cuenta */

dialog.cuenta {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  background: var(--papel);
  padding: 0;
}

dialog.cuenta::backdrop { background: var(--papel); }

.contenido-cuenta {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px);
}

.logo-cuenta { width: 100%; max-height: 190px; object-fit: contain; display: block; }

/* --------------------------------------------------------- comentarios */

.comentarios { margin-bottom: 10px; }

.comentario {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 7px;
}

.comentario.mio { background: var(--verde-claro); border-color: var(--verde-claro); }
.comentario .quien { font-size: .75rem; color: var(--gris); margin-bottom: 2px; }

/* La casilla de aceptar condiciones, y su parpadeo si se intenta saltar. */
.casilla-legal {
  margin: 10px 2px 4px;
  align-items: flex-start;
  gap: 10px;
  font-size: .85rem;
  line-height: 1.45;
}
.casilla-legal input { margin-top: 3px; flex: none; }
.casilla-legal a { color: var(--verde); }
.casilla-legal.pendiente {
  outline: 2px solid var(--peligro, #c62828);
  outline-offset: 4px;
  border-radius: 6px;
}
