/* ════════════════════════════════════════════════════════════════════════════════
   VARIABLES CSS GLOBALES (Color Scheme)
   ════════════════════════════════════════════════════════════════════════════════
   Define la paleta de colores y estilos reutilizables en todo el proyecto.
   Uso: var(--nombre-variable) en cualquier propiedad CSS
*/
:root {
    --primary-dark: #003057;          /* Azul oscuro principal - Headers, botones activos */
    --primary-teal: #008e97;          /* Verde azulado - Acentos, estadísticas destacadas */
    --teal-dark: #005f65;             /* Verde azulado oscuro - Bordes, elementos secundarios */
    --bg-page: #f4f7f9;               /* Gris muy claro - Fondo de página */
    --bg-card: #ffffff;               /* Blanco - Fondo de cards y paneles */
    --border-light: #e0e6ed;          /* Gris claro - Bordes de componentes */
    --text-main: #333333;             /* Gris oscuro - Texto principal */
    --text-muted: #666666;            /* Gris medio - Texto secundario */
    --text-light: #999999;            /* Gris claro - Texto terciario */
    --shadow-card: 0 4px 6px rgba(0,0,0,0.6);  /* Sombra suave - Cards y paneles */
    --gradient-teal: linear-gradient(90deg, #009688, #004d40);  /* Gradiente teal - Barras, gráficos */
}

/* ════════════════════════════════════════════════════════════════════════════════
   RESET GLOBAL - Estilos base para todos los elementos
   ════════════════════════════════════════════════════════════════════════════════
   Elimina márgenes/paddings por defecto, establece border-box para todos los elementos
*/
* { margin:0; padding:0; box-sizing:border-box; }

/* ════════════════════════════════════════════════════════════════════════════════
   BODY - Estilos del elemento raíz
   ════════════════════════════════════════════════════════════════════════════════
   Fuente: Barlow | Fondo: gris muy claro | Altura mínima: 100vh
*/
body {
    font-family: 'Barlow', sans-serif;
    background: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
}

/* ════════════════════════════════════════════════════════════════════════════════
   HEADER INSTITUCIONAL
   ════════════════════════════════════════════════════════════════════════════════
   Sección superior con logos (Gobierno, OVER, Fundelec) y estado en tiempo real.
   Layout: Flexbox con 3 secciones (izq 25%, centro 50%, der 25%)
   Altura: 90px | Borde inferior: 1px gris | z-index: 20 (por encima de nav)
*/
header {
    background: #fff;
    border-bottom: 1px solid var(--border-light);
    padding: 0.8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    position: relative;
    z-index: 20;
    height: 90px;
}

.header-left {
    display: flex;
    align-items: center;
    width: 25%;
}

/* Logo Gobierno - Sección izquierda del header */
.logo-min {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-min img {
    height: 55px;
    width: auto;
    object-fit: contain;
}

.logo-min .txt {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-min .txt span:first-child {
    font-size: 0.65rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
}

.logo-min .txt span:last-child {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
}

/* Logo OVER - Centro del header */
.logo-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 50%;
}

.logo-center img {
    height: 45px;
    width: auto;
    object-fit: contain;
    margin-bottom: 2px;
}

.logo-center .titulo {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Logo Fundelec - Sección derecha del header */
.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    width: 25%;
    gap: 5px;
}

.logo-fundelec {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: row-reverse;
}

.logo-fundelec img {
    height: 45px;
    width: auto;
}

.logo-fundelec .txt {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: right;
}

.logo-fundelec .txt span:first-child {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary-teal);
}

.logo-fundelec .txt span:last-child {
    font-size: 0.6rem;
    color: #666;
    letter-spacing: 0.5px;
}

/* Indicador en vivo - "Datos cargados" con punto verde */
.live-text {
    font-size: 0.65rem;
    color: #666;
    display: flex;
    align-items: center;
}

.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #4CAF50;  /* Verde - indica datos disponibles */
    border-radius: 50%;
    margin-right: 5px;
}

/* ════════════════════════════════════════════════════════════════════════════════
   BARRA DE NAVEGACIÓN (NAV)
   ════════════════════════════════════════════════════════════════════════════════
   5 botones de pestañas principales | Color fondo: azul oscuro
   Botón activo tiene borde inferior teal | Sticky position (fijo al scroll)
*/
nav {
    background: var(--primary-dark);
    display: flex;
    justify-content: center;
    padding: 0;
}

/* Botones de navegación - Estilos individuales */
.nav-tab {
    padding: 0.9rem 1.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);  /* Blanco semi-transparente */
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;  /* Borde inferior invisible por defecto */
}

