/* ==================== APP CONTAINER ==================== */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

.app-container.hidden { display: none; }

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 420px;
    background: linear-gradient(180deg, rgba(10, 14, 26, 0.98) 0%, rgba(20, 25, 35, 0.98) 100%);
    backdrop-filter: blur(25px);
    border-right: 1px solid rgba(0, 212, 170, 0.3);
    padding: 24px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 0 60px rgba(0, 212, 170, 0.15);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s ease, opacity 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    border-right: none;
}

/* Sidebar Toggle */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    width: 48px;
    height: 48px;
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 212, 170, 0.4);
    border-radius: 12px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: rgba(0, 212, 170, 0.2);
    border-color: var(--primary);
    transform: scale(1.05);
}

.sidebar-toggle.shifted { left: 436px; }

/* Mobile sidebar backdrop overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1001;
}
.sidebar-backdrop.visible { display: block; }

/* ==================== HEADER ==================== */
.header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 212, 170, 0.3);
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.wesense-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(0, 212, 170, 0.3);
}

.header h1 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, #7b68ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 1px;
}

.epa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.15) 0%, rgba(0, 168, 255, 0.15) 100%);
    border: 1px solid rgba(0, 212, 170, 0.4);
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 8px;
    text-transform: uppercase;
}

/* Connection status with CSS dots */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.25);
    border-radius: 20px;
    font-size: 12px;
    margin-top: 12px;
    transition: all 0.4s ease;
}

.connection-status.status-error {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.3);
}

.connection-status.status-demo {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
}

.status-dot-css {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.status-dot-css.connecting { background: #fbbf24; animation: pulse 1.5s infinite; }
.status-dot-css.success    { background: #00d4aa; }
.status-dot-css.error      { background: #ff6b6b; }
.status-dot-css.demo       { background: #fbbf24; animation: pulse 2s infinite; }

/* Demo banner */
.demo-banner {
    background: linear-gradient(135deg, rgba(251,191,36,0.15) 0%, rgba(245,158,11,0.15) 100%);
    border: 1px solid rgba(251,191,36,0.4);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 16px;
    text-align: center;
    display: none;
}

.demo-banner.show { display: block; }

/* ==================== AQI CARD ==================== */
.aqi-card {
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    text-align: center;
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.2) 0%, rgba(0, 168, 255, 0.2) 100%);
    border: 2px solid rgba(0, 212, 170, 0.3);
    transition: all 0.4s ease;
}

.aqi-epa-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.epa-official-badge {
    background: linear-gradient(135deg, var(--epa-blue-dark) 0%, var(--epa-blue) 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
}

.aqi-value {
    font-size: 64px;
    font-weight: 900;
    margin-bottom: 8px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-family: 'JetBrains Mono', monospace;
}

.aqi-status {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.aqi-description {
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.9;
}

.aqi-main-pollutant {
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ==================== EPA COMPLIANCE SECTION ==================== */
.epa-compliance-section {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 24px;
}

.epa-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #60a5fa;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.epa-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.epa-stat {
    text-align: center;
    padding: 10px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.epa-stat-value {
    font-size: 18px;
    font-weight: 800;
    color: #60a5fa;
    font-family: 'JetBrains Mono', monospace;
}

.epa-stat-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ==================== METRICS GRID ==================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.metric-card.epa-pollutant {
    border-color: rgba(0, 212, 170, 0.4);
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.1) 0%, rgba(0, 168, 255, 0.1) 100%);
}

.metric-card.epa-pollutant::before {
    content: 'EPA';
    position: absolute;
    top: 5px;
    right: 6px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(0, 212, 170, 0.8);
    opacity: 1;
}

.metric-icon {
    font-size: 22px;
    margin-bottom: 8px;
    color: rgba(0, 212, 170, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.metric-icon svg {
    stroke: currentColor;
    flex-shrink: 0;
}

.metric-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--secondary);
    margin-bottom: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.metric-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ==================== CHART CONTAINER ==================== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    height: 200px;
}

.chart-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-epa-badge {
    background: linear-gradient(135deg, var(--epa-blue-dark) 0%, var(--epa-blue) 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
}

/* ==================== CONTROLS SECTION ==================== */
.controls-section { margin-bottom: 24px; }

.section-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.control-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-switch.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active::after { transform: translateX(24px); }

.wind-info {
    margin-top: 14px;
    padding: 12px;
    background: rgba(0, 168, 255, 0.1);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.wind-info strong { color: var(--primary); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 360px;
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 1002;
        padding: 16px;
        /* Use transform for smooth slide animation on mobile */
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    /* On mobile, slide sidebar off-screen instead of collapsing its width */
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 100%;
        max-width: 360px;
        padding: 16px;
    }
    .sidebar-toggle { top: 16px; left: 16px; width: 44px; height: 44px; font-size: 18px; }
    .sidebar-toggle.shifted { left: 16px; }

    .aqi-value { font-size: 52px; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .metric-card { padding: 10px; }
    .metric-value { font-size: 15px; }
    .chart-container { height: 170px; }
}

@media (max-width: 360px) {
    .sidebar { max-width: 100%; }
    .aqi-value { font-size: 44px; }
}

/* Logout Button */
.logout-btn-sidebar {
    width: 100%;
    margin-top: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2) 0%, rgba(255, 61, 87, 0.2) 100%);
    border: 1px solid rgba(255, 107, 107, 0.4);
    border-radius: 12px;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.logout-btn-sidebar:hover {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.3) 0%, rgba(255, 61, 87, 0.3) 100%);
    border-color: #ff6b6b;
    color: white;
}
