/* ========================================
   MAPA Y LEYENDAS
   ======================================== */
#map {
    width: 100%;
    flex: 1; 
    height: auto !important; 
}

.map-legend {
    position: absolute;
    bottom: 4vh; 
    left: 1.5vw;
    background: white;
    padding: 0.8rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.15);
    z-index: 800;
    font-family: 'Roboto', sans-serif;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.legend-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
}

.legend-items {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.legend-color {
    width: 3rem; 
    height: 1.25rem;
}

.legend-label {
    font-size: 0.7rem;
    color: #444;
    font-weight: 400;
    white-space: nowrap;
}


.ui-panel {
    position: absolute;
    top: 10vh; 
    right: 2vw;
    
    width: 45vw;            
    max-width: 60rem; 
    min-width: 22rem;       
    max-height: 85vh; 
    
    overflow-y: auto; 
    overflow-x: hidden;
    
    border-radius: 1.5rem;     
    background: rgba(98, 119, 112, 0.5);
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px); 
    box-shadow: 0 1.5rem 3.75rem rgba(0,0,0,0.22); 
    z-index: 800;           
    padding: 1rem; 
    color: #0f172a;

    scrollbar-width: thin;
    scrollbar-color: rgba(254, 255, 255, 0.781) rgba(255, 255, 255, 0.1);
}

.ui-panel::-webkit-scrollbar {
    width: 8px; 
}

.ui-panel::-webkit-scrollbar-track {
    background: transparent; 
    margin: 1rem 0; 
}

.ui-panel::-webkit-scrollbar-thumb {
    background-color: rgba(98, 119, 112, 0.6); 
    border-radius: 20px; 
    border: 2px solid transparent;
    background-clip: content-box;
}

.ui-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(98, 119, 112, 0.9); 
}

.ui-panel.hidden { display: none; }

.ui-close {
    position: absolute;
    top: 0.6rem; 
    right: 0.8rem;
    background: transparent;
    border: 0;
    font-size: 2rem;   
    cursor: pointer;
    color: inherit;     
}

.ui-panel .popup-card { 
    width: 100%;
    padding: 0.6rem 0.4rem;
}

.popup-title {
    font-size: 1.5rem;
    margin: 0.4rem 0.4rem 0.8rem;
    text-align: center;
}
.section {
    background: #f3f4f6;           
    border-radius: 0.9rem;
    margin: 0.6rem 0.4rem;
    overflow: hidden;               
    border: 1px solid #e5e7eb;      
}

.section summary {
    list-style: none;             
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    font-weight: 600;
}

.section summary::-webkit-details-marker { display: none; }

.section .chev { 
    transition: transform 0.45s ease; 
    font-size: 1.5rem;
}
.section[open] .chev { transform: rotate(180deg); }

.section-body { padding: 0.6rem 0.9rem 0.9rem; }

/* Badges */
.badge {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.6rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.6rem;
    font-size: 0.75rem;
    padding: 0 0.5rem;
    gap: 0.4rem;
    text-align: center;
}

.badge .key { opacity: 0.6; }
.badge.is-empty { display: none; }

.feature-selected {
    stroke: rgb(255, 0, 0) !important;      
    stroke-width: 5 !important;
    filter: drop-shadow(0 0 0.4rem rgba(37,99,235,0.25));
}


.solar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.solar-card {
    border-radius: 1rem;       
    padding: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 0.1rem 0.25rem rgba(0,0,0,0.05);
}

.solar-icon {
    width: 2.5rem; 
    height: 2.5rem;
    flex-shrink: 0; 
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.solar-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0; 
}

.solar-label {
    font-size: 0.85rem;
    color: #444;
    margin-bottom: 0.25rem;
    line-height: 1.2;
    text-align: center;
}

.solar-value-box {
    background-color: var(--color-primario-light);
    color: white;
    padding: 0.4rem 0.25rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    width: 90%; 
    display: block;
    margin: 0 auto; 
}


.icono-alerta {
    width: 15%; 
    height: auto;
    margin-top: 1rem;
}

.panel1 {
    background: #e5d3a6; 
    border: 2px solid rgb(201, 190, 159); 
    border-radius: 0.75rem; 
    padding: 2rem; 
    margin: 1.25rem 0;
    display: flex;
    flex-direction: column; 
    align-items: center;    
    justify-content: center;            
    text-align: center;   
    font-size: 0.9rem;
}


.summary-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-grow: 1; 
}

.header-img {
    display: none;       
    height: 3rem;        
    width: auto;         
    object-fit: contain;
    margin-left: auto;   
    margin-right: 1rem;  
    transition: all 0.3s ease;
}

.section[open] .header-img {
    display: block;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-0.6rem); }
    to { opacity: 1; transform: translateX(0); }
}



/* Tabletas y móviles grandes */
@media (max-width: 768px) {
    .map-legend {
        bottom: 3vh;
        left: 2vw;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        max-width: 90%; 
    }
    
    .legend-header h3 { font-size: 0.8rem; }
    .legend-color { width: 2rem; height: 0.75rem; } 
    .legend-label { font-size: 0.65rem; }

    .ui-panel {
        width: 60vw;
        top: 12vh;
    }
}

@media (max-width: 480px) {
    .ui-panel {
        width: 95vw;
        right: 2.5vw; 
        top: 15vh;
        max-height: 75vh;
    }

    .map-legend {
        bottom: 12vh; 
        left: 2vw;
        padding: 0.5rem;
        flex-direction: column; 
        align-items: flex-start;
        gap: 0.4rem;
        width: auto;
        max-width: 50vw; 
    }

    .legend-header h3 {
        font-size: 0.75rem;
        margin-bottom: 0.2rem;
    }

    .legend-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr); 
        gap: 0.4rem 0.6rem; 
        width: 100%;
    }

    .legend-item {
        flex-direction: row; 
        align-items: center;
        gap: 0.25rem;
    }

    .legend-color {
        width: 0.8rem; 
        height: 0.8rem; 
        border-radius: 0.15rem;
    }

    .legend-label {
        font-size: 0.65rem;
        white-space: nowrap; 
    }
}

@media (max-width: 400px) {
    .solar-grid { grid-template-columns: 1fr; }
}