body {
    margin: 0;
    font-family: Arial, sans-serif;
}
h1 {
    text-align: center;
    margin: 10px 0;
}

/* Barra horizontal principal header*/
#header {
    background: #1565c0;
    color: #fff;
    padding: 12px 24px 0 24px;
    box-sizing: border-box;
    width: 100%;
    position: relative;
    z-index: 2000;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.header-logos-container {
    display: flex;
    align-items: center;
    gap: 16px;
}
.header-logo {
    height: 36px;
    width: auto;
    margin: 0;
    display: block;
}
.header-logo-cortolima {
    height: 58px;
    background: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-nav {
    display: flex;
    gap: 12px;
}

.nav-btn {
    background: #fff;
    color: #1565c0;
    border: none;
    border-radius: 4px;
    padding: 8px 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.nav-btn:hover {
    background: #1976d2;
    color: #fff;
}

.header-title-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
}
.header-title {
    font-size: 2.2rem;
    text-align: center;
    width: 100%;
    margin: 0;
}

/* Responsive menú principal */
@media (max-width: 700px) {
    .header-nav {
        flex-direction: column;
        align-items: flex-start;
        padding: 0 8px;
    }
    .nav-btn {
        font-size: 0.95em;
        padding: 6px 12px;
        margin: 4px 0;
        width: 100%;
        min-width: unset;
        box-sizing: border-box;
    }
    #menu-capas {
        left: 0 !important;
        right: 0 !important;
        width: 98vw !important;
        max-width: 98vw !important;
        min-width: unset !important;
        font-size: 0.97em;
    }
    .menu-section-title {
        font-size: 1em;
        padding: 8px 0 8px 4px;
    }
    .menu-section-content label {
        font-size: 0.97em;
        padding-left: 8px;
    }
    .header-title {
        font-size: 1.1em;
        margin-left: 8px;
    }
    .header-logo {
        max-width: 65px;
        height: auto;
    }
    .header-logo-cortolima {
        max-width: 90px;
        height: auto;
        padding: 2px 8px;
    }
    .header-logos-container {
        gap: 8px;
    }
}

/* Ocultar título en móviles con orientación vertical */
@media (max-width: 700px) and (orientation: portrait) {
    .header-title {
        display: none !important;
    }
    .header-row {
        position: relative;
        justify-content: flex-start !important;
    }
    /* Posicionar el botón hamburguesa en la derecha */
    .nav-hamburger {
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    /* El nav no debe ocupar espacio visible en el header-row */
    .header-nav {
        width: 0 !important;
        height: 0 !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }
    /* Ocultar los botones del nav (pero no afectar el menu-capas) */
    .header-nav > .nav-btn {
        display: none !important;
    }
}

/* Estilos para la capa municipios */
.leaflet-tooltip.custom-muni-tooltip {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}





/* ocultar el panel lateral en móviles */
@media (max-width: 700px) {
    #lateral-panel {
        display: none;
    }
}

/* Oculta el botón hamburguesa en escritorio */
.nav-hamburger {
    background: #fff;
    color: #1565c0;
    border: none;
    font-size: 2em;
    padding: 4px 8px;      /* Menos padding horizontal */
    cursor: pointer;
    border-radius: 6px;
    margin-right: 8px;
    width: 44px;           /* Fijo y cuadrado */
    height: 44px;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}



/* Responsive para menos de 1280px */
@media (max-width: 1280px) {
    #header {
        padding: 12px 8px 0 8px;
    }
    .header-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px; /* Espacio entre logo, título y hamburguesa */
    }
    .header-logos-container {
        gap: 10px;
    }
    .header-logo {
        height: 30px;
        max-width: 90px;
        margin-bottom: 4px;
    }
    .header-logo-cortolima {
        height: 50px;
        max-width: 120px;
        padding: 2px 8px;
    }
    .nav-hamburger {
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        font-size: 2em;
        margin-bottom: 4px;
        margin: 0;
    }
    .header-title-row {
        margin-top: 8px;
    }
    .header-title {
        font-size: 1.3rem;
        margin: 0 auto;
        text-align: center;
        width: 100%;
        margin-bottom: 4px;
        margin-top: 0;
    }
    .header-nav {
        flex-direction: column;
        align-items: flex-start;
        padding: 0 8px;
    }
}

