:root {
    /* Base Palette - Deep Blue/Slate */
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7); /* Glass effect */
    --card-bg: rgba(30, 41, 59, 0.6); /* Glass effect */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.1);
    
    /* Accents */
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    
    /* AQI Colors - Modern Vibrancy */
    --aqi-good: #22c55e;
    --aqi-moderate: #eab308;
    --aqi-unhealthy-sg: #f97316;
    --aqi-unhealthy: #ef4444;
    --aqi-very-unhealthy: #a855f7;
    --aqi-hazardous: #be123c;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none; /* Custom focus styles preferred */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    border-bottom: var(--glass-border);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.header-title h2 {
    font-family: 'Orbitron', sans-serif; /* Tech feel for title */
    font-size: 1.5rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 0.05em;
}

.header-title i {
    color: var(--accent-color);
    -webkit-text-fill-color: initial; /* Don't apply text gradient to icon */
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

#lbl-language {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 360px 1fr; /* Slightly wider sidebar */
    gap: 32px;
    padding: 32px;
    height: 100%;
    overflow: hidden;
}

/* Sidebar Column */
.col-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Cards Generic */
.card {
    background-color: var(--card-bg);
    border: var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 255, 255, 0.12);
}

.control-card {
    flex-shrink: 0;
}

.watchlist-card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    overflow: hidden;
}

.watchlist-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

/* Main Column */
.col-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    padding-right: 8px;
}

.location-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 8px;
}

#location-name {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 8px;
    background: linear-gradient(to bottom, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#location-coords {
    font-family: 'Orbitron', monospace;
    color: var(--accent-color);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
}

.toggle-group {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.action-btn {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
    filter: brightness(1.1);
}

.action-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.full-width {
    width: 100%;
    justify-content: center;
}

/* Form Elements */
.mode-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.mode-selector label {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.mode-selector input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.mode-selector span {
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.mode-selector input:checked + span {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.select-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select {
    width: 100%;
    padding: 12px;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    transition: border-color 0.2s;
}

select:focus {
    border-color: var(--accent-color);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Top Data Grid */
.top-row-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 32px;
    margin-bottom: 24px;
}

/* AQI Card - Centerpiece */
.aqi-card {
    position: relative;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    border: 2px solid transparent; /* Colored border set via JS */
    background: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 70%);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Subtle glow background behind AQI */
.aqi-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: currentColor; /* Inherits from color set in JS */
    opacity: 0.1;
    filter: blur(60px);
    border-radius: 50%;
    z-index: 0;
}

.aqi-title {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    z-index: 1;
}

.aqi-value {
    font-size: 8rem;
    font-weight: 800;
    line-height: 1;
    margin: 16px 0;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1;
}

.aqi-status {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    z-index: 1;
}

.aqi-sub {
    font-size: 1.1rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 16px;
    border-radius: 50px;
    z-index: 1;
}

/* Metrics */
.metrics-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
}

.metric-box {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    transition: transform 0.2s;
}

.metric-box:hover {
    background: rgba(30, 41, 59, 0.6);
    transform: translateX(-4px);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 600;
    margin-top: 0;
    color: var(--text-primary);
}

/* Map */
.map-card {
    flex: 1;
    min-height: 400px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: var(--glass-border);
    border-radius: 24px;
}

.map-card h3 {
    padding: 20px 24px 0;
    font-size: 0.9rem;
}

#map {
    flex: 1;
    width: 100%;
    z-index: 1;
    margin-top: 16px;
}

/* Watchlist Item - Compact */
.watchlist-item {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.watchlist-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.watchlist-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color); /* Fallback */
    opacity: 0;
    transition: opacity 0.2s;
}

.watchlist-item:hover::before {
    opacity: 1;
}

.watchlist-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    opacity: 0;
    transition: all 0.2s;
    z-index: 2;
}

.watchlist-item:hover .watchlist-delete {
    opacity: 1;
}

.watchlist-delete:hover {
    background: #ef4444;
    color: white;
}

.watchlist-item h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    padding-right: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watchlist-item .meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    margin-bottom: 12px;
}

.watchlist-item .wl-aqi {
    font-size: 1.75rem;
    font-weight: 700;
    position: absolute;
    bottom: 12px;
    right: 16px;
    font-family: 'Orbitron', sans-serif;
}

.watchlist-item .status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0,0,0,0.2);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px dashed var(--border-color);
    margin: 8px;
}

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

h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

p { color: var(--text-secondary); line-height: 1.6; }

/* Status Message */
.status-text {
    font-size: 0.9rem;
    margin-top: 12px;
    text-align: center;
    min-height: 1.4em;
}

/* Responsive */
@media (max-width: 1024px) {
    body {
        height: auto;
        overflow-y: auto; /* Allow body scroll on smaller screens */
    }

    .app-container {
        height: auto;
        overflow: visible;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 32px;
        height: auto;
        overflow: visible;
    }
    
    .col-sidebar {
        height: auto;
        overflow: visible;
    }

    .col-main {
        overflow: visible;
        padding-right: 0;
    }

    .top-row-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .metrics-grid-vertical {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .aqi-card {
        padding: 32px;
    }
    
    .aqi-value {
        font-size: 6rem;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 16px 20px;
    }

    .header-title h2 {
        font-size: 1.25rem;
    }

    .dashboard-grid {
        display: flex;
        flex-direction: column;
        padding: 16px;
        gap: 20px;
    }
    
    .col-sidebar {
        display: contents; /* Allows children to participate in flex layout of parent */
    }
    
    .control-card {
        order: 1; /* First */
    }
    
    .col-main {
        order: 2; /* Second */
        padding-right: 0;
    }
    
    .watchlist-card-container {
        order: 3; /* Last */
        min-height: auto;
        max-height: 400px;
        margin-top: 12px;
    }

    .metrics-grid-vertical {
        grid-template-columns: 1fr; /* Stack metrics on mobile */
    }

    .aqi-value {
        font-size: 5rem;
    }
    
    .map-card {
        min-height: 300px;
    }
    
    /* Make Locate Me button more prominent on mobile */
    #btn-locate {
        padding: 16px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .aqi-value {
        font-size: 4rem;
    }
    
    .aqi-status {
        font-size: 1.5rem;
    }
    
    .mode-selector {
        flex-direction: column;
        gap: 8px;
    }
}
