/* Estilos específicos para la visualización de mapas */

/* Layout del mapa */
.map-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .map-sections {
        grid-template-columns: 1fr;
    }
}

/* Contenedor principal del mapa */
.map-container {
    background-color: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    height: auto;
    min-height: 500px;
}

/* El mapa en sí */
#impact-map {
    width: 100%;
    height: 100%;
    z-index: 1;
    border-radius: var(--radius);
}

/* Estilos para filtros rápidos */
.quick-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    color: var(--text-dark);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: var(--bg-light);
    border-color: var(--primary-color);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Leyenda del mapa - mejor posicionamiento */
.map-legend {
    position: absolute;
    bottom: 60px;
    right: 10px;
    background-color: white;
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    font-size: 0.75rem;
    max-width: 180px;
}

.map-legend h4 {
    margin: 0 0 8px 0;
    font-size: 0.875rem;
    color: var(--text-dark);
}

/* Estadísticas del mapa - mejor posicionamiento */
.map-stats {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    gap: 1rem;
    z-index: 1000;
}

.map-stat {
    background-color: white;
    padding: 8px 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.map-stat i {
    color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.875rem;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.65rem;
}

/* Panel de detalles de ubicación */
.location-detail-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 300px;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.location-detail-panel.visible {
    transform: translateX(0);
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-dark);
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.close-btn:hover {
    background-color: var(--bg-light);
}

.panel-body {
    padding: 1rem;
}

.location-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.meta-item i {
    color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-primary {
    flex: 1;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

/* Estadísticas del mapa */
.map-stats {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.map-stats-card {
    background-color: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.map-stats-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

/* Items de estadísticas */
.stat-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Estadísticas de la región seleccionada */
.selected-region-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.selected-metric {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background-color: var(--bg-light);
    border-radius: var(--radius-sm);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.375rem;
}

.metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* ODS en región seleccionada */
.selected-metric .ods-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.selected-metric .ods-tags .ods-tag {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
}

/* Proyectos por región */
.region-projects {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.no-region-selected {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-style: italic;
}

.region-project-card {
    background-color: var(--bg-light);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    border-left: 4px solid var(--primary-color);
}

.region-project-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.region-project-org {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.region-project-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: auto;
}

.region-project-metric {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-light);
}

.region-project-metric i {
    margin-right: 0.375rem;
    width: 1rem;
    height: 1rem;
}

.region-project-metric strong {
    color: var(--text-dark);
    margin-left: 0.25rem;
}

/* Historias de impacto */
.impact-stories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 1.5rem;
}

.impact-story {
    display: flex;
    background-color: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.story-image {
    width: 160px;
    min-width: 160px;
    overflow: hidden;
    background-color: var(--bg-light);
}

.story-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

.story-placeholder i {
    width: 3rem;
    height: 3rem;
    opacity: 0.5;
}

.story-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.story-content h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.story-content p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    flex: 1;
}

.story-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.story-metric {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dark);
    background-color: var(--bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Personalización de Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    min-width: 200px;
}

.popup-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.popup-content {
    font-size: 0.875rem;
    color: var(--text-dark);
}

.popup-metrics {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.popup-metric {
    font-size: 0.75rem;
    color: var(--text-light);
}

.popup-metric strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.popup-ods {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.popup-ods .ods-tag {
    padding: 0.2rem 0.375rem;
    font-size: 0.7rem;
}

/* Marcadores personalizados para el mapa */
.custom-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: white;
    border: 3px solid;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.custom-marker-icon.education {
    border-color: #3498db;
    color: #3498db;
}

.custom-marker-icon.inclusion {
    border-color: #e74c3c;
    color: #e74c3c;
}

.custom-marker-icon.culture {
    border-color: #9b59b6;
    color: #9b59b6;
}

.custom-marker-icon.biodiversity {
    border-color: #2ecc71;
    color: #2ecc71;
}

/* Regiones en el mapa */
.region-highlight {
    fill: rgba(0, 94, 138, 0.2);
    stroke: #005E8A;
    stroke-width: 2;
    transition: fill 0.3s ease;
}

.region-highlight:hover,
.region-highlight.active {
    fill: rgba(0, 94, 138, 0.4);
    cursor: pointer;
}

/* Clúster de marcadores */
.marker-cluster {
    background-color: rgba(0, 94, 138, 0.6);
    border-radius: 50%;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Asegurar que el contenedor del mapa sea responsivo */
@media (max-width: 768px) {
    .map-container {
        min-height: 400px;
    }
    
    #impact-map {
        height: 400px !important;
    }
}

/* Estilos para elementos de la leyenda */
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 6px;
}

.legend-label {
    font-size: 0.7rem;
    color: var(--text-dark);
}

/* Mejoras para popups del mapa */
.map-popup {
    font-family: 'Inter', sans-serif;
}

.map-popup h5 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
}

.popup-meta {
    margin-bottom: 8px;
}

.popup-project {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dark);
    font-weight: 500;
}

.popup-region {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
}

.popup-stats {
    margin: 8px 0;
    padding: 6px;
    background-color: var(--bg-light);
    border-radius: 4px;
    text-align: center;
}

.popup-stat .stat-value {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
}

.popup-stat .stat-label {
    font-size: 0.65rem;
    color: var(--text-light);
}

.popup-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    width: 100%;
    margin-top: 6px;
}

.popup-btn:hover {
    background-color: var(--primary-dark);
}

/* Asegurar que el contenedor del mapa sea responsivo */
@media (max-width: 768px) {
    .map-container {
        min-height: 400px;
    }
    
    #impact-map {
        height: 350px !important;
    }
    
    .map-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .map-stat {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    .location-detail-panel {
        width: calc(100% - 20px);
        top: 5px;
        right: 10px;
    }
    
    .quick-filters {
        flex-direction: column;
    }
    
    .filter-btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Iconos de fallback */
.icon-fallback {
    display: inline-block;
    width: 16px;
    height: 16px;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
}

/* Ocultar emojis cuando Feather funciona */
.icon-fallback svg + * {
    display: none;
}

/* Mostrar emojis cuando Feather no funciona */
.icon-fallback:not(:has(svg)):before {
    content: attr(title);
    font-size: 14px;
}

/* Asegurar que el contenedor del mapa sea responsivo */
@media (max-width: 768px) {
    .map-container {
        min-height: 400px;
    }
    
    #impact-map {
        height: 350px !important;
    }
    
    .map-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .map-stat {
        padding: 6px 8px;
        font-size: 0.7rem;
    }
    
    .location-detail-panel {
        width: calc(100% - 20px);
        top: 5px;
        right: 10px;
    }
    
    .quick-filters {
        flex-direction: column;
    }
    
    .filter-btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .icon-fallback {
        font-size: 11px;
    }
}