.nav-tab:hover {
    color: #fff;  /* Blanco opaco al pasar mouse */
    background: rgba(255,255,255,0.05);  /* Fondo blanco muy suave */
}

.nav-tab.active {
    color: #fff;
    border-bottom-color: var(--primary-teal);  /* Borde teal cuando está activo */
    background: rgba(255,255,255,0.1);
}

/* ════════════════════════════════════════════════════════════════════════════════
   CONTENEDOR PRINCIPAL (MAIN)
   ════════════════════════════════════════════════════════════════════════════════
   Padding: 1.5rem 2rem | Max-width: 1600px | Centrado
   Display: Flex columna con gap de 1.5rem
*/
main {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Sistema de Grillas principales */
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }                           /* 1 columna */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }                       /* 2 columnas iguales */
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.5rem; }                   /* 3 columnas: 2fr + 1fr + 1fr */

/* ════════════════════════════════════════════════════════════════════════════════
   CONTENEDOR DE IMAGEN DEL ESTADO
   ════════════════════════════════════════════════════════════════════════════════
   Muestra imagen del estado seleccionado | Centro alineado | Fondo gris claro
   Función JS: showEstadoImagen() - Carga imagen desde carpeta /estados/
*/
.estado-imagen-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9fafb;
    border-radius: 6px;
    min-height: 150px;
    overflow: hidden;
}

.estado-imagen-container img {
    max-width: 100%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 4px;
}

/* ════════════════════════════════════════════════════════════════════════════════
   BANNER PRINCIPAL CON KPI TOTAL
   ════════════════════════════════════════════════════════════════════════════════
   Ancho: 100vw (pantalla completa) | Centrado | Muestra título + número
   Función JS: updateKPIs() - Llena el contador de sistemas totales
*/
.ban {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-bottom: 1.5rem;
    padding: 2rem 2rem;
    background: #FFFFFF;
}

.ban-label {
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.ban-label span {
    font-size: 3.4rem;
    color: #003057;
    font-weight: 800;
    margin-left: 4.5rem;
}

/* ════════════════════════════════════════════════════════════════════════════════
   INDICADORES CLAVE (KPIs)
   ════════════════════════════════════════════════════════════════════════════════
   Mostrados en filas de 5 columnas | Cards con bordes y sombras sutiles
   Función JS: updateKPIs() - Llena dinámicamente los valores
*/
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: 6px;
    padding: 1.2rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    height: 100%;
}

.kpi-label {
    font-size: 0.65rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 700;
    width: 100%;
}

.kpi-value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 3.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary-dark);
    display: flex;
    align-items: baseline;
    justify-content: center;
    width: 100%;
}

.kpi-unit {
    font-size: 0.9rem;
    color: var(--primary-teal);
    margin-left: 4px;
    font-weight: 600;
}

.kpi-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    width: 100%;
}

/* ════════════════════════════════════════════════════════════════════════════════
   CARDS Y PANELES
   ════════════════════════════════════════════════════════════════════════════════
   Contenedores principales con fondo blanco | Panel-title: encabezado con borde inferior
*/
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}

.panel-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary-dark);
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #eee;
}

/* ════════════════════════════════════════════════════════════════════════════════
   TABLAS
   ════════════════════════════════════════════════════════════════════════════════
   Estilos para tabla-estados | Encabezados en mayúsculas | Filas con hover
   Funciones JS: buildTablaEstados(), buildAreasProtegidas(), buildImpactoAmbiental()
*/
.tabla-estados {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.tabla-estados thead th {
    text-align: left;
    padding: 0.6rem 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
}

.tabla-estados tbody tr {
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;  /* Indica que las filas son clickeables */
}

.tabla-estados tbody tr:hover {
    background: #f8fbfc;  /* Cambio de fondo al pasar mouse */
}

.tabla-estados td {
    padding: 0.5rem 0.4rem;
    color: var(--text-main);
}

.td-estado {
    font-weight: 600;
    color: var(--primary-dark);
}

.td-num {
    color: var(--primary-dark);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
}

.td-co2 {
    color: var(--primary-teal);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Barra horizontal dentro de tabla (distribución) */
.bar-container {
    width: 80px;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--gradient-teal);
}

/* ════════════════════════════════════════════════════════════════════════════════
   GRÁFICOS Y LEYENDAS
   ════════════════════════════════════════════════════════════════════════════════
   Barras verticales para Top 10 estados | Donas con leyendas | Tipo grid
   Funciones JS: buildChart(), buildDonut(), buildSocial(), buildTiposDetalle()
*/
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 140px;
    padding: 0 4px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bar-rect {
    width: 100%;
    border-radius: 4px 4px 0 0;
    background: var(--gradient-teal);
    min-height: 4px;
    transition: opacity 0.2s;
}

.bar-xlabel {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
}

.bar-ylabel {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.8rem;
    color: var(--primary-dark);
    font-weight: 700;
}

/* Donas (SVG charts) */
.donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Leyendas para gráficos */
.legend {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    color: var(--text-muted);
}

.legend-val {
    font-weight: 700;
    color: var(--primary-dark);
}

/* Grid de tipos (barras horizontales) */
.tipo-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tipo-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
}

