:root {
    --primary: #27ae60;
    --danger: #e63946;
    --warning: #f39c12;
    --bg-dark: #0b0f14;
    --bg-panel: rgba(15, 20, 28, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent-glow: rgba(39, 174, 96, 0.3);
    --font-main: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: #e0e0e0;
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* --- UI OVERLAY --- */
.ui-overlay {
    position: fixed; /* Asegura que cubra la pantalla */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Deja que el mapa respire debajo */
    z-index: 5000; /* Por encima de TODO en Leaflet */
}

.ui-overlay > * {
    pointer-events: auto; /* Elementos internos sí capturan clics */
}

/* --- HEADER / LOGO --- */
.header-mini {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel);
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    z-index: 1010;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.header-mini h1 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: white;
}

.header-mini h1 span {
    color: var(--primary);
}

/* --- TOP CARDS (KPIs) --- */
.top-stats {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 1010;
}

.kpi-card {
    background: var(--bg-panel);
    padding: 12px 20px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    min-width: 140px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    transition: transform 0.3s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.2);
}

.kpi-card small {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #888;
    font-weight: 700;
    margin-bottom: 4px;
}

.kpi-card .val {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
}

.kpi-card.risk-high .val { color: var(--danger); text-shadow: 0 0 10px rgba(230, 57, 70, 0.4); }
.kpi-card.focus .val { color: var(--warning); }

/* --- SIDE PANEL (COLLAPSIBLE) --- */
.side-panel {
    position: absolute;
    left: 20px;
    top: 80px;
    bottom: 120px; /* Espacio para el timeline NASA */
    width: 350px;
    background: var(--bg-panel);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow: hidden;
}

.side-panel.collapsed {
    transform: translateX(-380px);
}

.toggle-panel {
    position: absolute;
    left: 20px;
    top: 80px;
    width: 45px;
    height: 45px;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2000; /* Mucho más alto para asegurar click */
    color: white;
    transition: 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.toggle-panel:hover {
    background: var(--primary);
    transform: scale(1.05);
}

.panel-inner {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 15px;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 5px;
}

/* --- REGLA / TIMELINE --- */
/* --- TABS --- */
.panel-tabs {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    background: rgba(255,255,255,0.02);
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }

/* --- REPORTS --- */
.report-card {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.05);
}

.report-card h5 {
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: #ccc;
    text-transform: uppercase;
}

.report-list {
    list-style: none;
    padding: 0;
}

.report-list li {
    font-size: 0.75rem;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    display: flex;
    justify-content: space-between;
}

.btn-download-report {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: var(--danger);
    border: none;
    color: white;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

/* --- TIMELINE NASA STYLE --- */
.timeline-nasa {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(11, 15, 20, 0.95);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(15px);
    z-index: 2000;
    padding: 10px 20px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* --- TIMELINE NASA FIRMS REPLICA --- */
.timeline-nasa {
    position: absolute;
    bottom: 25px;
    left: 400px; 
    right: 40px;
    background: rgba(11, 15, 20, 0.95);
    border: 1px solid rgba(46, 204, 113, 0.4);
    border-radius: 4px; /* Más cuadrado estilo dash */
    padding: 12px 20px;
    backdrop-filter: blur(15px);
    z-index: 4500;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,1);
    border-left: 4px solid #2ecc71; /* Acento verde NASA */
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.timeline-controls-inner {
    display: flex;
    align-items: center;
    gap: 20px;
}

.timeline-controls button {
    background: #2ecc71;
    color: #0b0f14;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}

.timeline-controls button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(46, 204, 113, 0.6);
}

#current-date-display {
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    font-size: 1.3rem;
    color: #fff;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.timeline-interval-selector {
    display: flex;
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
    padding: 3px;
    border: 1px solid rgba(255,255,255,0.1);
}

.interval-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 6px 15px;
    border-radius: 15px;
    font-size: 0.65rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
}

.interval-btn.active {
    background: #2ecc71;
    color: #0b0f14;
}

