/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #1f2937;
    --darker-bg: #111827;
    --text-light: #f3f4f6;
    --text-dark: #1f2937;
    --sidebar-bg: rgba(31, 41, 55, 0.95);
    --card-bg: rgba(255, 255, 255, 0.98);
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-light);
    overflow: hidden;
    height: 100vh;
    position: relative;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    z-index: 1000;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.navbar-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-light);
}

.logo i {
    color: #3b82f6;
    font-size: 32px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo-text {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-right {
    display: flex;
    gap: 15px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.report-btn {
    background: linear-gradient(135deg, #b81414, #e96629);
    color: white;
}

.report-btn:hover {
    background: linear-gradient(135deg, #e96629, #b3480b);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 7, 7, 0.4);
}

.ngo-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.ngo-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.govt-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.govt-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    width: 350px;
    height: calc(100vh - 70px);
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    padding: 25px;
    overflow-y: auto;
    z-index: 900;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header i {
    color: #3b82f6;
}

.sidebar-section {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #93c5fd;
}

/* ===== AQI Legend ===== */
.legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.legend-item:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: translateX(5px);
}

.legend-color {
    width: 15px;
    height: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.legend-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.legend-label {
    font-weight: 600;
    font-size: 14px;
}

.legend-range {
    font-size: 12px;
    color: #9ca3af;
}

/* ===== Sidebar Buttons ===== */
.sidebar-btn {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.sidebar-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
}

.sidebar-btn i {
    font-size: 16px;
}

/* ===== City List Widget ===== */
.city-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.city-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.city-item:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: translateX(5px);
}

.city-name {
    font-weight: 500;
    font-size: 14px;
}

.city-aqi {
    font-weight: 700;
    font-size: 18px;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
}

/* AQI Color Classes */
.aqi-good { 
    border-left-color: #00e400; 
    color: #00e400;
}
.aqi-satisfactory { 
    border-left-color: #ffff00; 
    color: #ffff00;
}
.aqi-moderate { 
    border-left-color: #ff7e00; 
    color: #ff7e00;
}
.aqi-poor { 
    border-left-color: #ff0000; 
    color: #ff0000;
}
.aqi-very-poor { 
    border-left-color: #8f3f97; 
    color: #8f3f97;
}
.aqi-severe { 
    border-left-color: #7e0023; 
    color: #7e0023;
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: #9ca3af;
}

.sidebar-footer p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.sidebar-footer i {
    color: #60a5fa;
}

/* ===== Map Container ===== */
#map {
    position: fixed;
    top: 70px;
    left: 350px;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.leaflet-container {
    background: #1a1a2e;
}

/* ===== Custom Marker Styles ===== */
.custom-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: relative;
    transform: rotate(-45deg);
}

@keyframes bounce {
    0%, 100% { transform: rotate(-45deg) translateY(0); }
    50% { transform: rotate(-45deg) translateY(-10px); }
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-overlay.hidden {
    display: none;
}

.loader-container {
    text-align: center;
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-container p {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1100;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: linear-gradient(135deg, var(--dark-bg), var(--darker-bg));
    color: white;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.close-modal {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    max-height: calc(90vh - 100px);
    overflow-y: auto;
}

/* ===== Compare Grid ===== */
.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.compare-card {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid;
    text-align: center;
    transition: all 0.3s ease;
}

.compare-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.compare-city-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.compare-aqi-value {
    font-size: 48px;
    font-weight: 700;
    margin: 15px 0;
}

.compare-aqi-label {
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    display: inline-block;
    color: white;
}

/* ===== Trends Modal ===== */
.trends-modal .modal-content {
    max-width: 1100px;
}

.trends-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.trend-select {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.trend-select:hover {
    border-color: #3b82f6;
}

.trend-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#trendChart {
    max-height: 400px;
}

/* ===== Toggle Sidebar Button (Mobile) ===== */
.toggle-sidebar {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.toggle-sidebar:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

/* ===== Leaflet Popup Customization ===== */
.leaflet-popup-content-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.popup-header {
    background: linear-gradient(135deg, var(--dark-bg), var(--darker-bg));
    color: white;
    padding: 15px;
    font-weight: 600;
}

.popup-body {
    padding: 15px;
}

.popup-aqi {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin: 10px 0;
}

.popup-category {
    text-align: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    color: white;
    margin-bottom: 10px;
}

.popup-details {
    font-size: 13px;
    color: #6b7280;
    margin-top: 10px;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    #map {
        left: 0;
    }
    
    .toggle-sidebar {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 15px;
        height: 60px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .logo i {
        font-size: 24px;
    }
    
    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .nav-btn span {
        display: none;
    }
    
    .sidebar {
        width: 300px;
        top: 60px;
        height: calc(100vh - 60px);
        padding: 20px;
    }
    
    #map {
        top: 60px;
    }
    
    .compare-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .navbar-right {
        gap: 8px;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .sidebar-section {
        padding: 15px;
    }
}