/* ==========================================
   VARIABLES Y CONFIGURACIÓN GENERAL
   ========================================== */
:root {
    --background: #F3F2EE;
    --panel: #FFFFFF;
    --text: #2F3437;
    --green: #6F7F63;
    --blue: #7C94A3;
    --sand: #D8C9A5;
    --border: #E5E2DA;
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
    
    /* Colores del semáforo de potencial competitivo */
    --pot-muy-alto: #2E7D32;
    --pot-alto: #7CB342;
    --pot-medio: #D8C9A5;
    --pot-bajo: #F57C00;
    --pot-muy-bajo: #C62828;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
}

/* ==========================================
   HEADER / TOPBAR
   ========================================== */
.topbar {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 30px 60px;
    background: white;
    box-shadow: var(--shadow);
}

.logo img {
    height: 90px;
    display: block;
}

.titulo h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
}

.titulo p {
    margin-top: 6px;
    font-size: 18px;
    color: #666;
}

/* ==========================================
   CARDS (KPIs y Selectores superiores)
   ========================================== */
.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    padding: 35px 60px;
}

.card {
    background: white;
    border-radius: 14px;
    padding: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.card h3 {
    font-size: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: 12px;
    font-weight: 600;
}

.card h2 {
    font-size: 38px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.card span {
    font-size: 13px;
    color: #666;
}

.card select {
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background-color: #fafafa;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.card select:focus {
    border-color: var(--blue);
}

/* ==========================================
   LAYOUT PRINCIPAL (Mapa + Sidebar)
   ========================================== */
.layout {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 25px;
    padding: 0 60px 60px;
}

/* Sección de Mapa + Buscador */
.map-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toolbar {
    width: 100%;
}

/* Contenedor relativo que controla el ancho del input y su menú desplegable */
.search-container {
    position: relative;
    width: 70%;
    max-width: 700px;
}

.search-container input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    outline: none;
    box-shadow: var(--shadow);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.search-container input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(124, 148, 163, 0.15);
}

.mapa {
    height: 650px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 1; /* Evita solapamientos con capas del mapa */
}

/* Barra Lateral (Sidebar) */
aside {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.panel {
    background: white;
    border-radius: 14px;
    padding: 25px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-height: 310px;
}

.panel h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.panel-content {
    font-size: 14px;
    color: #555;
}

/* Formato para el gran número del Ranking */
#rankingPanel h2 {
    font-size: 54px;
    font-weight: 800;
    color: var(--green);
    line-height: 1;
    margin-bottom: 8px;
}

#rankingPanel p {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

/* ==========================================
   COMPONENTES DE DATOS (Ficha técnica y badges)
   ========================================== */
.tablaInfo {
    width: 100%;
    border-collapse: collapse;
}

.tablaInfo td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0edf5;
    font-size: 13.5px;
}

.tablaInfo tr:last-child td {
    border-bottom: none;
}

.tablaInfo td:first-child {
    color: #777;
    font-weight: 500;
    width: 45%;
}

.tablaInfo td:last-child {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

/* Badges dinámicos para los potenciales en tablas */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 6px;
    color: white;
}

/* ==========================================
   LEYENDA DE LEAFLET (Inyectada desde JS)
   ========================================== */
.info.legend {
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 14px 18px !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
    min-width: 190px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    border: 1px solid var(--border);
}

.info.legend h4 {
    margin: 0 0 10px 0;
    font-size: 13.5px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%; /* Círculos perfectos para colegios */
    display: inline-block;
    margin-right: 10px;
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.legend-icon-rect {
    width: 14px;
    height: 14px;
    background-color: var(--green);
    margin-right: 10px;
    display: inline-block;
    flex-shrink: 0;
}

/* ==========================================
   ELEMENTOS DINÁMICOS Y BUSCADOR
   ========================================== */
.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ranking-item:hover {
    background: #f4f7fb;
}

#resultadosBusqueda {
    position: absolute;
    top: 100%; /* Se despliega exactamente debajo del input */
    left: 0;
    width: 100%; /* Toma el mismo ancho dinámico del contenedor */
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 999;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 5px; /* Pequeño margen estético de separación */
}

/* Badge estilizado para identificar los escenarios E1 y E2 */
.badge-escenario {
    display: inline-block;
    background-color: var(--blue);
    color: white;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Contenedor individual para cada explicación */
.escenario-info {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

.escenario-info:hover {
    transform: scale(1.01);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* ==========================================
   MEDIA QUERIES (Responsividad)
   ========================================== */
@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 0 30px 30px;
    }
    
    .topbar {
        padding: 25px 30px;
    }
    
    .cards {
        padding: 25px 30px;
        grid-template-columns: repeat(2, 1fr);
    }

    .panel {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    /* En pantallas móviles se expande el buscador para un uso táctil cómodo */
    .search-container {
        width: 100%;
        max-width: none;
    }

    .cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .topbar {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }

    .titulo h1 {
        font-size: 28px;
    }

    .titulo p {
        font-size: 15px;
    }

    .logo img {
        height: 70px;
    }

    .mapa {
        height: 450px; /* Menor tamaño en dispositivos pequeños */
    }
 
}
@media (max-width: 768px) {

    .search-container {
        width: 100%;
        max-width: none;
    }

    .cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .topbar {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }

    .titulo h1 {
        font-size: 28px;
    }

    .titulo p {
        font-size: 15px;
    }

    .logo img {
        height: 70px;
    }

    .mapa {
        height: 450px;
    }

} /* ← Cierra aquí el @media */

/* ==========================================
   FOOTER
========================================== */

.footer{
    margin-top:40px;
    padding:25px 20px;
    background:#243447;
    color:#ffffff;
    text-align:center;
    font-size:14px;
}

.footer strong{
    color:#ffffff;
}

.footer-content{
    max-width:1200px;
    margin:auto;
}
.dashboard-summary{

    margin-top:40px;
    padding:30px;

}

.kpi-grid{

    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:20px;
    margin-bottom:30px;

}

.kpi-card{

    background:#fff;

    border-radius:12px;

    padding:25px;

    text-align:center;

    box-shadow:0 3px 10px rgba(0,0,0,.08);
    
    .kpi-card{

    padding:18px;

}

}

.kpi-value{

    font-size:2rem;

    font-weight:700;

    color:#2F3437;

      font-size:2.3rem;

}

.kpi-label{

    display:block;

    margin-top:10px;

    color:#666;

    margin-top:5px;

}

.charts-grid{

    display:grid;

    grid-template-columns:1fr 1fr;

    gap:25px;

}

.chart-card{

    background:white;

    border-radius:12px;

    padding:20px;

    box-shadow:0 3px 10px rgba(0,0,0,.08);

    height:340px;

}

.chart-card canvas{

    width:100% !important;

    height:260px !important;

}

/* Ajuste estético para el control de norte */
.leaflet-north-arrow {
    margin-top: 10px !important;
    margin-left: 10px !important;
}