.timeline-source {
    font-size: 0.65rem;
    color: #2ecc71;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.timeline-body {
    padding: 5px 0 15px 0;
    position: relative;
}

/* Custom Range Styling (Verde NASA) */
input[type=range]#timeline-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]#timeline-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(46, 204, 113, 0.1);
    border-radius: 3px;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

input[type=range]#timeline-range::-webkit-slider-thumb {
    height: 22px;
    width: 22px;
    border-radius: 50%;
    background: #2ecc71;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -9px;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.8), inset 0 0 5px rgba(255,255,255,0.5);
    border: 2px solid #fff;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    position: relative;
}

.tick {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    opacity: 0.4;
    transition: all 0.3s;
}

.tick.active {
    opacity: 1;
    color: #2ecc71;
}

.tick-mark {
    width: 2px;
    height: 10px;
    background: #888;
    margin-bottom: 5px;
}

.tick.active .tick-mark {
    background: #2ecc71;
    height: 15px;
    box-shadow: 0 0 10px #2ecc71;
}

.tick-label {
    font-size: 0.6rem;
    font-weight: 800;
    white-space: nowrap;
}
/* Catálogo de Capas Expandido */
.layer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.layer-item:hover {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.2);
}

#timeline-range {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.05);
    height: 6px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#timeline-range::-webkit-slider-runnable-track {
    background: linear-gradient(to right, #1a3c26, var(--primary));
    height: 6px;
    border-radius: 3px;
}

#timeline-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 50%;
    margin-top: -5px;
    box-shadow: 0 0 10px var(--primary);
}

.timeline-labels {
    position: absolute;
    width: 100%;
    left: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

/* --- HOTSPOT & CLUSTER ANIMATIONS --- */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.2);
}

.marker-cluster-small div {
    background-color: rgba(230, 57, 70, 0.85); /* Rojo peligro */
    box-shadow: 0 0 15px rgba(230, 57, 70, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(230, 57, 70, 0.9);
    box-shadow: 0 0 20px rgba(230, 57, 70, 0.8);
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.marker-cluster-large div {
    background-color: rgba(230, 57, 70, 1);
    box-shadow: 0 0 30px rgba(230, 57, 70, 0.9);
    width: 44px;
    height: 44px;
    font-size: 16px;
    animation: cluster-pulse 2s infinite;
}

.foco-pulse {
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 15px rgba(230, 57, 70, 1);
}

.foco-recent { 
    background: #e63946; 
    animation: pulse-red 1.5s infinite; 
    box-shadow: 0 0 20px #e63946;
}

.foco-old { 
    background: #f39c12; 
    border-color: rgba(255,255,255,0.5);
    opacity: 0.8;
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.8); }
    70% { transform: scale(1.6); box-shadow: 0 0 0 15px rgba(230, 57, 70, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0); }
}

@keyframes cluster-pulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(230, 57, 70, 0.8); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(230, 57, 70, 0.9); }
    100% { transform: scale(1); box-shadow: 0 0 20px rgba(230, 57, 70, 0.8); }
}

/* --- TOOLBAR --- */
.toolbar-apps {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1050; /* Al mismo nivel que el panel lateral */
}

.app-btn {
    width: 55px;
    height: 55px;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    color: #888;
}

.app-btn.active {
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

.app-btn i { font-size: 1.2rem; }
.app-btn small { font-size: 0.55rem; margin-top: 4px; font-weight: 800; }

/* --- UTILS --- */
.custom-select {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

/* --- SWITCH / TOGGLES --- */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(14px); }

.layer-item {
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid transparent;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}


.btn-prediction:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.coords-display {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.6);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #aaa;
    z-index: 6000;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.05);
}

.layer-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.1);
}

/* --- LEGEND --- */
.map-legend {
    position: absolute;
    bottom: 120px;
    right: 20px;
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    z-index: 6000; /* Asegurar que esté sobre el mapa */
    font-size: 0.75rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    color: #ccc;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.btn-prediction {
    width: 100%;
    background: linear-gradient(45deg, var(--primary), #27ae60);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.75rem;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}