* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
}

.container {
    display: flex;
    height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 300px;
    background: #16213e;
    padding: 20px;
    overflow-y: auto;
    color: #fff;
}

.sidebar h2 {
    margin-bottom: 20px;
    color: #00d4ff;
    font-size: 1.2em;
}

.layer-control {
    margin-bottom: 15px;
    padding: 12px;
    background: #0f3460;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.layer-control:hover {
    background: #1a4d7a;
    transform: translateX(5px);
}

.layer-control label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9em;
}

.layer-control input {
    margin-right: 10px;
    cursor: pointer;
}

.opacity-control {
    margin-top: 20px;
    padding: 15px;
    background: #0f3460;
    border-radius: 8px;
}

.opacity-control label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.opacity-control input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.refresh-btn {
    width: 100%;
    padding: 12px;
    background: #00d4ff;
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: #00a8cc;
    transform: scale(1.02);
}

.date-info {
    margin-top: 15px;
    padding: 10px;
    background: #0f3460;
    border-radius: 8px;
    font-size: 0.85em;
    text-align: center;
}

/* ========== MAPA ========== */
#map {
    flex: 1;
    height: 100vh;
    position: relative;
}

/* Asegurar que las capas del mapa sean visibles */
.leaflet-tile-pane {
    opacity: 1 !important;
}

.leaflet-overlay-pane {
    opacity: 1 !important;
}

/* ========== CANVAS DE VIENTO - COMPLETAMENTE TRANSPARENTE ========== */
#windCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 600;
    /* CRÍTICO: Sin background, completamente transparente */
    background: transparent !important;
    opacity: 1;
}

/* ========== CONTROLES DE ANIMACIÓN ========== */
.animation-controls {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 33, 62, 0.95);
    padding: 15px 25px;
    border-radius: 12px;
    color: #fff;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.animation-controls.active {
    display: block;
}

.control-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.control-btn {
    background: #00d4ff;
    color: #1a1a2e;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.control-btn:hover {
    background: #00a8cc;
    transform: scale(1.05);
}

.control-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.timeline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeline-bar {
    flex: 1;
    height: 6px;
    background: #0f3460;
    border-radius: 3px;
    position: relative;
    cursor: pointer;
}

