/* ═══════════════════════════════════════════════════════════════════════════
   estilos.css — Tokens de color, fuentes y clases de componente
   (arquitectura de fintrack-pro, identidad de la Alcaldía de San Salvador Sur)
   ═══════════════════════════════════════════════════════════════════════════

   LOS COLORES SON VARIABLES, NO VALORES FIJOS
   Cada token guarda los canales RGB sueltos ("0 27 160") porque así Tailwind
   puede aplicar opacidad: bg-marca-600/20 → rgb(var(--marca-600) / .2).
   tailwind-config.js mapea cada nombre a su variable.

   EL AZUL INSTITUCIONAL ES marca-600
   #001ba0 es el color oficial. Está en el paso 600 porque ese es el de los
   botones primarios (texto blanco encima: 12.6:1). En modo oscuro el 600 se
   aclara a #3254fb: el #001ba0 sobre una superficie casi negra no se vería.

   MODO OSCURO SIN VARIANTES dark:
   html.dark redefine las mismas variables. Las vistas escriben bg-superficie o
   text-texto-2 y funcionan en los dos modos sin una sola clase dark:.

   Este archivo se carga ANTES de Tailwind: las utilidades se declaran después
   y ganan sobre estas clases base (p. ej. pl-11 sobre el padding de .campo).
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Inter';
  src: url('../vendor/fuentes/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Outfit';
  src: url('../vendor/fuentes/outfit.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --fondo: 238 241 247;
  --superficie: 255 255 255;
  --superficie-2: 245 246 252;
  --superficie-3: 228 231 236;
  --borde: 208 213 221;
  --borde-suave: 228 231 236;
  --texto: 16 24 40;
  --texto-2: 71 84 103;
  --texto-3: 102 112 133;

  /* Rampa institucional (control-insumos-sssur, temas.js), desplazada para que
     el 600 sea #001ba0. Los reemplaza el <style id="ag-apariencia"> que
     calcula js/config/temas.js. */
  --marca-50: 236 239 251;
  --marca-100: 211 218 250;
  --marca-200: 171 184 250;
  --marca-300: 115 138 249;
  --marca-400: 50 84 251;
  --marca-500: 0 40 240;
  --marca-600: 0 27 160;
  --marca-700: 0 21 125;
  --marca-800: 0 15 92;
  --marca-900: 0 9 51;
  --marca-tinte: 236 239 251;
  --marca-tinte-texto: 0 27 160;

  --exito: 22 163 74;
  --exito-tinte: 220 252 231;
  --exito-texto: 21 128 61;
  --peligro: 220 38 38;
  --peligro-tinte: 254 226 226;
  --peligro-texto: 185 28 28;
  --alerta: 217 119 6;
  --alerta-tinte: 254 243 199;
  --alerta-texto: 180 83 9;
  /* Celeste #0ba5ec y no azul: los DELEGADOS no deben confundirse con la marca. */
  --info: 11 165 236;
  --info-tinte: 224 242 254;
  --info-texto: 2 106 162;

  /* Armazón por defecto: «Cabecera de marca» en azul institucional. */
  --cabecera: 0 27 160;
  --cabecera-2: 0 21 125;
  --cabecera-borde: 0 21 125;
  --cabecera-texto: 255 255 255;
  --cabecera-texto-2: 211 218 250;
  --cabecera-texto-3: 171 184 250;
  --cabecera-activo: 41 61 173;
  --cabecera-activo-texto: 255 255 255;
  --cabecera-boton: 255 255 255;
  --cabecera-boton-texto: 0 27 160;
  --lateral: 252 252 253;
  --lateral-2: 242 244 247;
  --lateral-borde: 228 231 236;
  --lateral-texto: 16 24 40;
  --lateral-texto-2: 71 84 103;
  --lateral-texto-3: 102 112 133;
  --lateral-activo: 236 239 251;
  --lateral-activo-texto: 0 27 160;
  --lateral-boton: 0 27 160;
  --lateral-boton-texto: 255 255 255;

  --sombra-sm: 0 1px 3px 0 rgb(16 24 40 / 0.08), 0 1px 2px 0 rgb(16 24 40 / 0.05);
  --sombra-md: 0 4px 10px -2px rgb(16 24 40 / 0.10), 0 2px 4px -2px rgb(16 24 40 / 0.06);
  --sombra-xl: 0 20px 24px -4px rgb(16 24 40 / 0.10), 0 8px 8px -4px rgb(16 24 40 / 0.04);

  /* Series de gráficas: orden fijo validado para daltonismo (de fintrack-pro).
     No reordenar: el orden ES la garantía de separación entre vecinos. */
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --serie-4: #eda100;
  --serie-5: #e87ba4;
  --serie-6: #008300;
  --serie-7: #4a3aa7;
  --serie-8: #e34948;
  --serie-neutra: #98a2b3;
}