/* Oculta el botón hamburguesa en escritorio (1280px o más) */
@media (min-width: 1280px) {
    .header-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 24px;
    }
    .header-logos-container {
        gap: 16px;
    }
    .header-logo {
        height: 36px;
        max-width: 130px;
    }
    .header-logo-cortolima {
        height: 58px;
        padding: 3px 10px;
    }
    .header-title {
        flex: 1 1 auto;
        font-size: 2.2rem;
        text-align: center;
        margin: 0 24px;
        white-space: nowrap;
    }
    .header-nav {
        display: flex;
        flex-direction: row;
        gap: 12px;
        align-items: center;
        justify-content: flex-end;
        width: auto;
        padding: 0;
    }
    .nav-hamburger {
        display: none !important;
    }
}

/* Solo muestra el botón hamburguesa en menos de 1280px */
@media (max-width: 1280px) {
    .header-nav .nav-btn:not(.nav-hamburger) {
        display: none !important;
    }
    .nav-hamburger {
        display: flex !important;
    }
}



/* Estilos para la sección de menu */

.menu-section-content {
    display: none;
    margin-bottom: 8px;
    padding-left: 8px;
}
.menu-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    color: #1976d2;
    margin-bottom: 6px;
    font-size: 1.08em;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
    transition: background 0.2s;
    white-space: nowrap;
    gap: 8px;
}
.menu-section-title::after {
    content: '▼';
    font-size: 0.9em;
    transition: transform 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
}
.menu-section-title.collapsed::after {
    transform: rotate(-90deg);
}
.menu-section-content.active {
    display: block;
}

/* Estilos del menu lateral */
.menu-capas {
    position: absolute;
    right: 0;
    top: 48px;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    padding: 12px 18px;
    z-index: 1002;
    min-width: 220px;
    max-width: 96vw;      /* Limita el ancho máximo al 96% de la pantalla */
    width: 320px;         /* Ancho base */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-x: auto;     /* Permite scroll horizontal si es necesario */
    word-break: break-word; /* Evita desbordes de texto */
}
.menu-capas label {
    display: block;         /* Cada opción ocupa toda la línea */
    font-size: 1rem;
    color: #1565c0;
    cursor: pointer;
}
.menu-capas input[type="checkbox"] {
    margin-right: 8px;
}
/* Ajuste extra para pantallas pequeñas */
@media (max-width: 600px) {
    .menu-capas {
        left: 2vw;
        right: 2vw;
        width: 96vw;
        min-width: unset;
        max-width: 98vw;
        padding: 10px 4vw;
        font-size: 0.97em;
    }
    .menu-section-title {
        font-size: 1em;
        padding: 8px 0 8px 4px;
        white-space: normal; /* Permite que el texto y la flecha hagan wrap si es necesario */
    }
}

/* Estilos para el footer */
#footer {
    width: 100%;
    background: #1565c0;
    color: #fff;
    position: fixed;
    left: 0;
    bottom: 0;
    height: 56px;
    display: flex;
    align-items: center;
    z-index: 20;
    box-sizing: border-box;
    padding: 0 24px;
}
.footer-logos {
    display: flex;
    align-items: center;
    gap: 18px;
}
.footer-logos img {
    height: 58px;
    width: auto;
    display: block;
}
@media (max-width: 600px) {
    #footer {
        height: 44px;
        padding: 0 8px;
    }
    .footer-logos img {
        height: 24px;
    }
}



/* Estilos para el mapa y el panel lateral */

#map {
    position: absolute;
    top: 60px; /* Igual a la altura del header */
    left: 0;
    bottom: 56px; /* Igual a la altura del footer */
    width: 67vw;
    z-index: 0;
}
#lateral-panel {
    position: fixed; /* Fixed to allow hover effect */
    top: 60px; /* AJustado para coincidir con el header */
    right: 0; /* Siempre visible sin animaciones */
    width: 33vw;
    height: calc(100vh - 116px); /* Ajustado para header + footer */
    background: #f9f9f9;
    border-left: 2px solid #bbb;
    padding: 20px;
    box-sizing: border-box;
    z-index: 1000;
    overflow-y: auto;
}

@media (max-width: 768px) {
    #lateral-panel {
        display: none; /* Oculto en móviles */
    }
   #map {
        width: 100%; /* Full width for the map */
        height: calc(100vh - 104px); /* header + footer móvil */
        bottom: 44px;
    }
}

.info-control {
    padding: 8px;
    background: white;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    opacity: 0.7;
}

.cursor-info-control {
    padding: 5px;
    background: white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    font-size: 12px;
}

/* Ajustes de estilo para los controles personalizados */