.timeline-progress {
    height: 100%;
    background: #00d4ff;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

.timeline-text {
    font-size: 0.85em;
    color: #00d4ff;
    min-width: 120px;
    text-align: center;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85em;
}

.speed-btn {
    background: #0f3460;
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s;
}

.speed-btn:hover {
    background: #1a4d7a;
}

.speed-btn.active {
    background: #00d4ff;
    color: #1a1a2e;
}

/* ========== INFO BOXES ========== */
.info-box {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(22, 33, 62, 0.95);
    padding: 15px;
    border-radius: 8px;
    color: #fff;
    z-index: 1000;
    max-width: 250px;
    font-size: 0.85em;
}

.info-box h3 {
    color: #00d4ff;
    margin-bottom: 8px;
    font-size: 1em;
}

.wind-legend {
    position: relative; /* CAMBIO: relative para que sea parte del flujo */
    /* Eliminar top, bottom, right - ya está dentro del contenedor */
    background: rgba(22, 33, 62, 0.98);
    padding: 12px 15px;
    border-radius: 10px;
    border: 2px solid #00d4ff;
    box-shadow: 
        0 4px 20px rgba(0, 212, 255, 0.4),
        0 0 40px rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(10px);
    color: #fff;
    z-index: auto; /* Ya no necesita z-index específico */
    font-size: 0.85em;
    display: none;
    max-width: 100%; /* Usar todo el ancho del contenedor */
    animation: legendSlideIn 0.4s ease-out;
    flex-shrink: 0; /* No comprimir */
    margin-top: 0; /* El gap del contenedor ya maneja el espacio */
}

.wind-legend.active {
    display: block;
}

.wind-legend h4 {
    margin: 0 0 10px 0;
    color: #00d4ff;
    font-size: 14px;
    font-weight: 700;
    border-bottom: 2px solid rgba(0, 212, 255, 0.4);
    padding-bottom: 6px;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.wind-legend div {
    margin: 5px 0;
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 12px;
    color: #e8f4f8;
    transition: background 0.2s;
}

.wind-legend div:hover {
    background: rgba(0, 212, 255, 0.15);
}

/* ========== LEYENDA ========== */
.legend {
    margin-top: 20px;
    padding: 15px;
    background: #0f3460;
    border-radius: 8px;
}

.legend h3 {
    color: #00d4ff;
    margin-bottom: 10px;
    font-size: 1em;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85em;
}

.legend-color {
    width: 30px;
    height: 20px;
    margin-right: 10px;
    border-radius: 3px;
}

/* ========== SCROLLBAR PERSONALIZADO ========== */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #0f3460;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #00d4ff;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #00a8cc;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
    }
    
    #map {
        height: 60vh;
    }
    
    .animation-controls {
        width: 90%;
        padding: 10px 15px;
    }
    
    .control-buttons {
        flex-wrap: wrap;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ========== FILTROS PARA CAPAS SATELITALES - ESTILO GOES/SERVIR ========== */
/* Aplicar colores tipo radar meteorológico similar a SERVIR.net */

/* Filtro general para mejorar contraste de capas */
.leaflet-tile-pane .leaflet-layer {
    filter: contrast(1.2) saturate(1.4) brightness(1.05);
}

/* Clases específicas para capas satelitales (aplicadas desde JavaScript) */
.satellite-ir-style {
    /* Estilo infrarrojo tipo GOES - colores azul/verde/amarillo/rojo */
    filter: contrast(1.6) saturate(2.2) brightness(1.15) hue-rotate(180deg) !important;
}

.satellite-precip-style {
    /* Estilo precipitación - realzar colores de radar */
    filter: contrast(1.5) saturate(2.0) brightness(1.2) !important;
}

.satellite-clouds-style {
    /* Estilo nubes - mejorar contraste y visibilidad */
    filter: contrast(1.4) saturate(1.6) brightness(1.1) !important;
}

/* ========== FILTROS PARA CAPAS OPENWEATHERMAP ========== */

/* Capa de NUBES - Cambiar color */
.clouds-layer {
    /* OPCIÓN 1: Nubes más intensas (blanco brillante) */
    filter: contrast(1.4) brightness(1.3) saturate(1.2) !important;
    
    /* OPCIÓN 2: Nubes azuladas (descomentar para probar)
    filter: contrast(1.3) brightness(1.1) hue-rotate(200deg) saturate(1.5) !important;
    */
    
    /* OPCIÓN 3: Nubes rojizas/anaranjadas (descomentar para probar) 
    filter: contrast(1.3) brightness(1.2) hue-rotate(330deg) saturate(3.0) !important;
    */
    
    /* OPCIÓN 4: Nubes verdosas (descomentar para probar)
    filter: contrast(1.3) brightness(1.1) hue-rotate(90deg) saturate(1.3) !important;
    */
}

/* Capa de PRECIPITACIÓN - Realzar colores */
.precipitation-layer {
    /* Colores más intensos para precipitación */
    filter: contrast(1.5) saturate(1.8) brightness(1.15) !important;
}

/* Capa de TEMPERATURA - Colores más vivos */
.temperature-layer {
    /* Colores de temperatura más intensos */
    filter: contrast(1.4) saturate(1.6) brightness(1.1) !important;
}

/* ========== LEYENDAS DINÁMICAS TIPO VENTANA EMERGENTE ========== */

.dynamic-legends-container {
    position: fixed; /* CAMBIO: fixed en lugar de absolute */
    top: 140px;
    right: 10px;
    bottom: 20px; /* NUEVO: Límite inferior */
    z-index: 900;
    pointer-events: auto; /* CRÍTICO: Cambiar a auto para permitir scroll */
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 250px;
    width: 250px;
    /* CRÍTICO: Usar height automático con límites top y bottom */
    overflow-y: auto; /* Scroll vertical cuando sea necesario */
    overflow-x: hidden; /* Sin scroll horizontal */
    padding-right: 5px; /* Espacio para scrollbar */
}

/* Scrollbar personalizado para leyendas */
.dynamic-legends-container::-webkit-scrollbar {
    width: 8px; /* Un poco más ancho para facilitar uso */
}

.dynamic-legends-container::-webkit-scrollbar-track {
    background: rgba(15, 52, 96, 0.5);
    border-radius: 4px;
}

.dynamic-legends-container::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.7);
    border-radius: 4px;
}

.dynamic-legends-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 1);
}

.layer-legend {
    background: rgba(22, 33, 62, 0.98);
    border: 2px solid #00d4ff;
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: 
        0 4px 20px rgba(0, 212, 255, 0.4),
        0 0 40px rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    animation: legendSlideIn 0.4s ease-out;
    flex-shrink: 0; /* Evitar que se compriman */
    min-height: fit-content; /* Mantener altura mínima */
}

@keyframes legendSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.layer-legend h3 {
    margin: 0 0 10px 0;
    color: #00d4ff;
    font-size: 14px;
    font-weight: 700;
    border-bottom: 2px solid rgba(0, 212, 255, 0.4);
    padding-bottom: 6px;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.legend-items {
    margin-bottom: 8px;
}

.legend-color-bar {
    height: 20px;
    border-radius: 5px;
    border: 2px solid rgba(0, 212, 255, 0.3);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #a0c4d9;
    margin-top: 4px;
    margin-bottom: 10px;
    font-weight: 600;
}

.legend-detail {
    font-size: 11px;
    color: #e8f4f8;
    line-height: 1.5;
}

.legend-detail div {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    padding: 3px 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.legend-detail div:hover {
    background: rgba(0, 212, 255, 0.15);
}

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

.color-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Responsive para pantallas pequeñas */
@media (max-width: 768px) {
    .dynamic-legends-container {
        position: fixed;
        top: auto;
        bottom: 100px;
        right: 10px;
        left: auto;
        max-width: 240px;
        width: 240px;
        max-height: 50vh; /* Máximo 50% de altura en móviles */
    }
    
    .layer-legend {
        padding: 10px 12px;
    }
    
    .layer-legend h3 {
        font-size: 13px;
    }
    
    .legend-detail {
        font-size: 10px;
    }
    
    .color-dot {
        width: 14px;
        height: 14px;
    }
}
