/* =========================================================
   Base común de todas las páginas: fuentes, tokens de diseño,
   ajustes de Bootstrap, estructura de página y componentes
   compartidos. Las hojas de cada página (dashboard, estacion,
   perfil…) solo usan estos tokens: ningún color, radio, sombra
   ni fuente se define fuera de aquí.
   ========================================================= */

/* ---------------------------------------------------------
   Fuentes: IBM Plex, servida desde la propia web (licencia OFL
   en static/fonts/ibm-plex/OFL.txt). Solo el subconjunto latino,
   que cubre el español; lo demás cae en la fuente de reserva.
   --------------------------------------------------------- */
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/ibm-plex/IBMPlexSans-Variable.b2c9031d9fd6.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: italic;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/ibm-plex/IBMPlexSans-Italic-Variable.ed273b4064f8.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex/IBMPlexMono-Regular.79936b18df9f.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex/IBMPlexMono-Medium.b1c8a895f5fd.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/ibm-plex/IBMPlexMono-SemiBold.5a2ce7798732.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------
   Tokens
   --------------------------------------------------------- */
:root {
    /* Verdes de marca (Inysur) */
    --g950: #001208;
    --g900: #002013;
    --g800: #004f2d;
    --g600: #00663d;  /* verde primario de marca */
    --g500: #009155;
    --g400: #00a060;
    --g100: #c8e8d8;
    --g50:  #eaf6f0;

    /* Neutros */
    --ink: #1a2e24;       /* texto principal */
    --muted: #56625d;     /* texto secundario: 6,4:1 sobre blanco y 5,6:1 sobre el fondo (AA) */
    --hair: #e2ebe6;      /* separadores */
    --border: #cdd9d2;    /* borde de campos y botones secundarios */
    --surface: #fff;

    /* Acentos */
    --ochre: #b5852f;       /* pesados; solo en gráficos y filetes, no como texto */
    --ochre-dim: #8f6a25;   /* pesados como texto */
    --ochre-soft: #f6e9cb;
    --danger: #a52020;

    /* Red de carreteras: los mismos colores que el visor (ROAD_STYLES en
       leaflet_main.js). Local y Ramal van oscurecidos para que el texto
       blanco de las etiquetas se lea (5,6 y 5,1:1). */
    --red-comarcal: #db1e2a;
    --red-local: #3a6aa3;
    --red-ramal: #2f7d2a;
    --red-otras: #0e5ae8;   /* valores de `red` no contemplados */

    /* Tipografía */
    --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Formas */
    --r-sm: 6px;      /* botones, campos, etiquetas */
    --r: 10px;        /* tarjetas y paneles */
    --r-lg: 14px;     /* tarjetas de cabecera (ficha, perfil, portada) */
    --shadow: 0 4px 10px rgba(0, 32, 19, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 32, 19, 0.08);
    --focus-ring: 0 0 0 3px rgba(0, 102, 61, 0.2);
    --gradient: linear-gradient(135deg, var(--g600) 0%, var(--g800) 100%);
    --page-bg:
        radial-gradient(120% 60% at 85% -5%, rgba(0, 102, 61, 0.05), transparent 60%),
        linear-gradient(180deg, #f4f7f5, #eef3f0);

    /* Bootstrap, con los mismos tokens */
    --bs-body-font-family: var(--sans);
    --bs-body-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-link-color: var(--g600);
    --bs-link-color-rgb: 0, 102, 61;
    --bs-link-hover-color: var(--g800);
    --bs-link-hover-color-rgb: 0, 79, 45;
    --bs-border-color: var(--border);
    --bs-border-radius: var(--r-sm);
}

/* ---------------------------------------------------------
   Estructura: barra, contenido y pie
   --------------------------------------------------------- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    /* El contenido hace scroll dentro de <main>: la barra y el pie
       quedan siempre a la vista. */
    overflow: auto;
    padding: 0;
}

.nav-principal {
    background: var(--g900);
}

.ft-main {
    display: flex;
    justify-content: space-evenly;
    background: var(--g900);
    padding: 0.2rem 1rem;
}

.ft-main a,
.ft-main a:hover {
    font-size: 0.8rem;
    color: #fff;
    text-decoration: none;
}

.ft-main a:hover { text-decoration: underline; }
.ft-main p { margin: 0; }

/* Página de contenido: fondo común, ancho máximo y cabecera */
.pagina {
    min-height: 100%;
    padding: 2rem 1rem 4rem;
    background: var(--page-bg);
    color: var(--ink);
}

