/* Weather Dashboard Styles - SCK style (light, blue/teal) */

:root {
    --bg: #e8f1f5;
    --surface: #ffffff;
    --surface-hover: #f0f6f9;
    --text: #2c3e50;
    --text-muted: #6a8a9e;
    --accent: #1e7eaa;
    --accent-dark: #17607f;
    --accent-light: #d5eaf5;
    --live-green: #27ae60;
    --live-offline: #ffffff;
    --border: #c4d8e2;
    --radius: 6px;
    --shadow: 0 1px 4px rgba(0,0,0,0.08);
    --header-bg: linear-gradient(135deg, #1a6e96, #2196b8);

    /* Wind rose heatmap bands (calm → moderate → strong → storm) */
    --wind-calm: #a0d2eb;
    --wind-moderate: #3ca0dc;
    --wind-strong: #1e78b4;
    --wind-storm: #b43c3c;
    --wind-grid: rgba(255,255,255,0.25);
}

* {
    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);
    min-height: 100vh;
}

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--header-bg);
    color: #fff;
    margin-bottom: 16px;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #a8e6cf;
    font-weight: 500;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a8e6cf;
    animation: pulse 2s infinite;
}

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

@keyframes flash {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(2); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

.live-dot.flash {
    animation: flash 0.5s ease-out;
}

.live-time {
    font-size: 0.8rem;
    opacity: 0.85;
    font-variant-numeric: tabular-nums;
}

.theme-select {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
}

.theme-select option {
    background: var(--surface);
    color: var(--text);
}

.live-indicator.stale {
    color: var(--live-offline);
    font-weight: 700;
}

.live-indicator.stale .live-dot {
    background: var(--live-offline);
    animation: none;
}

.live-indicator.stale .live-time {
    opacity: 0.7;
}

/* Tiles */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 0 12px 16px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.tile:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(30,126,170,0.15);
}

.tile-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.tile-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.tile-unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Controls */
.controls {
    margin: 0 12px 12px;
}

.time-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.time-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.time-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-dark);
}

.time-btn.active {
    background: var(--accent);
    border-color: var(--accent-dark);
    color: #fff;
}

.custom-range {
    display: flex;
    gap: 6px;
    align-items: center;
}

.custom-range input {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 0.8rem;
    width: 130px;
}

.custom-range input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(30,126,170,0.2);
}

/* Chart */
.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 12px 12px;
    position: relative;
    height: 400px;
    box-shadow: var(--shadow);
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Field Selector */
.field-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 12px 16px;
}

.field-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    user-select: none;
}

.field-toggle:hover {
    background: var(--accent-light);
}

.field-toggle.active {
    border-color: var(--color, var(--accent));
    background: var(--accent-light);
    font-weight: 600;
}

.field-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color);
}

/* Bottom panels */
.bottom-panels {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
    margin: 0 12px 16px;
}

.wind-rose-panel,
.stats-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.wind-rose-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.wind-rose-panel canvas {
    display: block;
    align-self: center;
}

.wind-unit-toggle {
    float: right;
    background: var(--accent-light);
    color: var(--accent-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wind-unit-toggle:hover {
    background: var(--accent);
    color: #fff;
}

.wind-rose-panel h3,
.stats-panel h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin: -16px -16px 12px -16px;
    padding: 16px 16px 6px 16px;
    color: var(--accent-dark);
    border-bottom: 2px solid var(--accent-light);
}

.stats-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.stats-panel th,
.stats-panel td {
    padding: 5px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.stats-panel th {
    color: var(--accent-dark);
    font-weight: 600;
    text-align: right;
    background: var(--accent-light);
}

.stats-panel th:first-child,
.stats-panel td:first-child {
    text-align: left;
}

.stats-panel tr:hover td {
    background: var(--surface-hover);
}

/* Touch-friendly: ensure minimum tap targets */
@media (pointer: coarse) {
    .time-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 8px 14px;
        font-size: 0.9rem;
    }
    .field-toggle {
        min-height: 44px;
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    .custom-range input {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }
    .wind-unit-toggle {
        min-height: 36px;
        min-width: 36px;
        padding: 4px 10px;
        font-size: 0.8rem;
    }
}

/* Responsive - Tablets */
@media (max-width: 768px) {
    .tiles { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 0 8px 12px; }
    .header h1 { font-size: 1.1rem; }
    .tile { padding: 10px; }
    .tile-value { font-size: 1.3rem; }
    .chart-container { height: 300px; margin: 0 8px 12px; padding: 10px; }
    .bottom-panels { grid-template-columns: 1fr; margin: 0 8px 12px; }
    .controls { margin: 0 8px 12px; }
    .field-selector { margin: 0 8px 12px; }
    .custom-range { flex-wrap: wrap; }
    .custom-range input { width: 110px; }
}

/* Responsive - Phones */
@media (max-width: 480px) {
    .dashboard { padding: 0; }

    .header {
        padding: 10px 12px;
        border-radius: 0;
        margin-bottom: 10px;
    }
    .header h1 { font-size: 1rem; }

    .tiles {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin: 0 6px 10px;
    }
    .tile { padding: 8px 4px; }
    .tile-value { font-size: 1.15rem; }
    .tile-label { font-size: 0.65rem; }
    .tile-unit { font-size: 0.75rem; }

    .controls { margin: 0 6px 10px; }
    .time-controls {
        gap: 4px;
        justify-content: center;
    }
    .time-btn { padding: 6px 10px; font-size: 0.8rem; }
    .custom-range {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
    .custom-range input { width: calc(50% - 4px); }

    .chart-container {
        height: 250px;
        margin: 0 6px 10px;
        padding: 8px 4px;
        border-radius: 4px;
    }

    .field-selector {
        margin: 0 6px 10px;
        gap: 4px;
    }
    .field-toggle {
        padding: 5px 8px;
        font-size: 0.72rem;
        gap: 4px;
    }
    .field-dot { width: 8px; height: 8px; }

    .bottom-panels {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 0 6px 10px;
    }

    .wind-rose-panel h3,
    .stats-panel h3 {
        font-size: 0.8rem;
    }

    .stats-panel table { font-size: 0.72rem; }
    .stats-panel th,
    .stats-panel td { padding: 4px 6px; }
}

/* Safe area insets for notch devices */
@supports (padding: env(safe-area-inset-top)) {
    .header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    .dashboard {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
