/* Estilos del simulador HEEI — re-skin con la identidad CIEP.
   CERO HEX aquí: todo color viene de ciep-tokens.css (guidelines v1). */
* { box-sizing: border-box; }

body {
  font-family: var(--fuente-cuerpo);
  font-size: 16px;
  line-height: 1.65;
  margin: 0;
  color: var(--ciep-black);
  background: var(--ciep-beige);
}
h1, h2, h3, legend, summary { font-family: var(--fuente-titulos); }
h1 { font-weight: 700; font-size: 1.6rem; margin: 0 0 0.3rem; }
h2 { font-weight: 700; font-size: 1.5rem; }
h3 { font-weight: 500; font-size: 1.25rem; }

/* Header y footer: fondo oscuro institucional, logo blanco lateral */
header, footer { background: var(--ciep-gray-dark); color: var(--ciep-white); padding: 1rem 2rem; }
header { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
header img { flex-shrink: 0; }
header div { flex: 1 1 28rem; min-width: 0; max-width: 60rem; }
header p, footer p { color: var(--ciep-gray-light); margin: 0; font-size: 0.92rem; line-height: 1.5; }
footer { font-size: 0.9rem; }

main { max-width: 70rem; margin: 0 auto; padding: 1.5rem; }

/* Card: superficie blanca, radio 24, borde sutil, sombra sm→md en hover */
.panel, section#resultados {
  background: var(--ciep-white);
  border: 1px solid var(--ciep-gray-light);
  border-radius: var(--radio-card);
  box-shadow: var(--sombra-sm);
  padding: 20px 28px 24px;
  margin-bottom: 1.2rem;
  transition: box-shadow 0.15s ease;
}
.panel:hover { box-shadow: var(--sombra-md); }

/* Rótulo de paso (estilo "SIGUE 2 SIMPLES PASOS" del Simulador Fiscal) */
.eyebrow {
  font-family: var(--fuente-titulos);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ciep-gray);
  margin: 0 0 0.4rem;
}

/* ---- Formulario compacto: parámetros en 2 columnas, costos abajo ---- */
.parametros {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 2.5rem;
}
@media (max-width: 800px) {
  .parametros { grid-template-columns: 1fr; }
  .parametros .columna + .columna { margin-top: 1.1rem; }
}
.parametros h2, .costos h2 {
  font-size: 1.05rem; margin: 0 0 0.5rem; padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--ciep-gray-light);
}
.parametros h2 small, .costos h2 small {
  display: block; font-family: var(--fuente-cuerpo); font-weight: 400;
  font-size: 0.78rem; color: var(--ciep-gray); margin-top: 0.1rem;
}
.costos { margin-top: 1.1rem; }
.costos .nota { margin: 0 0 0.6rem; }

.campo { padding: 0.3rem 0; border-bottom: 1px solid var(--ciep-gray-light); }
.campo:last-child { border-bottom: 0; }
/* Etiqueta y control en la misma línea (patrón de filas del Fiscal) */
.campo.fila { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
.campo.fila label { flex: 1; margin: 0; }
.campo.fila select, .campo.fila input.campo_numero { flex: 0 0 11rem; min-width: 0; }

label { display: block; margin: 0 0 0.15rem; font-weight: 600; font-size: 0.86rem; line-height: 1.35; }
/* Dato fijado por el build (no editable), alineado como los controles */
.dato_fijo { flex: 0 0 11rem; text-align: right; font-size: 0.86rem; font-weight: 600; color: var(--ciep-gray-dark); font-variant-numeric: tabular-nums; }
#fuente_pib { margin: 0.5rem 0 0; font-size: 0.75rem; }
label small { display: block; font-weight: 400; font-size: 0.76rem; color: var(--ciep-gray); }
input[type=range] { width: 100%; height: 1.2rem; margin: 0.1rem 0 0.25rem; accent-color: var(--ciep-orange); }
/* Todos los números alineados a la derecha, con dígitos tabulares */
input[type=number], input.campo_numero { text-align: right; font-variant-numeric: tabular-nums; }

input[type=number], input.campo_numero, select {
  padding: 0.25rem 0.5rem;
  font-size: 0.86rem;
  font-family: var(--fuente-cuerpo);
  border: 1px solid var(--ciep-gray-light);
  border-radius: 6px;
  background: var(--ciep-white);
  color: var(--ciep-black);
}
input[type=checkbox] { accent-color: var(--ciep-orange); }
output { font-weight: 700; color: var(--ciep-orange); margin-left: 0.35rem; font-variant-numeric: tabular-nums; }

/* Stepper unificado [−][ valor ][+] (patrón .tasa-control del Fiscal):
   botones cuadrados pequeños fusionados al campo, acento naranja en hover */
.stepper { display: inline-flex; align-items: stretch; width: 100%; }
.stepper button {
  flex: 0 0 1.6rem; width: 1.6rem; margin: 0; padding: 0;
  font-family: var(--fuente-cuerpo); font-size: 0.95rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--ciep-gray-light); color: var(--ciep-black);
  border: 1px solid var(--ciep-gray-light); border-radius: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.stepper .paso_menos { border-radius: 6px 0 0 6px; border-right: 0; }
.stepper .paso_mas { border-radius: 0 6px 6px 0; border-left: 0; }
.stepper button:hover { background: var(--ciep-orange); border-color: var(--ciep-orange); color: var(--ciep-white); transform: none; }
.stepper button:active { background: var(--ciep-orange-light); border-color: var(--ciep-orange-light); }
.stepper input.campo_numero { flex: 1; min-width: 0; border-radius: 0; padding: 0.2rem 0.45rem; }
.stepper input.campo_numero:focus-visible { position: relative; z-index: 1; }

/* Focus SIEMPRE visible: borde naranja + halo (nunca outline:none a secas) */
input:focus-visible, select:focus-visible, button:focus-visible,
a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ciep-orange);
  outline-offset: 1px;
  box-shadow: var(--halo-focus);
}

