/* ==========================================================================
   Portal Ciudadano — GAD Municipal de Rocafuerte
   Base común de todas las páginas del ciudadano: paleta, tipografía, foco,
   superficies del navegador, movimiento, encabezado/navegación y tablas que
   se vuelven tarjetas en el celular. Las utilidades vienen de Tailwind
   (public/css/tailwind.css, compilado); aquí sólo lo que es del sistema.
   ========================================================================== */

:root {
    /* Tinta institucional: títulos, enlaces, encabezado (11.6:1 sobre blanco) */
    --gad-tinta: #003B73;
    --gad-tinta-osc: #002855;
    /* Acción de pago: botones primarios (5.5:1 con texto blanco) */
    --gad-verde: #047857;
    --gad-verde-osc: #065F46;
    /* Dorado del escudo: sólo como detalle decorativo, nunca para texto */
    --gad-oro: #D4A017;

    --texto: #1F2937;        /* 14.7:1 */
    --texto-2: #4B5563;      /* 7.6:1  */
    --texto-3: #5F6B7A;      /* 5.4:1 sobre blanco, 5.0:1 sobre #F8FAFC */
    --superficie: #FFFFFF;
    --fondo: #F8FAFC;
    --borde: #D9DEE5;
    --borde-campo: #7D8796;  /* borde de inputs: 3.6:1 sobre blanco (WCAG 1.4.11) */

    --radio: 14px;
    --sombra: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
    --nav-inferior: 64px;
}

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--texto);
    background: var(--fondo);
    font-feature-settings: 'cv11', 'ss01';
}
.font-institucional { font-family: 'Montserrat', 'Inter', system-ui, sans-serif; letter-spacing: -0.02em; }
.cifra { font-variant-numeric: tabular-nums; }

/* ── Superficies del navegador ──────────────────────────────────────────── */
::selection { background: #CDE3F7; color: var(--gad-tinta-osc); }
input, textarea, select { caret-color: var(--gad-tinta); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--gad-verde); }
a { text-underline-offset: 3px; }

/* Foco visible y consistente en todo control (WCAG 2.4.7). Se impone a los
   `outline-none` de las utilidades porque el halo anterior medía 1.27:1. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--gad-tinta) !important;
    outline-offset: 2px !important;
}
:where(input, select, textarea):focus-visible { border-color: var(--gad-tinta) !important; }

/* Casillas de aceptación: 22px visibles, con zona táctil de 44px en la etiqueta */
.casilla { width: 22px; height: 22px; flex-shrink: 0; margin-top: 1px; cursor: pointer; }
.casilla-etiqueta { min-height: 44px; display: flex; align-items: flex-start; gap: .75rem; padding: .5rem 0; cursor: pointer; }

/* ── Movimiento: el contenido nace visible; la entrada es un detalle ───── */
.fade-in, .fade-up { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
    .fade-in { animation: gadEntrada .32s cubic-bezier(.16, 1, .3, 1) both; }
    @keyframes gadEntrada { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
.gad-spin { display: inline-block; animation: gadGiro .9s linear infinite; }
@keyframes gadGiro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .gad-spin { animation-duration: 2.4s; }
    * { scroll-behavior: auto !important; }
}

/* ── Encabezado común ───────────────────────────────────────────────────── */
.gad-franja {
    background: var(--gad-tinta-osc); color: #E6EEF7;
    font-size: 12px; padding: 6px 16px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.gad-franja a { color: #E6EEF7; text-decoration: none; }
.gad-franja a:hover { text-decoration: underline; }
.gad-header {
    background: var(--superficie);
    border-bottom: 3px solid var(--gad-oro);
    position: sticky; top: 0; z-index: 40;
}
.gad-header-in {
    max-width: 80rem; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.gad-marca { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-height: 44px; }
.gad-marca img { width: 44px; height: 47px; object-fit: contain; }
.gad-marca-nombre { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 15px; line-height: 1.15; color: var(--gad-tinta); letter-spacing: -0.01em; }
.gad-marca-sub { display: block; font-size: 12px; font-weight: 600; color: var(--texto-3); letter-spacing: 0; }

.gad-nav { display: flex; align-items: center; gap: 4px; }
.gad-nav a {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
    border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--texto-2); text-decoration: none;
}
.gad-nav a:hover { background: #EEF4FA; color: var(--gad-tinta); }
.gad-nav a[aria-current="page"] { background: #E3EDF7; color: var(--gad-tinta); }
.gad-nav a.gad-salir { color: #B91C1C; }
.gad-nav a.gad-salir:hover { background: #FEF2F2; color: #991B1B; }

/* Barra inferior en el celular (sólo con sesión iniciada) */
.nav-inferior { display: none; }
@media (max-width: 767px) {
    .gad-nav { display: none; }
    .gad-marca-sub { display: none; }
    .nav-inferior {
        display: grid; grid-template-columns: repeat(4, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
        background: var(--superficie); border-top: 1px solid var(--borde);
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 14px rgba(15, 23, 42, .06);
    }
    .nav-inferior a {
        min-height: var(--nav-inferior); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        font-size: 12px; font-weight: 600; color: var(--texto-3); text-decoration: none;
    }
    .nav-inferior a i { font-size: 18px; }
    .nav-inferior a[aria-current="page"] { color: var(--gad-tinta); }
    .nav-inferior a.gad-salir { color: #B91C1C; }
    body:has(.nav-inferior) { padding-bottom: calc(var(--nav-inferior) + env(safe-area-inset-bottom)); }
}

/* ── Tablas que en el celular se leen como tarjetas ─────────────────────── */
@media (max-width: 639px) {
    .tabla-resp thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .tabla-resp, .tabla-resp tbody, .tabla-resp tr, .tabla-resp td { display: block; width: 100%; }
    .tabla-resp tr { padding: 14px 16px; border-bottom: 1px solid var(--borde); }
    .tabla-resp td { padding: 3px 0 !important; text-align: left !important; white-space: normal !important; }
    .tabla-resp td[data-label]::before {
        content: attr(data-label); display: block;
        font-size: 12px; font-weight: 600; color: var(--texto-3); margin-bottom: 1px;
    }
    .tabla-resp td.celda-monto { display: flex; justify-content: space-between; align-items: baseline; padding-top: 8px !important; }
    .tabla-resp td.celda-monto::before { display: inline; margin: 0; }
    .tabla-resp tfoot { display: none; }
}

/* ── Diálogos (los modales existentes reciben semántica en gad.js) ─────── */
body.gad-modal-abierto { overflow: hidden; }

/* ── Avisos (reemplazan a alert()) ──────────────────────────────────────── */
.gad-avisos { position: fixed; left: 50%; transform: translateX(-50%); top: 16px; z-index: 70; width: min(560px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; }
.gad-aviso {
    background: var(--superficie); border: 1px solid var(--borde); border-radius: 12px; box-shadow: var(--sombra);
    padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--texto);
}
.gad-aviso.error { border-color: #FCA5A5; background: #FEF2F2; color: #7F1D1D; }
.gad-aviso.exito { border-color: #A7F3D0; background: #ECFDF5; color: #064E3B; }
.gad-aviso button { margin-left: auto; min-width: 32px; min-height: 32px; border-radius: 8px; color: inherit; }

/* ── Impresión ──────────────────────────────────────────────────────────── */
@media print {
    .gad-franja, .gad-header nav, .nav-inferior, .no-print { display: none !important; }
    .gad-header { position: static; border-bottom-width: 2px; }
    body { background: #fff; padding: 0 !important; }
}
