/* ==========================================================================
   Pescador Cantábrico — hoja de estilo

   Pensada para leerse en un espigón a las 6 de la mañana, con guantes:
   · Fondo oscuro y contraste alto (pantalla al sol y de noche sin deslumbrar)
   · Objetivos táctiles de 48 px mínimo (manos frías y mojadas)
   · Todo lo importante en el pulgar: navegación abajo
   ========================================================================== */

:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --card: #172033;
  --card-2: #1e293b;
  --borde: #2b3a52;
  --texto: #f1f5f9;
  --apagado: #94a3b8;
  --tenue: #64748b;

  --ocean: #38bdf8;
  --deep: #0c4a6e;
  --arena: #fbbf24;
  --verde: #22c55e;
  --amarillo: #eab308;
  --naranja: #f97316;
  --rojo: #ef4444;

  --radio: 16px;
  --radio-s: 10px;
  --sombra: 0 4px 16px rgba(0, 0, 0, .45);
  --nav-h: 68px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

body {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
a { color: var(--ocean); }

/* --- Cabecera ------------------------------------------------------------ */
.cabecera {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}
.cabecera h1 { font-size: 17px; }
.cabecera .sub { font-size: 12px; color: var(--apagado); font-weight: 500; }

.chip-btn {
  border: 1px solid var(--borde); background: var(--card);
  color: var(--texto); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  min-height: 40px; cursor: pointer;
}
.chip-btn:active { background: var(--card-2); }

/* --- Contenedor ---------------------------------------------------------- */
.vista { padding: 0 16px 24px; max-width: 720px; margin: 0 auto; }
.vista[hidden] { display: none; }

.seccion-titulo {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--apagado); font-weight: 700;
  margin: 26px 0 10px;
}
.seccion-titulo:first-child { margin-top: 6px; }

/* --- Tarjetas ------------------------------------------------------------ */
.tarjeta {
  background: var(--card); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--sombra);
}
.tarjeta.plana { box-shadow: none; }
.tarjeta h3 { font-size: 15px; margin-bottom: 8px; }

.fila { display: flex; align-items: center; gap: 12px; }
.fila.entre { justify-content: space-between; }
.crece { flex: 1; min-width: 0; }

/* --- Semáforo ------------------------------------------------------------ */
.semaforo {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--borde);
  border-radius: 20px; padding: 20px; margin-bottom: 12px;
  position: relative; overflow: hidden;
}
.semaforo::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120px 120px at 14% 50%, var(--halo), transparent 70%);
  opacity: .35; pointer-events: none;
}
.semaforo.verde { --halo: var(--verde); }
.semaforo.amarillo { --halo: var(--amarillo); }
.semaforo.rojo { --halo: var(--rojo); }

.medidor { position: relative; width: 104px; height: 104px; flex: none; }
.medidor svg { transform: rotate(-90deg); display: block; }
.medidor .valor {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.medidor .num { font-size: 30px; font-weight: 800; line-height: 1; }
.medidor .de { font-size: 10px; color: var(--apagado); margin-top: 2px; }

.semaforo .texto h2 { font-size: 19px; margin-bottom: 4px; }
.semaforo .texto p { font-size: 13px; color: var(--apagado); margin: 0; }

/* --- Ventanas de pesca --------------------------------------------------- */
.ventana {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--borde);
  border-left: 4px solid var(--verde);
  border-radius: var(--radio-s); padding: 14px; margin-bottom: 10px;
}
.ventana.secundaria { border-left-color: var(--arena); opacity: .92; }
.ventana .horario { font-size: 17px; font-weight: 800; white-space: nowrap; }
.ventana .motivo { font-size: 12px; color: var(--apagado); }
.ventana .punt {
  margin-left: auto; font-size: 20px; font-weight: 800; color: var(--verde);
}
.ventana.secundaria .punt { color: var(--arena); }