html.dark {
  color-scheme: dark;
  --fondo: 12 17 29;
  --superficie: 26 34 49;
  --superficie-2: 29 41 57;
  --superficie-3: 52 64 84;
  --borde: 58 69 90;
  --borde-suave: 38 47 64;
  --texto: 249 250 251;
  --texto-2: 176 186 204;
  --texto-3: 138 150 172;

  --marca-400: 143 162 250;
  --marca-500: 92 120 250;
  --marca-600: 50 84 251;
  --marca-700: 0 40 240;
  --marca-tinte: 22 34 88;
  --marca-tinte-texto: 171 184 250;

  --exito-tinte: 18 52 36;
  --exito-texto: 74 222 128;
  --peligro-tinte: 69 22 28;
  --peligro-texto: 252 129 129;
  --alerta-tinte: 66 42 10;
  --alerta-texto: 251 191 36;
  --info-tinte: 12 46 70;
  --info-texto: 56 189 248;

  --lateral: 26 34 49;
  --lateral-2: 29 41 57;
  --lateral-borde: 38 47 64;
  --lateral-texto: 249 250 251;
  --lateral-texto-2: 176 186 204;
  --lateral-texto-3: 138 150 172;
  --lateral-activo: 30 44 110;
  --lateral-activo-texto: 171 184 250;
  --lateral-boton: 50 84 251;
  --lateral-boton-texto: 255 255 255;

  --sombra-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --sombra-md: 0 4px 12px -2px rgb(0 0 0 / 0.5);
  --sombra-xl: 0 20px 30px -6px rgb(0 0 0 / 0.6);

  --serie-1: #3987e5;
  --serie-2: #d95926;
  --serie-3: #199e70;
  --serie-4: #c98500;
  --serie-5: #d55181;
  --serie-6: #008300;
  --serie-7: #9085e9;
  --serie-8: #e66767;
  --serie-neutra: #6b7689;
}

html { -webkit-text-size-adjust: 100%; }
/* Con el armazón montado, solo <main> desplaza (Armazon.js pone la clase). Si el documento
   también pudiera desplazarse, se verían dos barras y la de afuera movería la barra lateral y
   la superior. Las pantallas de acceso e instalación no la llevan: siguen desplazándose normal. */
html.con-armazon, html.con-armazon body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  background: rgb(var(--fondo));
  color: rgb(var(--texto));
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

[v-cloak] { display: none !important; }

/* Un hijo de grid no se encoge por debajo de su contenido (min-width: auto): un
   <input type="date"> o un texto largo empujaba la columna fuera de la pantalla
   del teléfono. Con 0 cada celda respeta su columna. */
.grid > * { min-width: 0; }

/* Indicador de arranque: se ve hasta que Vue monta (sin <style> en línea en el HTML). */
#arranque { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgb(var(--fondo)); }
#arranque span { width: 2.5rem; height: 2.5rem; border-radius: 999px; border: 3px solid rgb(var(--marca-200)); border-top-color: rgb(var(--marca-600)); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* <iconify-icon> no ocupa espacio hasta que pinta: sin esto los botones saltan. */
iconify-icon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; flex-shrink: 0; }

/* ── Componentes base ─────────────────────────────────────────────────────── */
.tarjeta {
  background: rgb(var(--superficie));
  border: 1px solid rgb(var(--borde-suave));
  border-radius: 1rem;
  box-shadow: var(--sombra-sm);
}

.campo {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid rgb(var(--borde));
  border-radius: 0.625rem;
  background: rgb(var(--superficie));
  color: rgb(var(--texto));
  font-size: 1rem;   /* 16 px en el teléfono: iPhone no hace zoom al escribir */
  transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 640px) { .campo { font-size: 0.875rem; } }
textarea.campo { height: auto; min-height: 5rem; padding: 0.75rem 1rem; resize: vertical; }
select.campo { padding-right: 2.5rem; appearance: none; cursor: pointer; }
.campo::placeholder { color: rgb(var(--texto-3)); }
.campo:focus { outline: none; border-color: rgb(var(--marca-400)); box-shadow: 0 0 0 3px rgb(var(--marca-500) / 0.15); }
.campo:disabled { opacity: .6; cursor: not-allowed; }

.numeros { font-variant-numeric: tabular-nums; }

.esqueleto {
  position: relative;
  overflow: hidden;
  background: rgb(var(--superficie-3));
}
.esqueleto::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.45), transparent);
  animation: brillo 1.4s infinite;
}
html.dark .esqueleto::after { background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.06), transparent); }
@keyframes brillo { 100% { transform: translateX(100%); } }

