/* ============================= */
/*      Variables y Fuentes      */
/* ============================= */
:root {
    /* Colores Institucionales */
    --colorInstitucional1: #235B4E;
    --colorInstitucional2: #10312B;
    --colorInstitucional3: #DDC9A3;
    --colorInstitucional4: #BC955C;
    --colorInstitucional9: #FFFFFF;
    --colorHeaderDark: #691C32;
    --colorHeaderLight: #BC955C;
    --colorFooter: #691C32;
    --colorFooterText: #FFFFFF;
    --colorBotonHover: #8B5E34;
    --colorCentroSalud: #235B4E;
    --colorHospital: #BC955C;
    --colorUneme: #9F2241;
    --colorCaravana: #cccccc;
}

/* Fuentes Institucionales */
@font-face {
    font-family: "Institucional-Light";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Light.otf");
}

@font-face {
    font-family: "Institucional-Regular";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Regular.otf");
}

@font-face {
    font-family: "Institucional-Black";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Black.otf");
}

@font-face {
    font-family: "Institucional-Medium";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Medium.otf");
}

@font-face {
    font-family: "Institucional-Semibold";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Book.otf");
}

@font-face {
    font-family: "Institucional-Bold";
    src: url("https://ibhidalgo.org/cdn/fuentes/Geomanist/Geomanist-Bold.otf");
}

/* ============================= */
/*      Estilos Base             */
/* ============================= */
body {
    font-family: "Institucional-Regular", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--colorInstitucional9);
    color: var(--colorInstitucional2);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============================= */
/*      Estructura de Layout     */
/* ============================= */
.container {
    display: flex;
}

.containerDashboard {
    padding: 0 2%;
}

/* ============================= */
/*      Componentes              */
/* ============================= */
/* Header */
.header-top {
    background-color: var(--colorHeaderDark);
    color: white;
    padding: 1rem;
    border-bottom: 10px solid var(--colorHeaderLight);
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: "Institucional-Bold", Arial, sans-serif;
}

/* Menú móvil */
#mobileMenu {
    background-color: var(--colorHeaderDark);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

/* Footer */
footer {
    width: 100%;
    margin-top: 3vh;
    margin-bottom: 0;
    background-color: var(--colorFooter);
    color: var(--colorFooterText);
    text-align: center;
    padding: 1rem;
    font-family: "Institucional-Semibold", Arial, sans-serif;
    border-radius: 15px 15px 0 0;
    position: static;
}

footer a {
    color: var(--colorFooterText);
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

/* ============================= */
/*      Elementos Interactivos   */
/* ============================= */
/* Botones */
.btn-outline-light {
    border-color: var(--colorInstitucional3);
    color: var(--colorInstitucional3);
    border-radius: 15px;
}

.btn-outline-light:hover {
    background-color: var(--colorInstitucional3);
    color: white;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.pagination button {
    padding: 5px 10px;
    border: none;
    background-color: var(--colorInstitucional1);
    color: white;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
}

.pagination button:disabled {
    background-color: gray;
    cursor: not-allowed;
}

.next {
    background-color: #ffffff;
    border-radius: 15px;
}

.next:active {
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* ============================= */
/*      Mapa y Componentes       */
/* ============================= */
.map {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Regiones del mapa */
.map-dimmed .leaflet-pane > svg path {
    filter: brightness(0.3);
    transition: filter 0.3s ease;
}

.map-dimmed .leaflet-pane > svg path.selected-region {
    filter: none !important;
    z-index: 1000 !important;
}

.selected-region {
    stroke: #9F2241 !important;
    stroke-width: 3px !important;
    z-index: 1000 !important;
}

/* Controles del mapa */
.leaflet-control-container {
    filter: none !important;
    z-index: 1001;
}

/* ============================= */
/*      Búsqueda y Resultados    */
/* ============================= */
#sugerencias {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    max-height: 150px;
    overflow-y: auto;
    width: calc(50% - 40px);
    z-index: 1000;
    display: none;
    border-radius: 5px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

#sugerencias div {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-family: "Institucional-Regular", Arial, sans-serif;
}

#sugerencias div:hover {
    background-color: #f4f4f4;
}

.resultado-busqueda {
    padding: 1rem;
    background: #f9f9f9;
    font-family: "Institucional-Regular", Arial, sans-serif;
}

.resultado-busqueda ul {
    list-style: none;
    padding: 0;
}

.resultado-busqueda li {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #ccc;
}

.resultado-busqueda li:hover {
    background-color: #eee;
}

/* ============================= */
/*      Modo Oscuro              */
/* ============================= */
[data-bs-theme="dark"] {
    /* Estilos generales */
    body {
        background-color: #000000;
        color: #e0e0e0;
    }
    
    /* Botones */
    .btn-outline-light {
        border-color: #666;
        color: #e0e0e0;
    }
    
    .btn-outline-light:hover {
        background-color: #444;
        color: #fff;
    }
    
    /* Mapa */
    #map {
        filter: brightness(0.8) contrast(1.2);
        box-shadow: 0 0px 10px rgba(255, 255, 255);
    }
    
    .leaflet-tile {
        filter: hue-rotate(180deg) invert(70%) brightness(0.6) contrast(1.2);
    }
    
    .leaflet-container {
        background-color: #1a1a1a;
    }
    
    /* Popups y controles */
    .leaflet-popup-content-wrapper,
    .leaflet-popup-tip {
        background-color: #2d2d2df1;
        color: #e0e0e0;
        box-shadow: 0 0px 5px rgba(255, 255, 255);
    }
    
    .leaflet-popup-content-wrapper a {
        color: #4dabf7;
    }
    
    .leaflet-control-layers,
    .leaflet-bar {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }
    
    .leaflet-bar a {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border-bottom: 1px solid #444;
    }
    
    .leaflet-bar a:hover {
        background-color: #3a3a3a;
        color: #fff;
    }
    
    .leaflet-control-attribution {
        background-color: rgba(45, 45, 45, 0.7);
        color: #e0e0e0;
    }
    
    .leaflet-tooltip {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border: 1px solid #444;
    }
    
    .leaflet-tooltip-top:before {
        border-top-color: #2d2d2d;
    }
    
    .leaflet-tooltip-bottom:before {
        border-bottom-color: #2d2d2d;
    }
    
    .leaflet-tooltip-left:before {
        border-left-color: #2d2d2d;
    }
    
    .leaflet-tooltip-right:before {
        border-right-color: #2d2d2d;
    }
    
    /* Leyenda */
    .info.legend {
        background-color: #2d2d2d;
        color: #000000;
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
    }
    
    .legend-toggle {
        color: #000000;
    }
    
    .region-item:hover {
        background-color: #c7c7c7 !important;
    }
}

/* ============================= */
/*      Media Queries            */
/* ============================= */
@media (max-width: 768px) {
    /* Header */
    .logo {
        font-size: 1.2rem;
    }
    
    .header-top {
        padding: 0.8rem;
    }
    
    /* Layout */
    .container {
        flex-direction: column;
    }
    
    .map {
        order: 2;
    }
    
    #map {
        min-height: 70vh;
    }
    
    .filters {
        order: 1;
    }
}