:root {
    --bg-dark: #0f1115;
    --panel-bg: rgba(22, 26, 32, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f2f5;
    --text-secondary: #a0aabf;
    --accent: #3b82f6;
    
    /* Risk Colors */
    --risk-extreme: #ef4444;
    --risk-high: #f97316;
    --risk-medium: #eab308;
    --risk-low: #22c55e;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    overflow: hidden;
}

/* Map Container */
#map {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: var(--bg-dark);
}

/* Vignette Overlay for Map Edges */
.vignette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: radial-gradient(circle at calc(50% + 170px) center, transparent 15%, rgba(15, 17, 21, 1) 75%);
    z-index: 500;
}

/* Override Leaflet controls for dark theme */
.leaflet-control-zoom a {
    background-color: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--panel-border) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.leaflet-control-zoom a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Overlays */
.overlay-container {
    position: absolute;
    z-index: 1000;
    pointer-events: none; /* Let map clicks through where there's no panel */
}

.left-panel {
    top: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 320px;
}

.bottom-right {
    bottom: 32px;
    right: 24px;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    pointer-events: auto; /* Re-enable pointer events for the panels themselves */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Header */
.header-panel h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, #a0aabf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Stats */
.stats-panel h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.text-danger { color: var(--risk-extreme); }
.text-warning { color: var(--risk-medium); }

.divider {
    height: 1px;
    background: var(--panel-border);
    margin: 20px 0;
}

/* District Details */
.stats-panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.district-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    min-height: 22px;
}

.district-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0.5; /* Default state when no district is hovered */
    transition: opacity 0.3s ease;
}

.district-stats.active {
    opacity: 1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.stat-row span:last-child {
    font-weight: 600;
}

/* District List */
.active-district {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.district-list-container {
    display: flex;
    flex-direction: column;
    max-height: 200px; /* limits height so it's scrollable */
}

.district-list-header {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.district-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar for district list */
.district-list::-webkit-scrollbar {
    width: 4px;
}
.district-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.district-list::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 2px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}
.list-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
.list-item.active {
    background: rgba(255, 255, 255, 0.1);
    border-left: 2px solid var(--accent);
}

.list-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
.district-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.badge-kota {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-kab {
    background-color: rgba(160, 170, 191, 0.15);
    color: #a0aabf;
    border: 1px solid rgba(160, 170, 191, 0.2);
}

.list-item-name {
    color: var(--text-primary);
}
.list-item-cases {
    font-weight: 600;
}

/* Legend */
.legend-panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.risk-extreme { background-color: var(--risk-extreme); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
.risk-high { background-color: var(--risk-high); box-shadow: 0 0 10px rgba(249, 115, 22, 0.5); }
.risk-medium { background-color: var(--risk-medium); box-shadow: 0 0 10px rgba(234, 179, 8, 0.5); }
.risk-low { background-color: var(--risk-low); box-shadow: 0 0 10px rgba(34, 197, 94, 0.5); }

/* Custom Leaflet Tooltip */
.leaflet-tooltip.dark-tooltip {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}
.leaflet-tooltip.dark-tooltip::before {
    border-top-color: var(--panel-border);
}

/* Permanent District Labels */
.leaflet-tooltip.district-label {
    background: transparent;
    border: none;
    box-shadow: none;
    color: rgba(255, 255, 255, 0.9);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 11px;
    text-shadow: 0px 0px 4px rgba(0, 0, 0, 0.8), 0px 0px 8px rgba(0, 0, 0, 0.8);
    pointer-events: none !important;
}
.leaflet-tooltip.district-label::before {
    display: none;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.pulsing-path {
    animation: pulse 2s infinite;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #map {
        position: relative;
        width: 100vw;
        height: 45vh;
        flex-shrink: 0;
    }

    .vignette-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 45vh;
        background: radial-gradient(circle at center, transparent 15%, rgba(15, 17, 21, 1) 90%);
    }

    .overlay-container {
        position: relative;
    }

    .left-panel {
        top: 0;
        left: 0;
        width: 100vw;
        height: 55vh;
        background-color: var(--bg-dark);
        padding: 16px;
        margin: 0;
        overflow-y: auto;
    }
    
    .glass-panel {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 8px 4px;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        pointer-events: auto;
    }

    .district-list-container {
        max-height: none;
    }

    .bottom-right {
        display: none; /* Hide legend on mobile to save space */
    }
    
    .header-panel h1 {
        font-size: 20px;
    }
}