.tipo-name {
    color: var(--text-muted);
    width: 120px;
    flex-shrink: 0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.tipo-bar-wrap {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.tipo-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--gradient-teal);
}

.tipo-val {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.95rem;
    color: var(--primary-dark);
    min-width: 40px;
    text-align: right;
    font-weight: 700;
}

/* ════════════════════════════════════════════════════════════════════════════════
   CASOS DESTACADOS
   ════════════════════════════════════════════════════════════════════════════════
   Cards con borde izquierdo teal | Título en mayúsculas | Descripción secundaria
   Animación: Traslación al hover
*/
.caso-card {
    background: #f8fbfc;
    border-left: 4px solid var(--primary-teal);
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.caso-card:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.caso-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 6px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    line-height: 1.3;
}

.caso-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
    font-weight: 400;
}

/* ════════════════════════════════════════════════════════════════════════════════
   SISTEMA DE PESTAÑAS (TABS)
   ════════════════════════════════════════════════════════════════════════════════
   Display: none por defecto | Display: flex cuando .active
   Animación: fade-up (subida suave con opacidad)
   Función JS: window.showTab(id, btn) - Muestra/oculta tabs
*/
.tab-content {
    display: none;
    animation: fadeUp 0.3s ease;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════════════════════════════════════════
   Fondo: azul oscuro | Texto blanco | Centrado | Margin-top: 2rem
*/
footer {
    background: var(--primary-dark);
    color: #fff;
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    margin-top: 2rem;
}

/* ════════════════════════════════════════════════════════════════════════════════
   TOOLTIP DEL ESTADO
   ════════════════════════════════════════════════════════════════════════════════
   Mostrado al pasar mouse sobre mapa/imagen del estado
   Fondo: azul oscuro | Texto blanco | Posición: fixed (sigue mouse)
   Función JS: window.mostrarTooltip(), window.ocultarTooltip()
*/
.estado-tooltip {
    position: fixed;
    background: var(--primary-dark);
    color: #fff;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    z-index: 1000;
    pointer-events: none;  /* No interfiere con clics */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 200px;
}

.tooltip-content {
    line-height: 1.6;
}

.tooltip-content strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 0.4rem;
}

.tooltip-content div {
    margin: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
}

.tooltip-label {
    opacity: 0.8;
}

.tooltip-value {
    font-weight: 600;
    color: var(--primary-teal);
}

/* ════════════════════════════════════════════════════════════════════════════════
   MODAL - Overlay y contenedor
   ════════════════════════════════════════════════════════════════════════════════
   Overlay: Fondo oscuro semi-transparente | Centrado vertical y horizontal
   Display: none por defecto | Display: flex cuando está activo
   Función JS: window.mostrarDetallesEstado(), window.cerrarModalEstado()
*/
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);  /* Fondo oscuro transparente */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.modal-overlay.active {
    display: flex;
}

/* Contenedor principal del modal */
.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-estado {
    max-width: 650px;
}

/* Encabezado del modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-light);
    background: linear-gradient(90deg, rgba(0,48,87,0.05) 0%, rgba(0,142,151,0.05) 100%);
}

.modal-header h2 {
    color: var(--primary-dark);
    font-size: 1.2rem;
    margin: 0;
}

/* Botón cerrar (X) */
.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--border-light);
    color: var(--primary-dark);
}

/* Contenido del modal */
.modal-body {
    padding: 1.5rem;
}

/* Secciones dentro del modal */
.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--primary-dark);
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #eee;
}

/* Grid de estadísticas dentro del modal */
.modal-stat {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-stat-item {
    padding: 0.8rem;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 3px solid var(--primary-teal);
}

.modal-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.modal-stat-value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Lista dentro del modal */
.modal-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.modal-list li {
    padding: 0.6rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8rem;
    color: var(--text-main);
}

.modal-list li:last-child {
    border-bottom: none;
}

.modal-list strong {
    color: var(--primary-teal);
}