/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #232a3b;
    --bg-card-hover: #2a3347;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --accent-blue: #4fc3f7;
    --accent-green: #81c784;
    --accent-orange: #ffb74d;
    --accent-red: #e57373;
    --accent-yellow: #fff176;
    --accent-purple: #b39ddb;
    --border-color: #2d3548;
    --sidebar-width: 340px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

/* === Dashboard Layout === */
.dashboard {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
}

/* === Sidebar === */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.weather-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.weather-content::-webkit-scrollbar {
    width: 6px;
}

.weather-content::-webkit-scrollbar-track {
    background: transparent;
}

.weather-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.last-update {
    font-size: 11px;
    color: var(--text-muted);
}

/* === Connection Status === */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-orange);
    transition: background 0.3s;
}

.connection-status.connected .status-dot {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

.connection-status.disconnected .status-dot {
    background: var(--accent-red);
}

.connection-status.connecting .status-dot {
    background: var(--accent-orange);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* === Weather Cards === */
.weather-card {
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: background 0.2s;
}

.weather-card:hover {
    background: var(--bg-card-hover);
}

.weather-card.hidden {
    display: none;
}

.card-header {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 14px;
}

.primary-value {
    font-size: 36px;
    font-weight: 300;
    line-height: 1.1;
    margin-bottom: 8px;
}

.primary-value .unit {
    font-size: 18px;
    color: var(--text-secondary);
    margin-left: 2px;
}

.secondary-values {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 0;
    font-size: 14px;
}

.secondary-values .label {
    color: var(--text-secondary);
    min-width: 80px;
    font-size: 12px;
}

.secondary-values .unit {
    color: var(--text-muted);
    font-size: 12px;
}

.minmax {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 13px;
}

.minmax .lo {
    color: var(--accent-blue);
}

.minmax .hi {
    color: var(--accent-red);
}

/* === Trend Indicators === */
.trend {
    display: inline-block;
    font-size: 14px;
    margin-left: 4px;
    font-weight: bold;
}

.trend.rising {
    color: var(--accent-red);
}

.trend.rising::after {
    content: '\25B2';
}

.trend.falling {
    color: var(--accent-blue);
}

.trend.falling::after {
    content: '\25BC';
}

.trend.steady {
    color: var(--text-muted);
}

.trend.steady::after {
    content: '\25C6';
}

/* === Wind Compass === */
.wind-display {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compass {
    flex-shrink: 0;
}

.compass-ring {
    width: 90px;
    height: 90px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    position: relative;
    background: var(--bg-primary);
}

.compass-label {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

.compass-label.n { top: 4px; left: 50%; transform: translateX(-50%); }
.compass-label.s { bottom: 4px; left: 50%; transform: translateX(-50%); }
.compass-label.e { right: 6px; top: 50%; transform: translateY(-50%); }
.compass-label.w { left: 6px; top: 50%; transform: translateY(-50%); }

.compass-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 32px;
    background: var(--accent-red);
    transform-origin: center bottom;
    transform: translate(-50%, -100%) rotate(0deg);
    border-radius: 2px;
    transition: transform 0.5s ease;
}

.compass-arrow::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid var(--accent-red);
}

.wind-values {
    flex: 1;
}

.wind-values .primary-value {
    font-size: 28px;
}

/* === UV Label === */
.uv-label {
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 600;
    vertical-align: middle;
}

.uv-label.uv-low { background: var(--accent-green); color: #000; }
.uv-label.uv-moderate { background: var(--accent-yellow); color: #000; }
.uv-label.uv-high { background: var(--accent-orange); color: #000; }
.uv-label.uv-very-high { background: var(--accent-red); color: #fff; }
.uv-label.uv-extreme { background: var(--accent-purple); color: #fff; }

/* === Weather Placeholder === */
.weather-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.weather-placeholder.hidden {
    display: none;
}

/* === Map === */
.map-container {
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
}

/* Removed CSS filter - using CartoDB Dark Matter tiles instead */

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
}

.leaflet-control-layers {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    border-radius: 8px !important;
}

.leaflet-control-layers-list {
    color: var(--text-primary);
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    font-size: 13px;
    line-height: 1.5;
}

/* === Map Overlays === */
.map-overlay {
    position: absolute;
    z-index: 1000;
    background: rgba(26, 31, 46, 0.9);
    backdrop-filter: blur(8px);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    pointer-events: none;
}

.map-overlay.top-left {
    top: 12px;
    left: 12px;
    display: flex;
    gap: 16px;
}

.map-overlay.bottom-left {
    bottom: 12px;
    left: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* === Aircraft Labels === */
.aircraft-label {
    background: none !important;
    border: none !important;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9), -1px -1px 2px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.9);
    white-space: nowrap;
    pointer-events: none;
}

/* Light mode labels need dark text with light shadow */
.light-map .aircraft-label {
    color: #000;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.9), -1px -1px 2px rgba(255,255,255,0.9), 0 0 4px rgba(255,255,255,0.9);
}

/* === Aircraft Popup === */
.aircraft-popup {
    min-width: 160px;
}

.aircraft-popup h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--accent-blue);
}

.aircraft-popup .detail {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid var(--border-color);
}

.aircraft-popup .detail:last-child {
    border-bottom: none;
}

.aircraft-popup .detail-label {
    color: var(--text-secondary);
}

/* === Alert Popup === */
.alert-popup h3 {
    font-size: 14px;
    margin-bottom: 6px;
}

.alert-popup .alert-severity {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
}

.alert-popup .severity-warning { background: var(--accent-red); color: #fff; }
.alert-popup .severity-watch { background: var(--accent-orange); color: #000; }
.alert-popup .severity-advisory { background: var(--accent-yellow); color: #000; }

.alert-popup .alert-desc {
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.4;
}

/* === Eastern NE Warnings === */
.ne-warnings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ne-warning-count {
    background: var(--text-muted);
    color: var(--bg-primary);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.ne-warning-count.active {
    background: var(--accent-red);
    color: #fff;
    animation: pulse 2s infinite;
}

.ne-warnings-body {
    padding: 8px !important;
    max-height: 200px;
    overflow-y: auto;
}

.ne-no-warnings {
    text-align: center;
    color: var(--accent-green);
    font-size: 13px;
    padding: 8px;
}

.ne-warning-item {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    align-items: flex-start;
}

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

.ne-warning-badge {
    width: 4px;
    min-height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
}

.ne-warning-info {
    flex: 1;
    min-width: 0;
}

.ne-warning-event {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
}

.ne-warn-type-warning {
    color: var(--accent-red);
}

.ne-warn-type-watch {
    color: var(--accent-orange);
}

.ne-warning-counties {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.ne-warning-expires {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === Spotter Icons === */
.spotter-icon {
    background: none !important;
    border: none !important;
}

.spotter-dot {
    width: 6px;
    height: 6px;
    background: #00e5ff;
    border: 1px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 229, 255, 0.6);
}

.spotter-name {
    display: block;
    font-size: 8px;
    color: #00e5ff;
    white-space: nowrap;
    margin-top: 1px;
    margin-left: -20px;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.9), -1px -1px 1px rgba(0,0,0,0.9);
    pointer-events: none;
}

.spotter-popup b {
    color: #00e5ff;
}

/* === Product Controls (Radar / Visible / IR) === */
.product-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(26, 31, 46, 0.92);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 10px;
    min-width: 360px;
    pointer-events: auto;
    border: 1px solid var(--border-color);
}

.product-controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.product-tabs {
    display: flex;
    gap: 4px;
}

.product-tab {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 3px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.product-tab:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.product-tab.active {
    background: var(--accent-blue);
    color: #000;
    border-color: var(--accent-blue);
}

.product-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-opacity-row {
    margin-top: 5px;
    font-size: 11px;
}

.product-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 32px;
    height: 26px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.product-btn:hover {
    background: var(--bg-card-hover);
}

.product-speed-btn {
    font-size: 11px;
    font-weight: 700;
    width: 30px;
}

.product-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.product-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.4);
}

.product-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid #fff;
}

.product-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    text-align: center;
    white-space: nowrap;
}

.product-label {
    color: var(--text-muted);
    min-width: 46px;
}

.product-opacity-slider {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.product-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
    border: 1px solid #fff;
}

.product-opacity-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
    border: 1px solid #fff;
}

.product-opacity-val {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 30px;
    text-align: right;
}

/* === Loading Overlay === */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.loading-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Responsive === */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    :root {
        --sidebar-width: 100%;
    }
}
