/* ===== CSS VARIABLES ===== */
:root {
    --primary-dark: #0f172a;
    --primary-blue: #0f2557;
    --bg-gray: #f3f4f6;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-gray);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== HEADER ===== */
header {
    background-color: var(--primary-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    background: rgba(255,255,255,0.15);
    padding: 8px;
    border-radius: 8px;
    display: flex;
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-text p {
    font-size: 0.75rem;
    opacity: 0.7;
    font-weight: 500;
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    background: rgba(255,255,255,0.1);
    padding: 0.25rem;
    border-radius: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.tab-btn.active {
    background: white;
    color: var(--primary-blue);
}

/* City Selector */
.city-container {
    position: relative;
}

.city-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.city-btn:hover {
    background: rgba(255,255,255,0.2);
}

.city-menu {
    display: none;
    position: absolute;
    top: 120%;
    right: 0;
    background: white;
    color: #1f2937;
    width: 200px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 8px;
    z-index: 50;
    border: 1px solid #e5e7eb;
}

.city-menu.show {
    display: block;
}

.city-menu input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.city-option {
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.city-option:hover {
    background: #f3f4f6;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-container {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid #fff;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.yellow { background: #fffbeb; color: #d97706; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }

.stat-info h3 {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

.stat-info .sub {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
    margin-left: 4px;
}

/* Main Content Split */
.content-split {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ===== MAP SECTION ===== */
.map-wrapper {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    position: relative;
    border: 4px solid white;
    height: 100%;
    min-height: 400px;
}

#map {
    height: 100%;
    width: 100%;
    background: #e5e7eb;
}

.map-overlay-label {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 400;
}

.map-overlay-label h4 {
    font-size: 0.95rem;
    font-weight: 800;
    color: #1f2937;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-overlay-label span {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
}

.legend {
    position: absolute;
    bottom: 25px;
    right: 25px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 400;
    width: 220px;
}

.legend-title {
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 700;
    text-transform: uppercase;
}

.gradient-bar {
    height: 8px;
    background: linear-gradient(to right, #10b981, #f59e0b, #ef4444);
    border-radius: 4px;
    margin-bottom: 6px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #4b5563;
    font-weight: 600;
}

/* Custom Markers */
.custom-marker-bubble {
    background: white;
    border: 3px solid;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    cursor: pointer;
}

.custom-marker-bubble:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

.bubble-val {
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    color: #333;
}

.bubble-label {
    font-size: 7px;
    font-weight: 700;
    text-transform: uppercase;
    color: #666;
    margin-top: 1px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid white;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-label {
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--primary-blue);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Buttons */
.sim-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.sim-btn:hover {
    background: #fef2f2;
}

.sim-btn.active {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* Insight Section */
.insight-section h4 {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-item {
    margin-bottom: 16px;
}

.insight-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #334155;
    font-weight: 600;
}

.insight-status {
    font-weight: 700;
}

.status-high     { color: #dc2626; }
.status-critical { color: #b91c1c; }
.status-med      { color: #d97706; }
.status-low      { color: #10b981; }

.progress-bg {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    width: 0;
    transition: width 1s ease-out;
}

.rec-box {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.rec-box p {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.5;
}

.rec-box strong {
    color: #1e293b;
}

/* ===== ANALYTICS SECTION ===== */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container {
    position: relative;
    height: 250px;
}

/* Zone Pills */
.zone-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.zone-pill {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zone-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.zone-pill.active {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: white;
}

.zone-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Animations */
.heat-glow {
    filter: blur(35px);
    opacity: 0.6;
    animation: pulse 4s infinite;
}

@keyframes pulse {
    0%   { opacity: 0.4; }
    50%  { opacity: 0.7; }
    100% { opacity: 0.4; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .content-split {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
    }
    #map {
        height: 350px;
    }
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    .tab-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}