.leaflet-control-custom:hover {
    background: #e0e0e0 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}

.search-suggestion-box {
    z-index: 4000 !important;
}

.leaflet-top,
.leaflet-control-container .leaflet-top {
    margin-top: 24px; /* Ajusta el valor según lo que necesites */
}

.leaflet-bottom.leaflet-left {
    margin-bottom: 80px; /* Ajusta el valor según lo que necesites */
}

.leaflet-bottom.leaflet-right {
    margin-bottom: 80px; /* Sube el grupo de controles desde abajo (ajusta el valor a tu gusto) */
    margin-right: 36px;   /* Corre un poco a la izquierda (ajusta el valor a tu gusto) */
}

/* Centra verticalmente el infoControl en la barra izquierda de Leaflet */
.leaflet-top.leaflet-left {
    height: 100%;
}
.leaflet-top.leaflet-left .info-control {
    position: absolute !important;
    top: 50% !important;
    left: 10px !important;
    transform: translateY(-50%);
    z-index: 1000;
    min-width: 220px;
    max-width: 320px;
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    padding: 12px 18px;
}

/* === OCULTAR CONTROLES EN MÓVILES === */
/* ocultar controles en pantallas pequeñas */
@media (max-width: 768px) {
    /* Controles de escala y coordenadas */
    .leaflet-control-scale,
    .leaflet-control-coordinates,
    #map .leaflet-control-scale,
    #map .leaflet-control-coordinates,
    /* Control de coordenadas específico que muestra "Mueva el cursor" */
    .cursor-info-control,
    #map .cursor-info-control,
    /* Cualquier control en la esquina inferior izquierda */
    #map .leaflet-bottom.leaflet-left {
        display: none !important;
    }
    
    /* También ocultar controles específicos por clase */
    .leaflet-control-custom.cursor-info,
    .leaflet-control[title*="coordenadas"],
    .leaflet-control[title*="cursor"] {
        display: none !important;
    }
}

/* Para tablets en orientación vertical también */
@media (max-width: 1024px) and (orientation: portrait) {
    .leaflet-control-scale,
    .leaflet-control-coordinates,
    #map .leaflet-control-scale,
    #map .leaflet-control-coordinates,
    .cursor-info-control,
    #map .cursor-info-control,
    #map .leaflet-bottom.leaflet-left {
        display: none !important;
    }
    
    .leaflet-control-custom.cursor-info,
    .leaflet-control[title*="coordenadas"],
    .leaflet-control[title*="cursor"] {
        display: none !important;
    }
}

/* Pantallas muy pequeñas - ocultar completamente */
@media (max-width: 480px) {
    #map .leaflet-bottom.leaflet-left,
    #map .leaflet-bottom.leaflet-right .leaflet-control-scale,
    #map .leaflet-control-container .leaflet-control {
        display: none !important;
    }
}

/* Posición exacta para control de coordenadas */
.cursor-info-control {
    position: fixed !important;
    bottom: 70px !important;
    left: 5px !important;
    z-index: 1000 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
    border: 1px solid rgba(0,0,0,0.2) !important;
    margin: 0 !important;
}

/* Posición exacta para control de escala */
.leaflet-control-scale {
    position: fixed !important;
    bottom: 100px !important;  /* Encima del control de coordenadas */
    left: 5px !important;
    z-index: 1000 !important;
    margin: 0 !important;
}

/* === CONTROLES DE ZOOM, HOME Y SHARE LINK === */
/* Ajustar posición exacta para todos los controles superior izquierdo */
.leaflet-control-container .leaflet-top.leaflet-left {
    top: -15px !important;
    left: 8px !important;
}

/* Control de zoom específico */
.leaflet-control-zoom {
    margin: 0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

/* Controles personalizados (home y share) */
.leaflet-control-custom {
    margin: 0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

/* Espacio entre controles de zoom y los botones personalizados */
.leaflet-control-zoom + .leaflet-control-custom {
    margin-top: 4px !important;
}

/* Input de búsqueda también más arriba */
.leaflet-control-zoom input[type="text"] {
    margin-top: 0 !important;
}

/* Caja de sugerencias también ajustada */
.search-suggestion-box {
    top: 32px !important; /* Ajustar según la nueva posición */
}

/* === RESPONSIVE === */
/* En móviles, mover un poco más hacia abajo para no chocar con el header */
@media (max-width: 768px) {
    .leaflet-control-container .leaflet-top.leaflet-left {
        top: 15px !important;
        left: 8px !important;
    }
}