/**
 * @file home.css
 * Hoja de estilos principal para la vista del mapa.
 * Define la estructura, el layout y la apariencia de los componentes.
 */

/* ==========================================================================
   1. ESTRUCTURA GENERAL Y TIPOGRAFÍA
   ========================================================================== */
body, html {
    height: 100%;
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    background-color: #f4f6f8;
    color: #2c3e50;
    /* Evita que el contenido se oculte detrás de la navbar y el footer fijos */
    padding-top: 56px;
    padding-bottom: 40px;
    box-sizing: border-box;
}

/* ==========================================================================
   2. LAYOUT PRINCIPAL (SIDEBAR Y MAPA)
   ========================================================================== */

/* Contenedor de la barra lateral izquierda */
#sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 300px;
    height: calc(100vh - 96px); /* Altura total menos navbar y footer */
    background: #ffffff;
    padding: 1.5rem;
    border-right: 1px solid #ddd;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    z-index: 1000; /* Asegura que esté por encima del mapa */
}

/* Contenedor del mapa */
#map {
    position: fixed;
    top: 56px;
    left: 300px;
    right: 0;
    bottom: 40px;
    height: auto;
    width: auto;
}

/* ==========================================================================
   3. COMPONENTES PRINCIPALES (NAVBAR, FOOTER, ACORDEÓN)
   ========================================================================== */

/* Se define el color de la navbar personalizada para que coincida con viz3 */
.navbar-custom {
    background-color: #34495e;
}

.navbar-brand, .nav-link, .navbar-text {
    color: #ffffff;
}

.navbar-nav .nav-link:hover {
    color: #ecf0f1;
}

/* Estilo para los botones del acordeón en el sidebar */
.accordion-button {
    background-color: #34495e;
    color: white;
    font-weight: bold;
}
.accordion-button:not(.collapsed) {
    background-color: #2c3e50;
    color: white;
}
.accordion-button:focus {
    box-shadow: none;
    border-color: rgba(0,0,0,.125);
}

footer.custom-footer {
    height: 40px;
    background-color: #34495e; /* Color unificado con la navbar */
    color: #ffffff;
    font-size: 0.9rem;
    z-index: 1001; /* Por encima del sidebar y el mapa */
}


/* ==========================================================================
   4. CONTROLES DEL MAPA (AÑADIDO PARA MAPA.JS)
   ========================================================================== */

/* Estilo para el panel de leyendas */
.map-legend-control {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.map-legend-control h6 {
    margin: 0 0 5px 0;
    font-weight: bold;
    border-bottom: 1px solid #ccc;
    padding-bottom: 3px;
}

.map-legend-control div {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

/* Símbolos para las leyendas */
.legend-symbol-point, .legend-symbol-polygon {
    display: inline-block;
    margin-right: 8px;
    border: 1px solid #555;
}

.legend-symbol-point {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-symbol-polygon {
    width: 16px;
    height: 10px;
    border-radius: 2px;
}

/* Estilo para el botón de reseteo de vista */
.leaflet-control-custom {
    background-color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.leaflet-control-custom svg {
    width: 20px;
    height: 20px;
}

/* Estilo para los popups del mapa */
.map-popup-header {
    background-color: #34495e; /* Color por defecto, sobreescrito en JS */
    font-weight: bold;
    font-size: 14px;
    color: #ffffff;
    padding: 8px 12px;
    /* Redondear solo las esquinas superiores para que coincida con el contenedor */
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.map-popup-body {
    font-size: 13px;
    line-height: 1.5;
    padding: 12px; /* Aumentar el padding para más aire */
}

/* Estilos para cada fila de datos (etiqueta + valor) */
.popup-item {
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex; /* Usar Flexbox para alinear etiqueta y valor */
    flex-wrap: wrap; /* Permitir que el valor pase a la siguiente línea si es largo */
}
.popup-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.popup-label {
    font-weight: bold;
    color: #2c3e50; /* Color oscuro para la etiqueta */
    margin-right: 0.5em; /* Espacio entre la etiqueta y el valor */
}

/* Eliminar el padding por defecto de Leaflet para que nuestro header funcione */
.leaflet-popup-content {
    padding: 0 !important; /* CORRECCIÓN: Se debe anular el padding, no el margin. */
    width: auto !important; /* Asegura que el contenedor se ajuste al contenido. */
}

/* Ajuste para que el contenedor del popup no tenga bordes redondeados que interfieran con nuestro header */
.leaflet-popup-content-wrapper {
    border-radius: 5px; /* Bordes redondeados para todo el popup */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: none;
}

/* Estilo para el botón de cerrar del popup */
.leaflet-popup-close-button {
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-color: rgba(0,0,0,0.2);
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    line-height: 24px;
    text-align: center;
}

/* ==========================================================================


/* ==========================================================================
   5. TIPOGRAFÍA Y ELEMENTOS COMUNES
   ========================================================================== */

/* Espaciado estándar para encabezados */
h1, h2, h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* ==========================================================================
   6. ESTILOS PARA PÁGINAS DE AUTENTICACIÓN (LOGIN, SIGNUP, 404)
   ========================================================================== */

/* Contenedor principal para centrar el contenido */
.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 96px); /* Altura total menos navbar y footer */
    padding: 2rem 0;
}

/* Tarjeta para los formularios */
.auth-card {
    width: 100%;
    max-width: 450px; /* Ancho máximo del formulario */
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    background-color: #ffffff;
    padding: 2rem;
}

/* ==========================================================================
   7. ESTILOS DE COMPONENTES GLOBALES (BOTONES Y ENLACES)
   ========================================================================== */

/* Estilo principal para los botones primarios, usando el color institucional */
.btn-primary {
    background-color: #34495e;
    border-color: #34495e;
    color: #ffffff;
}

/* Efecto hover, focus y active para botones primarios */
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: #2c3e50;
    border-color: #2c3e50;
    color: #ffffff;
}

/* Estilo para los enlaces de texto estándar, usando el color institucional */
a {
    color: #34495e;
    text-decoration: none; /* Opcional: quitar subrayado por defecto */
}

a:hover {
    color: #2c3e50;
    text-decoration: underline; /* Opcional: añadir subrayado al pasar el mouse */
}