.scroll-fino::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-fino::-webkit-scrollbar-thumb { background: rgb(var(--borde)); border-radius: 8px; }
.scroll-fino::-webkit-scrollbar-track { background: transparent; }
.sin-scroll { scrollbar-width: none; }
.sin-scroll::-webkit-scrollbar { display: none; }

/* Barra de progreso reutilizable: el ancho lo pone la vista con :style. */
.barra { height: 0.5rem; border-radius: 999px; background: rgb(var(--superficie-3)); overflow: hidden; }
.barra > span { display: block; height: 100%; border-radius: inherit; transition: width .4s ease; }

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type='number'] { -moz-appearance: textfield; }
html.dark input[type='date']::-webkit-calendar-picker-indicator,
html.dark input[type='time']::-webkit-calendar-picker-indicator,
html.dark input[type='datetime-local']::-webkit-calendar-picker-indicator { filter: invert(1); }

/* Estado tachado de eventos rechazados o cancelados (§4.1): no depende solo del color. */
.tachado { text-decoration: line-through; text-decoration-thickness: 1.5px; }
/* Bloqueo personal: rayado, para distinguirlo de un evento aunque no se lea el texto. */
.rayado { background-image: repeating-linear-gradient(135deg, rgb(var(--superficie-3)) 0 6px, transparent 6px 12px); }

/* ── Transiciones de Vue ─────────────────────────────────────────────────── */
.vista-enter-active, .vista-leave-active { transition: opacity .15s ease, transform .15s ease; }
.vista-enter-from { opacity: 0; transform: translateY(6px); }
.vista-leave-to { opacity: 0; }
.modal-enter-active, .modal-leave-active { transition: opacity .2s ease; }
.modal-enter-from, .modal-leave-to { opacity: 0; }
.aviso-enter-active, .aviso-leave-active { transition: all .25s ease; }
.aviso-enter-from, .aviso-leave-to { opacity: 0; transform: translateY(12px); }

/* ── Leaflet ───────────────────────────────────────────────────────────────
   Sin filtros de color en modo oscuro: invertir los mosaicos arruinaba las
   capas de satélite. Las teselas se ven como las entrega Google. */
.leaflet-container { font-family: inherit; background: rgb(var(--superficie-2)); }

/* ── Menú del teléfono (componentes/BarraInferior.js) ─────────────────────
   El relleno de abajo del contenido lo pone .con-barra-inferior y NADIE MÁS:
   reserva el hueco de la barra (si no, la barra se come la última fila).
   --alto-barra lo mide BarraInferior; el respaldo cubre el primer pintado. */
.con-barra-inferior { padding-bottom: calc(var(--alto-barra, calc(6.5rem + env(safe-area-inset-bottom))) + 1.25rem); }
@media (min-width: 1024px) { .con-barra-inferior { padding-bottom: 2rem; } }
/* En una página de formulario (formulario: true en config/menu.js) no hay barra de navegación sino
   BarraAcciones, más baja: un botón y su margen. Sin este hueco, el último campo queda debajo de los botones. */
.con-barra-acciones { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) { .con-barra-acciones { padding-bottom: 2rem; } }
/* Los botones de BarraAcciones: de solo texto, como en AppSheet. 3.5rem de alto (más que los 44 px). */
.accion-barra { min-height: 3.5rem; padding: 0 .75rem; font-size: 1rem; font-weight: 500; color: rgb(var(--texto-2)); }
.accion-barra:active { background: rgb(var(--superficie-2)); }
.accion-barra:disabled { color: rgb(var(--texto-3)); opacity: .6; }
.accion-barra-principal { font-weight: 700; color: rgb(var(--marca-tinte-texto)); }
/* Lo que flota sobre el contenido (avisos) se queda por encima de la barra. */
.sobre-barra { bottom: calc(var(--alto-barra, calc(6.5rem + env(safe-area-inset-bottom))) + .75rem); }
@media (min-width: 1024px) { .sobre-barra { bottom: 1.5rem; } }
.sobre-barra-sin-menu { bottom: max(1rem, env(safe-area-inset-bottom)); }
.barra-inferior { padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
.barra-flotante, .boton-menu { padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
@media (max-width: 639px) {
  .pantalla-completa { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
.hoja-modulos { max-height: 78dvh; padding-bottom: max(1rem, env(safe-area-inset-bottom)); animation: subir-hoja .22s ease-out; }
@keyframes subir-hoja { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Retrasos de las manchas del panel de marca del acceso. */
.retraso-2s { animation-delay: -4s; }
.retraso-4s { animation-delay: -9s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
