/* style.css - ESTILOS MEJORADOS */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
}

.dashboard {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Estado de proyectos */
.estado {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.estado.en-ejecucion {
    background: #e8f5e9;
    color: #2e7d32;
}

.estado.finalizado {
    background: #fff3e0;
    color: #ef6c00;
}

/* Loading states */
.kpi-loading {
    color: #999 !important;
    font-style: italic;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1200px) {
    .kpi-container { 
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .kpi-container { 
        grid-template-columns: 1fr;
    }
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    .btn-group .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Animaciones para el mapa */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Tooltip mejorado */
.map-tooltip {
    animation: fadeIn 0.2s ease;
    pointer-events: none;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.4;
    border: 1px solid rgba(178, 34, 34, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Leyenda del mapa */
.leyenda-marcadores {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.leyenda-marcadores rect {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Botones específicos */
#btn-toggle-marcadores.active {
    animation: pulse 2s infinite;
    background: linear-gradient(135deg, #2E8B57, #3CB371) !important;
}

/* Select personalizado */
#filtro-marcadores {
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 45px;
}

/* Efectos hover para marcadores */
.punto-proyecto:hover {
    animation: pulse 0.5s ease;
}

/* Estilos para estadísticas */
#estadisticas-marcadores {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

#estadisticas-marcadores:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

/* Modal improvements */
.modal-overlay {
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-overlay h3 {
    color: #228B22;
    font-size: 1.3rem;
    border-bottom: 2px solid #228B22;
    padding-bottom: 10px;
}

.modal-overlay button {
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
}

.modal-overlay button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

/* KPI Colors */
.kpi-card:nth-child(1)::before { background: linear-gradient(90deg, #FF6B6B, #FF8E53); }
.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, #4ECDC4, #44A08D); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, #FFD166, #FF9E6D); }

.kpi-card:nth-child(1) .kpi-icon { color: #FF6B6B; }
.kpi-card:nth-child(2) .kpi-icon { color: #4ECDC4; }
.kpi-card:nth-child(3) .kpi-icon { color: #FFD166; }

/* Heatmap styles */
.heat-point {
    mix-blend-mode: multiply;
}

/* Grid para controles en móvil */
@media (max-width: 768px) {
    .filtro-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        width: 100%;
    }
    
    .btn-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    #btn-toggle-marcadores {
        grid-column: span 2;
    }
}
/* Controles del mapa */
.map-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    width:100%
}

.map-controls {
    display: flex;
    justify-content: flex-end; 
    gap: 8px;
    align-items: center;
     width: 100%;
}

.btn-map-control {
    background: white;
    justify-content: flex-end;
    border: 2px solid #667eea;
    color: #667eea;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.btn-map-control:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-map-control:active {
    transform: translateY(0);
}

.btn-map-control.active {
    background: #667eea;
    color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Contador de zoom */
.zoom-level {
    background: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    color: #667eea;
    border: 2px solid #667eea;
    min-width: 60px;
    text-align: center;
}

/* Animaciones para zoom */
.zoom-transition {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tooltip para controles */
.btn-map-control[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}

.btn-map-control[title] {
    position: relative;
}
/* Contenedor del mapa */
#map-wrapper {
    position: relative;
    width: 100%;
    height: 600px;
}

/* Google Maps */
#google-map {
    width: 100%;
    height: 100%;
    border-radius: 10px;
}


#leaflet-map {
    z-index: 1 !important; /* Leaflet DEBAJO */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: all !important; /* Permitir interacción */
}
/* Capa interactiva */
#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
    cursor: grab;
    z-index: 50;
}

#map-overlay:active {
    cursor: grabbing;
}
/* Agrega esto en la sección <style> del index.html */

/* Estilo para cuando Leaflet está activo */
#leaflet-map.active {
    pointer-events: all !important;
    display: block !important;
    opacity: 1 !important;
    z-index: 5 !important;
}

/* Estilo para cuando Leaflet está inactivo */
#leaflet-map.inactive {
    display: none !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

/* Cuando el mapa base está activo, hacer departamentos muy transparentes */
.base-map-active .departamento {
    fill-opacity: 0.05 !important;
    stroke-opacity: 0.1 !important;
    stroke-width: 0.5 !important;
}
.leaflet-active .departamento {
    fill-opacity: 0.1 !important;
    stroke-opacity: 0.2 !important;
    pointer-events: none !important;
}

.leaflet-active #map {
    pointer-events: none !important;
}
/* Cuando Leaflet está inactivo (modo normal) */
.leaflet-inactive #leaflet-map {
    display: none !important;
}
.leaflet-active .punto-proyecto {
    pointer-events: all !important;
    cursor: pointer !important;
}

/* Botón activo/inactivo */
#btn-toggle-base-map.active {
    background: #4CAF50 !important;
    color: white !important;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3) !important;
}

/* Debug overlay */
.debug-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 5px;
    z-index: 9999;
    font-size: 12px;
}
/* Botón para cambiar tipo de mapa */
#btn-toggle-map-type {
    position: relative;
}