.pagina-contenido {
    max-width: 1200px;
    margin: 0 auto;
}

.cabecera-pagina {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cabecera-pagina h1 {
    margin: 0;
    color: var(--g800);
    font-size: 1.9rem;
    font-weight: 700;
}

.cabecera-pagina p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---------------------------------------------------------
   Botones y campos: los de Bootstrap con los tokens de la web.
   Primario = acción principal; outline-secondary = secundaria;
   outline-danger = cerrar sesión y similares.
   --------------------------------------------------------- */
.btn {
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: var(--r-sm);
}

.btn-primary {
    --bs-btn-bg: var(--g600);
    --bs-btn-border-color: var(--g600);
    --bs-btn-hover-bg: var(--g800);
    --bs-btn-hover-border-color: var(--g800);
    --bs-btn-active-bg: var(--g900);
    --bs-btn-active-border-color: var(--g900);
    --bs-btn-disabled-bg: var(--g600);
    --bs-btn-disabled-border-color: var(--g600);
    --bs-btn-focus-shadow-rgb: 0, 102, 61;
}

.btn-outline-secondary {
    --bs-btn-color: var(--g800);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-color: var(--g800);
    --bs-btn-hover-bg: var(--g50);
    --bs-btn-hover-border-color: var(--g600);
    --bs-btn-active-color: var(--g800);
    --bs-btn-active-bg: var(--g100);
    --bs-btn-active-border-color: var(--g600);
    --bs-btn-focus-shadow-rgb: 0, 102, 61;
}

.btn-outline-danger {
    --bs-btn-color: var(--danger);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: rgba(165, 32, 32, 0.3);
    --bs-btn-hover-color: var(--danger);
    --bs-btn-hover-bg: rgba(165, 32, 32, 0.06);
    --bs-btn-hover-border-color: var(--danger);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--danger);
    --bs-btn-active-border-color: var(--danger);
    --bs-btn-focus-shadow-rgb: 165, 32, 32;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--g600);
    box-shadow: var(--focus-ring);
}

/* ---------------------------------------------------------
   Componentes compartidos
   --------------------------------------------------------- */

/* Antetítulo sobre el nombre de una ficha (carretera, perfil) */
.antetitulo {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--g600);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

.antetitulo::before {
    content: "";
    width: 18px;
    height: 2px;
    background: var(--g600);
}

/* Tarjeta de cabecera (ficha, perfil, portada), con los anillos de
   "localizador" tenues en la esquina */
.tarjeta-cabecera {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}

.con-anillos::before {
    content: "";
    position: absolute;
    top: -50px;
    right: -40px;
    width: 220px;
    height: 220px;
    background: repeating-radial-gradient(circle at center,
        transparent 0 18px, rgba(0, 102, 61, 0.05) 18px 19px);
    -webkit-mask-image: radial-gradient(circle at center, #000 40%, transparent 72%);
    mask-image: radial-gradient(circle at center, #000 40%, transparent 72%);
    pointer-events: none;
}

/* Acceso a otra sección: tarjeta-enlace con cifra opcional y flecha */
.acceso {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--hair);
    border-radius: var(--r);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.acceso:hover,
.acceso:focus-visible {
    border-color: var(--g600);
    box-shadow: 0 4px 12px rgba(0, 102, 61, 0.1);
    color: inherit;
}

.acceso:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.acceso-cifra {
    flex-shrink: 0;
    min-width: 46px;
    padding-right: 1rem;
    border-right: 1px solid var(--hair);
    font-family: var(--mono);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    color: var(--g600);
}

.acceso-cifra small {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.58rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.acceso-texto { flex: 1; min-width: 0; }

.acceso-titulo {
    margin-bottom: 0.12rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
}

.acceso-desc {
    font-size: 0.82rem;
    color: var(--muted);
}

.acceso-flecha {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 1.3rem;
    color: var(--g100);
    transition: color 0.16s;
}

.acceso:hover .acceso-flecha { color: var(--g600); }

/* Aviso de "no hay datos" a nivel de página */
.vacio {
    margin-bottom: 1.5rem;
    padding: 2.25rem 2rem;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    color: var(--muted);
    text-align: center;
}

.vacio p:last-child { margin-bottom: 0; }

/* Aparición al cargar: la usan tarjetas y paneles; cada uno fija su
   retardo con la variable --d (style="--d: 0.06s" en la plantilla). */
@keyframes aparecer {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

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