/* --- Leyenda de Leaflet --- */
.leaflet-control-container .leaflet-legend {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    line-height: 20px;
    margin-right: 60px;
}

.leaflet-legend h4 {
    margin: 0 0 5px;
    font-size: 1rem;
    font-weight: 700;
}

.leaflet-legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.85;
}

.leaflet-legend .legend-label {
    font-size: 0.9rem;
}

.leaflet-legend strong {
    display: inline-block;
    width: 50px;
}

/* --- Estilos para Tooltip y Popup de Leaflet --- */
.leaflet-tooltip {
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    color: var(--text-color);
    font-family: var(--font-family);
    padding: 6px 10px;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    font-size: 0.9rem; /* Reduced font size */
    line-height: 1.4;   /* Adjusted line height */
    margin: 10px;
}

.leaflet-popup-content .popup-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.95em; /* Slightly smaller than the main popup text */
}

.leaflet-popup-content .popup-table th,
.leaflet-popup-content .popup-table td {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.leaflet-popup-content .popup-table th {
    font-weight: 700;
    text-align: left;
}

.leaflet-popup-content .popup-table td:last-child {
    text-align: right;
    font-weight: 500;
}

.leaflet-popup-content .popup-table tr:last-child td {
    border-bottom: none;
}

.leaflet-popup-content .popup-table i {
    margin-right: 5px;
}

/* --- Custom Tooltip --- */
.custom-tooltip {
    position: absolute;
    background-color: var(--text-color);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.85em;
    white-space: nowrap;
    z-index: 1010; /* Above leaflet controls */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none; /* So it doesn't interfere with mouse events */
}

.custom-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Tooltip Arrow */
.custom-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%; /* Arrow on the left */
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--text-color) transparent transparent;
}

/* --- Estilos de Resaltado Interactivo --- */
.legend-item.highlighted,
.legend-item:hover {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
    border-radius: 3px; /* Para que el outline se vea mejor */
    cursor: pointer;
}

.map-feature-highlight {
    weight: 2.5;
    color: '#2c3e50';
}

/* --- Estilo Unificado para Controles del Mapa (Opción 1) --- */

/* 1. Contenedor de controles para espaciado */
/* Se eliminan los estilos de flexbox para usar el posicionamiento por defecto de Leaflet */
.leaflet-top.leaflet-right .leaflet-control {
    margin-top: 10px;
    margin-right: 10px;
}

/* 2. Estilo y tamaño para los botones individuales y de barra */
.leaflet-control-zoom a,
.leaflet-control-layers-toggle,
.leaflet-control-custom {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    background-color: white;
    color: #333;
    text-align: center;
    text-decoration: none;
    display: block;
}

.leaflet-control-zoom a:hover,
.leaflet-control-layers-toggle:hover,
.leaflet-control-custom:hover {
    background-color: #f4f4f4;
}

/* 3. Contenedores de Leaflet (unificar sombras y bordes) */
.leaflet-control-zoom,
.leaflet-control-layers,
.leaflet-control-custom {
    box-shadow: 0 1px 5px rgba(0,0,0,0.4) !important;
    border-radius: 5px !important;
    border: none !important;
}

/* 4. Ajustes específicos */

/* Control de Zoom (+/-) */
.leaflet-control-zoom {
    overflow: hidden;
}
.leaflet-control-zoom a {
    font-size: 1.6rem;
    font-weight: 600;
}
.leaflet-control-zoom-in {
    border-bottom: 1px solid #ccc !important;
}

/* Control de Capas */
.leaflet-control-layers-toggle {
    background-size: 22px 22px !important;
    background-position: center !important;
}



/* Control Custom (Leyenda) */
.leaflet-control-custom i {
    font-size: 1.3rem;
    vertical-align: middle;
}

.legend-info-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

.legend-info-btn:hover {
    color: var(--text-color);
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 0.9em;
    line-height: 1.6;
}

.leaflet-popup-content h3 {
    color: var(--primary-color);
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 10px;
}

.leaflet-popup-content .section-title {
    font-weight: 700;
    color: #004085;
    margin-top: 1rem;
    font-size: 1em;
    margin-bottom: 0.5rem;
}

.leaflet-popup-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaflet-popup-content li {
    padding: 0.25rem 0;
}

.leaflet-popup-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.leaflet-popup-content a:hover {
    text-decoration: underline;
}

.leaflet-legend .legend-info-btn i {
    background-color: transparent !important;
    border-radius: 50% !important;
    width: 18px !important;
    height: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 18px !important; /* to vertically center the icon */
}

/* Elimina el contorno azul al hacer clic en un polígono del mapa */
.leaflet-interactive:focus {
  outline: none;
}