.map-type-menu {
    position: absolute;
    top: 45px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    display: none;
    min-width: 150px;
}

.map-type-menu.active {
    display: block;
}

.map-type-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.map-type-item:last-child {
    border-bottom: none;
}

.map-type-item:hover {
    background: #f8f9fa;
}

.map-type-item.active {
    background: #667eea;
    color: white;
}

/* Opacidad para capas */
.layer-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 101;
}

.layer-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.layer-control:last-child {
    margin-bottom: 0;
}

.layer-control label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.layer-slider {
    width: 100px;
    margin-left: 10px;
}
/* Estilos para nuevos badges */
.badge-organizacion {
    background: #E3F2FD;
    color: #1976D2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-convenio {
    background: #F3E5F5;
    color: #7B1FA2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    font-family: monospace;
}

/* Mejoras para la tabla */
#proyectos-table th:nth-child(2) { /* Columna Organización */
    background: linear-gradient(135deg, #2196F3, #1976D2) !important;
}

#proyectos-table th:nth-child(8) { /* Columna N° Convenio */
    background: linear-gradient(135deg, #9C27B0, #7B1FA2) !important;
}

/* Responsive para tabla */
@media (max-width: 1200px) {
    #proyectos-table {
        font-size: 14px;
    }
    
    .badge-organizacion, .badge-convenio {
        max-width: 150px;
    }
}

@media (max-width: 768px) {
    #proyectos-table_wrapper {
        overflow-x: auto;
    }
    
    .badge-organizacion, .badge-convenio {
        max-width: 120px;
    }
}
/* Estilos para nuevos badges */
.badge-organizacion {
    background: #E3F2FD;
    color: #1976D2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-convenio {
    background: #F3E5F5;
    color: #7B1FA2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    font-family: monospace;
}

/* Mejoras para la tabla */
#proyectos-table th:nth-child(2) { /* Columna Organización */
    background: linear-gradient(135deg, #2196F3, #1976D2) !important;
}

#proyectos-table th:nth-child(8) { /* Columna N° Convenio */
    background: linear-gradient(135deg, #9C27B0, #7B1FA2) !important;
}

/* Responsive para tabla */
@media (max-width: 1200px) {
    #proyectos-table {
        font-size: 14px;
    }
    
    .badge-organizacion, .badge-convenio {
        max-width: 150px;
    }
}

@media (max-width: 768px) {
    #proyectos-table_wrapper {
        overflow-x: auto;
    }
    
    .badge-organizacion, .badge-convenio {
        max-width: 120px;
    }
}
/* Agrega al final de tu style.css o en el <style> del HTML */

/* Estilos para modal de detalles */
.modal-detalles {
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Estilos para tooltips de marcadores */
.map-tooltip {
    animation: tooltipFadeIn 0.2s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cursor pointer para marcadores */
.punto-proyecto {
    pointer-events: all !important;
    cursor: pointer !important;
}

.punto-proyecto:hover {
    animation: pulseMarker 0.5s ease;
}

@keyframes pulseMarker {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Botón en tooltip */
.map-tooltip button {
    transition: all 0.2s ease;
}

.map-tooltip button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* Marcadores HTML */
.marcador-html {
    animation: popIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

.marcador-html:hover {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Tooltip HTML */
.html-tooltip {
    animation: fadeIn 0.2s ease;
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    max-width: 200px;
    text-align: center;
}

/* Asegurar que el overlay esté por encima del SVG */
#map-overlay {
    z-index: 500 !important;
    pointer-events: all !important;
}

/* Deshabilitar eventos en el SVG cuando usamos HTML */
#map {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none !important;
    pointer-events: none !important; /* IMPORTANTE: Solo los marcadores serán interactivos */
}
#map rect.background {
    fill: none !important;
    stroke: none !important;
}
#map-leaflet {
    width: 100%;
    height: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1;
}

.custom-marker {
    background: #667eea;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
}
.cluster-marker {
    background: #FF6B6B;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}