a { color: var(--ciep-orange); }
a:hover { color: var(--ciep-orange-light); }

/* 3 columnas fijas: con 16 modalidades la última fila queda parcialmente
   vacía a propósito (grilla regular, lectura por filas) */
.grid-costos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem 1.2rem; }
@media (max-width: 900px) { .grid-costos { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-costos { grid-template-columns: 1fr; } }
.grid-costos label {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  margin: 0; padding: 0.2rem 0; font-weight: 400; font-size: 0.82rem;
  border-bottom: 1px solid var(--ciep-gray-light);
}
.grid-costos .costo_nombre { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-costos .stepper { flex: 0 0 9.5rem; width: 9.5rem; }
.grid-costos input { font-size: 0.82rem; }
.nota { font-size: 0.85rem; color: var(--ciep-gray); }

/* Acciones: rótulo del paso 2 a la izquierda, CTA a la derecha */
.acciones {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 1.1rem; padding-top: 0.9rem; border-top: 2px solid var(--ciep-gray-light);
}
.acciones .eyebrow { margin: 0; }

/* CTA primario: uno solo por vista, naranja; hover orange-light + lift */
button {
  background: var(--ciep-orange);
  color: var(--ciep-white);
  border: 0;
  border-radius: 12px;
  padding: 0.6rem 2.2rem;
  font-family: var(--fuente-titulos);
  font-weight: 500;
  font-size: 1.05rem;
  cursor: pointer;
  margin: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}
button:hover { background: var(--ciep-orange-light); transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: wait; transform: none; }

.error {
  background: var(--ciep-error-bg);
  color: var(--ciep-error-fg);
  border: 1px solid var(--ciep-error-border);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin-top: 1rem;
}

/* El atributo hidden debe ganar SIEMPRE (banner fantasma corregido) */
#espera { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
#espera[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px;
  border: 4px solid var(--ciep-gray-light);
  border-top-color: var(--ciep-orange);
  border-radius: 50%;
  animation: gira 0.9s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

/* ---- Resultados: cabecera con selector de ámbito, gasto protagonista,
   indicadores secundarios en UNA línea ---- */
#resultados h2 { margin: 0; font-size: 1.5rem; }
#resultados h3 { font-size: 1.05rem; margin: 1.4rem 0 0.5rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--ciep-gray-light); }
#resultados h3 small { font-family: var(--fuente-cuerpo); font-weight: 400; font-size: 0.78rem; color: var(--ciep-gray); margin-left: 0.4rem; }
.resultados_cabecera {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 0.8rem; border-bottom: 2px solid var(--ciep-gray-light);
}
.resultados_cabecera .eyebrow { margin-bottom: 0.1rem; }
.selector_ambito { flex: 0 1 22rem; border: 0; padding: 0; }
.selector_ambito label { text-align: right; }
.selector_ambito select { flex: 0 0 12rem; font-weight: 600; border-color: var(--ciep-orange); }

.gasto_principal {
  display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap;
  padding: 1rem 0 0.6rem;
}
.gasto_principal span { flex-basis: 100%; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ciep-gray); }
.gasto_principal strong { font-family: var(--fuente-titulos); font-size: 2.6rem; line-height: 1; color: var(--ciep-orange); font-variant-numeric: tabular-nums; }
.gasto_principal small { font-size: 0.95rem; font-weight: 600; color: var(--ciep-gray-dark); }

.indicadores { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.5rem; margin: 0.4rem 0 0; }
@media (max-width: 900px) { .indicadores { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .indicadores { grid-template-columns: repeat(2, 1fr); } }
.tarjeta {
  background: var(--ciep-beige);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  min-width: 0;
}
.tarjeta span { display: block; font-size: 0.7rem; line-height: 1.25; color: var(--ciep-gray); }
.tarjeta strong { display: block; margin-top: 0.15rem; font-family: var(--fuente-titulos); font-size: 1.15rem; color: var(--ciep-gray-dark); font-variant-numeric: tabular-nums; }

.tooltip_modalidad { padding: 0.45rem 0.65rem; font-size: 0.8rem; line-height: 1.5; }
.tooltip_modalidad strong { display: block; margin-bottom: 0.2rem; }

/* ---- Mapa: tres grupos de controles en UNA fila compacta ---- */
#mapa { height: 560px; border-radius: 16px; border: 1px solid var(--ciep-gray-light); margin: 0.6rem 0; }
.mapa_controles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; }
@media (max-width: 900px) { .mapa_controles { grid-template-columns: 1fr; } }
.mapa_controles fieldset { margin: 0; padding: 0.3rem 0.7rem 0.5rem; border: 1px solid var(--ciep-gray-light); border-radius: 12px; min-width: 0; }
.mapa_controles legend { font-weight: 500; font-size: 0.86rem; padding: 0 0.3rem; }
.mapa_controles legend small { font-family: var(--fuente-cuerpo); font-weight: 400; font-size: 0.72rem; color: var(--ciep-gray); }
.mapa_controles label { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; font-weight: 400; font-size: 0.8rem; margin: 0.1rem 0; }
.mapa_controles label small { display: inline; font-size: 0.7rem; }
.mapa_controles select { padding: 0.1rem 0.4rem; font-size: 0.8rem; }
/* Chips-toggle: el checkbox nativo queda accesible pero oculto a la vista;
   el estado se lee en el chip (lleno = activo, desvanecido = inactivo) */
.chips { display: flex; flex-wrap: wrap; gap: 0.2rem 0.3rem; margin-top: 0.3rem; }
.chips .chip {
  position: relative; display: inline-flex; gap: 0.25rem; align-items: center;
  font-size: 0.7rem; font-weight: 400; white-space: nowrap; margin: 0;
  background: var(--ciep-gray-light); color: var(--ciep-black);
  border-radius: 999px; padding: 0.05rem 0.5rem; cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.chips .chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chips .chip:hover { background: var(--ciep-orange-light); color: var(--ciep-white); }
.chips .chip:not(:has(input:checked)) { opacity: 0.45; text-decoration: line-through; }
.chips .chip:has(input:focus-visible) { outline: 2px solid var(--ciep-orange); outline-offset: 1px; }
.leyenda_punto {
  display: inline-block; width: 11px; height: 11px;
  border-radius: 50%; border: 1px solid var(--ciep-black); vertical-align: -1px;
}
.leaflet-popup-content { font-family: var(--fuente-cuerpo); }
/* Tooltip de hover sobre puntos (modalidad + magnitud); el click abre el popup */
.leaflet-tooltip.tooltip_mapa {
  font-family: var(--fuente-cuerpo); font-size: 0.78rem; line-height: 1.4;
  background: var(--ciep-gray-dark); color: var(--ciep-white);
  border: 0; border-radius: 8px; padding: 0.35rem 0.6rem; box-shadow: var(--sombra-md);
}
.leaflet-tooltip.tooltip_mapa::before { border-top-color: var(--ciep-gray-dark); }
.leaflet-popup-content hr { margin: 0.3rem 0; border: 0; border-top: 1px solid var(--ciep-gray-light); }

/* Tablas de los popups de oferta (tabla_html del asset) */
.leaflet-popup-content table { border-collapse: collapse; font-size: 0.8rem; }
.leaflet-popup-content th, .leaflet-popup-content td { border: 1px solid var(--ciep-gray-light); padding: 0.15rem 0.4rem; }

/* Roseta como marca de agua sobre claro (10% de opacidad, guidelines 03) */
main { position: relative; }
main::after {
  content: "";
  position: absolute;
  top: 0; right: -2rem;
  width: 260px; height: 260px;
  background: url("../assets/roseta-color.png") no-repeat center / contain;
  opacity: 0.1;
  pointer-events: none;
  z-index: 0;
}
main > * { position: relative; z-index: 1; }
