/* Custom scrollbars for side panels */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #e2e8f0; /* slate-200 */
    border-radius: 4px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #1e293b; /* slate-800 */
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1; /* slate-300 */
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #334155; /* slate-700 */
}

/* Custom pulsing fire marker */
.pulse-marker {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-ring {
    border: 3px solid #f97316; /* brand-orange */
    border-radius: 50%;
    height: 100%;
    width: 100%;
    position: absolute;
    animation: marker-pulse 1.8s ease-out infinite;
    opacity: 0;
}

.incident-badge {
    background: #f97316; /* brand-orange */
    border: 2px solid #ffffff;
    border-radius: 50%;
    height: 24px;
    width: 24px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.incident-badge-large {
    background: #ef4444; /* brand-red for large fires */
    height: 32px;
    width: 32px;
    font-size: 14px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* Larger pulsing ring for bigger/contained fires */
.pulse-ring-large {
    border-color: #ef4444;
}

@keyframes marker-pulse {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Override Leaflet controls styling for Light theme integration */
.leaflet-bar {
    border: 1px solid #cbd5e1 !important; /* slate-300 */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05) !important;
}

.leaflet-bar a {
    background-color: #ffffff !important;
    color: #475569 !important; /* slate-600 */
    border-bottom: 1px solid #e2e8f0 !important;
    transition: all 0.2s;
}

.leaflet-bar a:hover {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

.leaflet-container {
    background-color: #f1f5f9 !important; /* slate-100 */
    font-family: inherit !important;
}

/* Dark Theme overrides for Leaflet controls */
.dark .leaflet-bar {
    border: 1px solid #1e293b !important;
}

.dark .leaflet-bar a {
    background-color: #0f172a !important;
    color: #cbd5e1 !important;
    border-bottom: 1px solid #1e293b !important;
}

.dark .leaflet-bar a:hover {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

.dark .leaflet-container {
    background-color: #020617 !important;
}

/* Custom MarkerCluster Styling overrides */
.marker-cluster-small {
    background-color: rgba(249, 115, 22, 0.2) !important;
}
.marker-cluster-small div {
    background-color: rgba(249, 115, 22, 0.75) !important;
    color: #ffffff !important;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

.marker-cluster-medium {
    background-color: rgba(245, 158, 11, 0.25) !important;
}
.marker-cluster-medium div {
    background-color: rgba(245, 158, 11, 0.8) !important;
    color: #ffffff !important;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

.marker-cluster-large {
    background-color: rgba(239, 68, 68, 0.3) !important;
}
.marker-cluster-large div {
    background-color: rgba(239, 68, 68, 0.85) !important;
    color: #ffffff !important;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

/* Custom Leaflet popup design - Light Theme */
.leaflet-popup-content-wrapper {
    background-color: #ffffff !important;
    color: #334155 !important; /* slate-700 */
    border: 1px solid #e2e8f0;
    border-radius: 8px !important;
    padding: 2px !important;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1) !important;
}

.leaflet-popup-tip {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0;
}

.leaflet-popup-close-button {
    color: #94a3b8 !important; /* slate-400 */
    top: 6px !important;
    right: 6px !important;
}

.leaflet-popup-close-button:hover {
    color: #475569 !important;
}

/* Custom Leaflet popup design - Dark Theme */
.dark .leaflet-popup-content-wrapper {
    background-color: #0f172a !important;
    color: #cbd5e1 !important;
    border: 1px solid #1e293b;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3) !important;
}

.dark .leaflet-popup-tip {
    background-color: #0f172a !important;
    border: 1px solid #1e293b;
}

.dark .leaflet-popup-close-button {
    color: #64748b !important;
}

.dark .leaflet-popup-close-button:hover {
    color: #cbd5e1 !important;
}

/* FEMA Alert Glow Animation */
@keyframes fema-glow {
    0%, 100% {
        border-color: rgba(239, 68, 68, 0.35);
        box-shadow: 0 0 6px rgba(239, 68, 68, 0.15);
    }
    50% {
        border-color: rgba(239, 68, 68, 0.85);
        box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
    }
}

.fema-pulse-card {
    animation: fema-glow 2.5s infinite ease-in-out;
}

/* Leaflet Map Legend Styling */
.info.legend {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #1e293b !important; /* slate-800 */
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.5;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    max-width: 220px;
}

.dark .info.legend {
    background-color: rgba(15, 23, 42, 0.9) !important;
    color: #f1f5f9 !important; /* slate-100 */
    border: 1px solid #334155;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3) !important;
}

.info.legend h4 {
    margin: 0 0 6px 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
}

.dark .info.legend h4 {
    color: #94a3b8;
}

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

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

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

.legend-color-box {
    width: 16px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.15);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.15);
}

/* Layer Control UI Overrides */
.leaflet-control-layers {
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    color: #1e293b !important;
    font-family: inherit !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    padding: 6px 10px !important;
}

.dark .leaflet-control-layers {
    background-color: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid #334155 !important;
    color: #cbd5e1 !important;
}

.leaflet-control-layers-toggle {
    width: 32px !important;
    height: 32px !important;
    background-size: 16px 16px !important;
}

/* Tooltip Bubble CSS */
.tooltip-bubble {
    position: absolute;
    z-index: 99999;
    background-color: rgba(255, 255, 255, 0.98);
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    font-size: 11px;
    line-height: 1.5;
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    pointer-events: none;
    backdrop-filter: blur(8px);
}

.dark .tooltip-bubble {
    background-color: rgba(15, 23, 42, 0.98);
    color: #cbd5e1;
    border: 1px solid #334155;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.tooltip-bubble.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dynamic Grid Layout & Panel Transitions */
#app-layout {
    display: grid;
    grid-template-columns: 360px 1fr 380px;
    transition: grid-template-columns 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

#app-layout.left-collapsed {
    grid-template-columns: 0px 1fr 380px;
}

#app-layout.right-collapsed {
    grid-template-columns: 360px 1fr 0px;
}

#app-layout.left-collapsed.right-collapsed {
    grid-template-columns: 0px 1fr 0px;
}

aside, section {
    min-width: 0;
    overflow: hidden;
    transition: opacity 300ms ease, visibility 300ms ease, border-color 300ms ease;
}

aside.collapsed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border-right-color: transparent !important;
}

section.collapsed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    border-left-color: transparent !important;
}

/* Media query cutoff for tablet / mobile viewports (< 1024px) */
@media (max-width: 1023.98px) {
    #app-layout {
        grid-template-columns: 1fr !important;
        position: relative;
    }
    
    aside, section {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 1010;
        width: 320px;
        max-width: 80vw;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
        transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease, visibility 300ms ease;
    }
    
    aside {
        left: 0;
        border-right: 1px solid rgba(0, 0, 0, 0.1);
        transform: translateX(0);
    }
    
    aside.collapsed {
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
    }
    
    section {
        right: 0;
        border-left: 1px solid rgba(0, 0, 0, 0.1);
        transform: translateX(0);
    }
    
    section.collapsed {
        transform: translateX(100%);
        opacity: 0;
        visibility: hidden;
    }
}

