:root {
    --side-width: 380px;
    --primary: #0f172a;
    --accent: #3b82f6;
    --bg-main: #f8fafc;
    --border: #e2e8f0;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --radius: 12px;
}

.traffic-popup h3 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: var(--primary);
}

.traffic-popup p {
    margin: 4px 0;
    font-size: 0.85rem;
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

#map {
    flex: 1;
    z-index: 1;
}

/* Sidebar Styling */
.sidebar {
    width: var(--side-width);
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 2;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
}

header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

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

.logo .icon {
    font-size: 2rem;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo h1 span {
    color: var(--accent);
}

.logo p {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.region-selector {
    margin-top: 16px;
}

#city-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    background-color: var(--bg-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#city-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tabs */
.tabs {
    display: flex;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

/* Content Panels */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

.filter-box {
    margin-bottom: 20px;
}

.filter-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
}

.filter-box input:focus {
    border-color: var(--accent);
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-msg {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 40px;
}

/* Analysis Cards */
.analysis-card {
    background: var(--bg-main);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.analysis-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.analysis-card p {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.5;
}

.btn-toggle {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-toggle.active {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

/* Traffic Time Control */
.traffic-time-control {
    margin-top: 30px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: var(--radius);
}

.time-slider-container {
    padding: 10px 0;
}

#time-slider {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
}

.current-time-badge {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 12px;
    color: var(--accent);
}

/* Traffic Legend Styling */
.traffic-legend {
    margin-top: 24px;
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
}

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

.color-box.jam {
    background-color: #dc2626;
}

.color-box.slow {
    background-color: #f59e0b;
}

.color-box.smooth {
    background-color: #10b981;
}

.color-box.high {
    background-color: #2563eb;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 50%;
    left: calc(var(--side-width) + (100% - var(--side-width)) / 2);
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
}

#loading-overlay p {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Interactive Legend */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    padding: 4px 0;
    transition: opacity 0.2s;
}

.legend-item:hover {
    opacity: 0.8;
}

.legend-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Footer */
footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-main);
}

.data-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.status-dot.online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* Leaflet Overrides */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 4px;
}

.leaflet-popup-content {
    margin: 12px;
    font-family: 'Inter', sans-serif;
}