/* McKee Air Quality Network — Dashboard Styles */

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --pm-good: #16a34a;
    --pm-moderate: #d97706;
    --pm-unhealthy: #dc2626;
    --pm-hazardous: #7c2d12;
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #e2e8f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Layout: sidebar + main */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-header .subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    padding: 12px 8px 6px;
}

.node-list {
    list-style: none;
}

.node-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}

.node-item:hover {
    background: rgba(255,255,255,0.08);
}

.node-item.active {
    background: rgba(37, 99, 235, 0.3);
}

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

.node-status-dot.online { background: var(--success); }
.node-status-dot.offline { background: var(--danger); }
.node-status-dot.stale { background: var(--warning); }

.node-item-info {
    flex: 1;
    min-width: 0;
}

.node-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-item-pm {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
}

.sidebar-footer a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
}

.sidebar-footer a:hover {
    color: #fff;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top bar */
.topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Map container */
.map-and-detail {
    flex: 1;
    display: flex;
    min-height: 0;
}

#map {
    flex: 1;
    min-height: 300px;
}

/* Detail panel (slides in from right when a node is selected) */
.detail-panel {
    width: 380px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: none;
    flex-shrink: 0;
}

.detail-panel.open {
    display: block;
}

.detail-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.detail-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
}

.detail-body {
    padding: 20px;
}

/* Reading cards in detail panel */
.reading-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.reading-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 14px;
}

.reading-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reading-card .value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
    line-height: 1;
}

.reading-card .unit {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 2px;
}

.reading-card.pm-good .value { color: var(--pm-good); }
.reading-card.pm-moderate .value { color: var(--pm-moderate); }
.reading-card.pm-unhealthy .value { color: var(--pm-unhealthy); }
.reading-card.pm-hazardous .value { color: var(--pm-hazardous); }

/* Chart container */
.chart-section {
    margin-top: 8px;
}

.chart-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.chart-container {
    width: 100%;
    height: 200px;
    position: relative;
}

/* Admin health bar */
.health-bar {
    display: flex;
    gap: 16px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 48px;
    align-items: center;
    font-size: 13px;
}

.health-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.health-stat .count {
    font-weight: 600;
}

/* Flagged node indicator */
.node-item.flagged .node-item-name {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    font-size: 20px;
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .detail-panel { width: 100%; position: absolute; right: 0; top: 56px; bottom: 0; z-index: 1000; }
}
