/* Estilos generales */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    padding-top: 80px; /* Para el header fijo */
    padding-bottom: 80px; /* Espacio para el footer fijo */
    box-sizing: border-box;
    overflow: hidden; /* Evita el scroll en el body */
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-color: #007D3A;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.hamburger-button {
    display: none; /* Oculto por defecto en escritorio */
    position: absolute;
    left: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

header h1 {
    margin: 0;
    text-align: center;
    font-size: 24px;
}

/* Contenedor principal */
#main {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Sidebar */
#sidebar {
    width: 400px;
    background-color: #E7E6E6;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
    z-index: 1001;
}

/* Contenedor del campo de búsqueda y botón */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

#codigoBusqueda {
    flex-grow: 1;
    border: 1px solid #ccc;
    padding: 10px;
    padding-right: 35px; 
    border-radius: 5px 0 0 5px;
    margin: 0;
}

#botonBuscar {
    padding: 10px 15px;
    border: none;
    background-color: #007D3A;
    color: white;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
    transition: background-color 0.2s;
    z-index: 2;
}

#botonBuscar:hover {
    background-color: #005a2b;
}

#botonLimpiar {
    position: absolute;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 18px;
    padding: 0 5px;
    z-index: 2;
    display: none;
}

#botonLimpiar:hover {
    color: #333;
}

/* Estilos del acordeón */
.accordion {
    margin-top: 15px;
    border-top: 1px solid #ccc;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background-color: #007D3A;
    color: white;
    padding: 10px;
}

.accordion-header h2 {
    font-size: 18px;
    margin: 0;
}

.accordion-header i {
    transition: transform 0.2s;
}

.accordion-content {
    display: none;
    flex-direction: column;
    background-color: #E7E6E6;
    padding: 10px;
}

.accordion.active .accordion-content {
    display: flex;
}

.accordion.active .accordion-header i {
    transform: rotate(180deg);
}

/* Estilos de las tarjetas de capa */
.layer-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 10px;
    padding: 10px;
}

.layer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.layer-header label {
    font-weight: bold;
    display: flex;
    align-items: center;
}

.layer-header input {
    margin-right: 8px;
}

.layer-actions {
    display: flex;
    align-items: center;
}

.layer-actions i {
    cursor: pointer;
    color: #3fb7dc;
    margin-left: 12px;
    font-size: 16px;
}

.layer-actions i:hover {
    color: #007D3A;
}

.layer-description {
    font-size: 14px;
    color: #666;
    margin: 0;
    padding-left: 26px;
}

.empty-category {
    color: #888;
    font-style: italic;
}

.busqueda-en-tarjeta {
    margin-top: 10px;
}

/* Contenedor del control de mapa base sobre el mapa */
#base-map-control-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    padding: 5px;
    display: flex;
}

.base-map-button {
    padding: 8px 12px;
    cursor: pointer;
    border: none;
    background-color: #fff;
    color: #333;
    font-size: 14px;
    border-right: 1px solid #ccc;
}

.base-map-button:last-child {
    border-right: none;
}

.base-map-button.active {
    background-color: #007D3A;
    color: white;
}

.base-map-button:hover:not(.active) {
    background-color: #f4f4f4;
}

/* Mapa */
#map {
    flex-grow: 1;
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-color: #007D3A;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

footer p {
    margin: 0;
    text-align: center;
}

/* Popups de Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: 5px;
}
.leaflet-popup-content {
    max-height: 200px;
    overflow-y: auto;
}


/* Posicionamiento de controles Leaflet */
.leaflet-top.leaflet-right {
    top: 10px;
}

.leaflet-bottom.leaflet-left {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    pointer-events: none;
}

.leaflet-control-scale {
    pointer-events: auto;
    margin-bottom: 70px;
    z-index: 1002;
}

/* Indicador de carga */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: none; /* Oculto por defecto */
    justify-content: center;
    align-items: center;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #007D3A;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Contenedor de notificaciones */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.notification {
    background-color: #333;
    color: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateX(100%);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background-color: #28a745;
}

.notification.error {
    background-color: #dc3545;
}

.notification.info {
    background-color: #17a2b8;
}

/* Control de Coordenadas */
#coords-container {
    position: absolute;
    bottom: 13px; /* Movido 3px hacia arriba */
    right: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85); /* Más opaco */
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4); /* Sombra para resaltar */
    display: flex;
    align-items: center;
    font-family: Arial, sans-serif;
}

#coords-display {
    padding: 0 8px;
    font-size: 12px;
    min-width: 180px; /* Ancho mínimo para que no se mueva tanto */
    text-align: center;
}

#coords-selector {
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
}


/* Media Queries para Responsividad */
@media (max-width: 768px) {
    .hamburger-button {
        display: block;
    }

    header h1 {
        font-size: 18px;
        margin-left: 40px; /* Espacio para el botón */
    }

    #sidebar {
        position: fixed;
        top: 80px; /* Debajo del header */
        left: 0;
        height: calc(100% - 160px); /* Altura completa menos header y footer */
        width: 300px; /* Ancho del sidebar en móvil */
        transform: translateX(-100%);
        box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    }

    #sidebar.visible {
        transform: translateX(0);
    }

    #map {
        width: 100%;
    }
    
    /* Aumentar tamaño de botones para uso táctil */
    .base-map-button, #botonBuscar {
        padding: 12px 16px;
    }

    footer p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 16px;
    }

    #sidebar {
        width: 280px; /* Un poco más angosto en pantallas muy pequeñas */
    }

    .accordion-header h2 {
        font-size: 16px;
    }
}