/* =============================================
   National AQI Live-Mapping Terminal
   Stylesheet
   ============================================= */

:root {
    --color-good: #2ecc71;
    --color-satisfactory: #f39c12;
    --color-moderately-polluted: #e74c3c;
    --color-poor: #9b59b6;
    --color-very-poor: #34495e;
    --color-severe: #c0392b;
    
    --sidebar-width: 380px;
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --text-primary: #eaeaea;
    --text-secondary: #bdc3c7;
    --border-color: #0f3460;
    --accent-color: #00d4ff;
}

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-primary);
}

/* Layout */
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.sidebar::-webkit-scrollbar-track {
    background: var(--border-color);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.sidebar-header {
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.sidebar-header .subtitle {
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Info Panel */
.info-panel {
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
}

.last-updated {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.last-updated .label {
    color: var(--text-secondary);
}

.last-updated .timestamp {
    color: var(--accent-color);
    font-weight: bold;
}

/* AQI Legend */
.aqi-legend {
    margin-top: 10px;
}

.aqi-legend h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: var(--accent-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11px;
    padding: 4px 0;
}

.legend-item .color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-item.good .color-box { background-color: var(--color-good); }
.legend-item.satisfactory .color-box { background-color: var(--color-satisfactory); }
.legend-item.moderately-polluted .color-box { background-color: var(--color-moderately-polluted); }
.legend-item.poor .color-box { background-color: var(--color-poor); }
.legend-item.very-poor .color-box { background-color: var(--color-very-poor); }
.legend-item.severe .color-box { background-color: var(--color-severe); }

/* Search Panel */
.search-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-box {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all 0.3s ease;
}

.search-box:focus {
    background: rgba(0, 212, 255, 0.1);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

.search-box::placeholder {
    color: var(--text-secondary);
}

/* City List */
.city-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.city-list::-webkit-scrollbar {
    width: 6px;
}

.city-list::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

.city-item {
    padding: 8px 10px;
    background: rgba(0, 212, 255, 0.05);
    border-left: 3px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.city-item:hover {
    background: rgba(0, 212, 255, 0.15);
    border-left-color: var(--accent-color);
}

.city-item.active {
    background: rgba(0, 212, 255, 0.2);
    border-left-color: var(--accent-color);
}

.city-name {
    font-weight: bold;
    color: var(--text-primary);
}

.city-aqi {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Stats Panel */
.stats-panel {
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-top: auto;
}

.stats-panel h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: var(--accent-color);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item .label {
    color: var(--text-secondary);
}

.stat-item .value {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 14px;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    background: #0a0e27;
}

#map {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 100%);
}

/* Leaflet Customization */
.leaflet-control-attribution {
    background: rgba(26, 26, 46, 0.8) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-attribution a {
    color: var(--accent-color) !important;
}

.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    background: rgba(26, 26, 46, 0.8) !important;
}

.leaflet-control-zoom a {
    color: var(--text-primary) !important;
    background: transparent !important;
    border-right: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(0, 212, 255, 0.2) !important;
}

.leaflet-control-zoom a:last-child {
    border-right: none !important;
}

/* City Info Card - Hover Dashboard Tooltip */
.city-info-card {
    position: fixed;
    width: 380px;
    max-height: 420px;
    background: rgba(26, 26, 46, 0.98);
    backdrop-filter: blur(10px);
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    padding: 20px;
    display: none;
    z-index: 1000;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(0, 212, 255, 0.2);
    animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
}

.city-info-card.active {
    display: block;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.city-info-card.top-aligned {
    animation: slideInDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    color: var(--accent-color);
    font-size: 22px;
    font-weight: bold;
    transition: all 0.2s ease;
}

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

#info-city-name {
    font-size: 22px;
    margin-bottom: 4px;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
    font-weight: 700;
    letter-spacing: 0.5px;
}

#info-city-state {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}

/* AQI Display - Main Metric */
.aqi-display {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(0, 212, 255, 0.05) 100%);
    border: 1px solid var(--accent-color);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.aqi-display::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(0, 212, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

#info-aqi-value {
    font-size: 48px;
    font-weight: 900;
    color: var(--accent-color);
    margin-bottom: 6px;
    text-shadow: 
        0 0 10px rgba(0, 212, 255, 0.3),
        0 0 20px rgba(0, 212, 255, 0.1);
    animation: fadeInScale 0.4s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#info-aqi-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

/* Tier classification badge */
.aqi-tier-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.aqi-tier-badge.good { 
    background: rgba(46, 204, 113, 0.15);
    border-color: #2ecc71;
    color: #2ecc71;
}

.aqi-tier-badge.satisfactory { 
    background: rgba(243, 156, 18, 0.15);
    border-color: #f39c12;
    color: #f39c12;
}

.aqi-tier-badge.moderately-polluted { 
    background: rgba(231, 76, 60, 0.15);
    border-color: #e74c3c;
    color: #e74c3c;
}

.aqi-tier-badge.poor { 
    background: rgba(155, 89, 182, 0.15);
    border-color: #9b59b6;
    color: #9b59b6;
}

.aqi-tier-badge.very-poor { 
    background: rgba(52, 73, 94, 0.15);
    border-color: #34495e;
    color: #34495e;
}

.aqi-tier-badge.severe { 
    background: rgba(192, 57, 43, 0.15);
    border-color: #c0392b;
    color: #c0392b;
}

/* Info Details Grid */
.info-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(15, 52, 96, 0.6);
    border-left: 3px solid var(--accent-color);
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.detail-row:hover {
    background: rgba(15, 52, 96, 0.8);
    padding-left: 14px;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.8px;
}

.detail-value {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 13px;
}

/* Health recommendation message */
.health-message {
    margin-top: 14px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-secondary);
    border-left: 2px solid var(--accent-color);
}

/* Map Markers - Pulsing Radar Circles */
.aqi-marker-container {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Pulsing outer ring effect */
.aqi-marker-pulse {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid;
    opacity: 0.8;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Inner solid marker */
.aqi-marker {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.aqi-marker-container:hover .aqi-marker {
    transform: scale(1.25);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.aqi-marker-container:hover .aqi-marker-pulse {
    animation: pulse-intense 1.5s infinite;
}

@keyframes pulse-intense {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.2;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Color variants */
.aqi-marker.good { 
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
}

.aqi-marker.satisfactory { 
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.aqi-marker.moderately-polluted { 
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.aqi-marker.poor { 
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
}

.aqi-marker.very-poor { 
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
}

.aqi-marker.severe { 
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    color: white;
}

/* Pulse ring color variants */
.aqi-marker-pulse.good { border-color: #2ecc71; }
.aqi-marker-pulse.satisfactory { border-color: #f39c12; }
.aqi-marker-pulse.moderately-polluted { border-color: #e74c3c; }
.aqi-marker-pulse.poor { border-color: #9b59b6; }
.aqi-marker-pulse.very-poor { border-color: #34495e; }
.aqi-marker-pulse.severe { border-color: #c0392b; }

/* Responsive Design */
@media (max-width: 968px) {
    :root {
        --sidebar-width: 300px;
    }
    
    .city-info-card {
        width: 280px;
        max-height: 380px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        overflow-x: hidden;
    }
    
    .map-container {
        height: 60vh;
    }
    
    .city-info-card {
        width: calc(100% - 40px) !important;
        right: 20px !important;
        bottom: 20px !important;
        max-height: calc(60vh - 40px);
    }
    
    .aqi-marker-container {
        width: 45px;
        height: 45px;
    }
    
    .aqi-marker {
        width: 36px;
        height: 36px;
        font-size: 11px;
    }
    
    .aqi-marker-pulse {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-height: 30vh;
        padding: 15px;
        gap: 15px;
    }
    
    .map-container {
        height: 70vh;
    }
    
    .city-info-card {
        width: calc(100% - 30px) !important;
        right: 15px !important;
        bottom: 15px !important;
        max-height: calc(50vh - 30px);
        padding: 15px;
    }
    
    .sidebar-header h1 {
        font-size: 18px;
    }
    
    #info-city-name {
        font-size: 16px;
    }
    
    #info-aqi-value {
        font-size: 36px;
    }
    
    .aqi-legend,
    .stats-panel {
        font-size: 11px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .city-info-card {
        display: none;
    }
    
    .map-container {
        width: 100%;
        height: 100%;
    }
}