/* --- Aviso de seguridad -------------------------------------------------- */
.aviso {
  border-radius: var(--radio); padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid; font-size: 14px;
}
.aviso strong { display: block; margin-bottom: 4px; font-size: 15px; }
.aviso ul { margin: 6px 0 0; padding-left: 18px; }
.aviso li { margin-bottom: 3px; }
.aviso.verde    { border-color: #14532d; background: #052e16; color: #bbf7d0; }
.aviso.amarillo { border-color: #713f12; background: #2a1e05; color: #fde68a; }
.aviso.naranja  { border-color: #7c2d12; background: #2b1206; color: #fed7aa; }
.aviso.rojo     { border-color: #7f1d1d; background: #300a0a; color: #fecaca; }
.aviso.info     { border-color: var(--borde); background: var(--card-2); color: var(--apagado); }

/* --- Rejilla de datos ---------------------------------------------------- */
.datos {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.dato {
  background: var(--card); border: 1px solid var(--borde);
  border-radius: var(--radio-s); padding: 12px 10px; text-align: center;
}
.dato .v { font-size: 17px; font-weight: 700; color: var(--arena); }
.dato .k { font-size: 11px; color: var(--apagado); margin-top: 3px; }

/* --- Componentes del score ----------------------------------------------- */
.barra-comp { margin-bottom: 10px; }
.barra-comp .etq { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.barra-comp .etq span:last-child { color: var(--apagado); }
.barra-comp .pista { height: 7px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.barra-comp .relleno { height: 100%; background: var(--ocean); border-radius: 999px; }

/* --- Marea --------------------------------------------------------------- */
.grafico-marea { width: 100%; height: 150px; display: block; }
.marea-lista { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.marea-item {
  background: var(--card-2); border-radius: var(--radio-s); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.marea-item .ico { font-size: 20px; }
.marea-item .h { font-weight: 700; font-size: 16px; }
.marea-item .a { font-size: 11px; color: var(--apagado); }

/* --- Franja de días ------------------------------------------------------ */
.dias { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.dias::-webkit-scrollbar { display: none; }
.dia {
  flex: none; width: 78px; text-align: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--borde);
  border-radius: 14px; padding: 10px 6px;
}
.dia.activo { border-color: var(--ocean); background: #0b2e42; }
.dia .d { font-size: 11px; color: var(--apagado); text-transform: capitalize; }
.dia .s { font-size: 21px; font-weight: 800; margin: 4px 0 2px; }
.dia .c { font-size: 10px; color: var(--apagado); }
.dia .alerta { font-size: 11px; }

/* --- Formularios --------------------------------------------------------- */
label { display: block; font-size: 12px; color: var(--apagado); margin: 12px 0 5px; font-weight: 600; }
input, select, textarea, button { font-family: inherit; font-size: 16px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; min-height: 48px;
  background: var(--bg-2); color: var(--texto);
  border: 1px solid var(--borde); border-radius: var(--radio-s);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ocean); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 13px 18px;
  background: var(--ocean); color: #04222f; border: none;
  border-radius: var(--radio-s); font-weight: 700; font-size: 15px; cursor: pointer;
}
.btn:active { filter: brightness(.9); }
.btn.sec { background: var(--card-2); color: var(--texto); border: 1px solid var(--borde); }
.btn.peligro { background: var(--rojo); color: #fff; }
.btn.fino { min-height: 42px; font-size: 14px; }
.btn[disabled] { opacity: .5; }
.btn-fila { display: flex; gap: 10px; }

/* --- Selector de píldoras ------------------------------------------------ */
.pildoras { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.pildoras::-webkit-scrollbar { display: none; }
.pildora {
  flex: none; padding: 10px 16px; min-height: 42px;
  background: var(--card); border: 1px solid var(--borde);
  border-radius: 999px; color: var(--texto); font-size: 14px; cursor: pointer;
}
.pildora.activa { background: var(--deep); border-color: var(--ocean); font-weight: 700; }

/* --- Listas -------------------------------------------------------------- */
.item-lista {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--borde);
  border-radius: var(--radio-s); padding: 12px; margin-bottom: 8px;
}
.item-lista .ico { font-size: 26px; flex: none; }
.item-lista .t { font-weight: 700; font-size: 14px; }
.item-lista .s { font-size: 12px; color: var(--apagado); }

.etiquetas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.etiqueta {
  background: var(--deep); color: #dbeafe;
  border-radius: 999px; padding: 4px 10px; font-size: 11px; white-space: nowrap;
}
.etiqueta.gris { background: var(--card-2); color: var(--apagado); }
.etiqueta.roja { background: #450a0a; color: #fecaca; }
.etiqueta.verde { background: #052e16; color: #bbf7d0; }

.vacio { text-align: center; padding: 40px 20px; color: var(--apagado); }
.vacio .ico { font-size: 44px; display: block; margin-bottom: 10px; opacity: .6; }

/* --- SOS ----------------------------------------------------------------- */
.sos-flotante {
  position: fixed; right: 16px;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--rojo); color: #fff; border: none;
  font-size: 24px; cursor: pointer; z-index: 45;
  box-shadow: 0 6px 20px rgba(239, 68, 68, .45);
}

/* --- Modal --------------------------------------------------------------- */
.modal-fondo {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 6, 16, .82); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-fondo[hidden] { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--borde);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 720px;
  max-height: 92vh; overflow-y: auto;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) {
  .modal-fondo { align-items: center; }
  .modal { border-radius: 22px; }
}
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .cerrar {
  float: right; background: none; border: none; color: var(--apagado);
  font-size: 24px; cursor: pointer; padding: 0 6px; margin: -6px -6px 0 0;
}

/* --- Navegación inferior ------------------------------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(15, 23, 42, .96);
  border-top: 1px solid var(--borde);
  backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav button {
  background: none; border: none; color: var(--tenue);
  padding: 9px 2px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--nav-h);
}
.nav button .ico { font-size: 21px; line-height: 1; }
.nav button .txt { font-size: 9px; font-weight: 600; }
.nav button.activo { color: var(--ocean); }

/* --- Utilidades ---------------------------------------------------------- */
.pequeno { font-size: 12px; color: var(--apagado); }
.centro { text-align: center; }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.cargando { text-align: center; padding: 50px 20px; color: var(--apagado); }

.cinta-offline {
  background: #422006; color: #fed7aa; text-align: center;
  font-size: 12px; padding: 7px 12px;
}

@media (prefers-reduced-motion: no-preference) {
  .vista { animation: entrar .18s ease-out; }
  @keyframes entrar { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* --- Mapa: contencion de capas -------------------------------------------
   Leaflet usa z-index de 200 a 700 en sus paneles internos. Sin aislarlo,
   el mapa se pinta por encima de la cabecera y de la barra de navegacion.
   `isolation: isolate` crea un contexto de apilamiento propio: todo lo de
   Leaflet queda encerrado dentro de su tarjeta.                            */
.leaflet-container {
  isolation: isolate;
  z-index: 0;
  background: #0c2a3e;
}
#mapa-vista, #mapa-perfil {
  position: relative;
  isolation: isolate;
  z-index: 0;
  contain: paint;
}

/* La cabecera y la navegacion mandan siempre sobre el mapa */
.cabecera { z-index: 1000; }
.nav { z-index: 1000; }
.sos-flotante { z-index: 1001; }
.modal-fondo { z-index: 2000; }

/* Controles de Leaflet con el tema oscuro de la app */
.leaflet-control-attribution {
  background: rgba(11,18,32,.82) !important;
  color: #94a3b8 !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: #7dd3fc !important; }
.leaflet-bar a {
  background: #172033 !important;
  color: #f1f5f9 !important;
  border-color: #2b3a52 !important;
}
.leaflet-bar a:hover { background: #1e293b !important; }
.leaflet-control-scale-line {
  background: rgba(11,18,32,.72);
  border-color: #64748b;
  color: #cbd5e1;
}
/* Barra de progreso de la descarga del mapa. Sin ella, 900 teselas parecen
   la app colgada y el usuario la cierra a mitad.                            */
.barra { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 6px; }
.barra-relleno { height: 100%; background: var(--ocean); transition: width .2s ease; }

/* Salida en blanco: se distingue de una captura de un vistazo, sin gritar.
   Es un registro tan valioso como una captura, no un fracaso.               */
.captura.blanco { border-left: 3px solid #64748b; opacity: .88; }
.captura.blanco strong { color: #94a3b8; }

/* Lista compacta de capturas dentro de una tarjeta de patrones */
.lista-fina{margin:.4rem 0 .6rem;padding-left:1.1rem;list-style:disc}
.lista-fina li{margin:.15rem 0;line-height:1.35}

/* --- Fotos: miniaturas en el historial y foto de cabecera del spot ------- */
.miniatura{position:relative;flex:0 0 auto;width:56px;height:56px;border-radius:10px;
  overflow:hidden;background:var(--card-2)}
.miniatura img{width:100%;height:100%;object-fit:cover;display:block}
.miniatura .etiqueta-mini{position:absolute;left:0;right:0;bottom:0;font-size:.62rem;
  text-align:center;background:rgba(0,0,0,.62);color:#e2e8f0;padding:1px 0;letter-spacing:.03em}
.foto-spot{width:calc(100% + 24px);margin:-12px -12px 10px;display:block;
  max-height:190px;object-fit:cover;border-radius:12px 12px 0 0}
.tarjeta.spot{overflow:hidden}

/* --- Guía de uso --------------------------------------------------------- */
.guia-indice{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
.guia-indice .chip-btn{font-size:.8rem}
.guia-seccion h3{margin:0 0 .5rem}
.guia-seccion p{line-height:1.5}
.guia-seccion a{color:var(--ocean);text-decoration:underline}
.guia-sep{border:0;border-top:1px solid var(--borde);margin:1.1rem 0}

/* --- ¿Está removido el fondo? ------------------------------------------- */
.mf{display:flex;flex-direction:column;gap:4px}
.mf-fila{display:flex;align-items:center;gap:8px;font-size:.78rem}
.mf-d{flex:0 0 42px;text-align:right;color:var(--apagado);font-variant-numeric:tabular-nums}
.mf-b{flex:1;height:8px;border-radius:4px;background:var(--card-2);overflow:hidden;display:block}
.mf-b i{display:block;height:100%;border-radius:4px}
.mf-t{flex:0 0 108px;color:var(--tenue)}

/* --- Informar de un fallo ------------------------------------------------ */
.sg-tecnicos{background:var(--card-2);border-radius:8px;padding:8px 10px;margin:.5rem 0 0;
  font-size:.72rem;line-height:1.45;white-space:pre-wrap;word-break:break-word;
  color:var(--tenue);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
#sg-tipo .btn.activo{border-color:var(--ocean);color:var(--ocean)}
