/* Estonian Climate Data Explorer - Styles */

/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --max-width: 1200px;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

.header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 1rem;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card h3 {
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.help-text {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.control-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Form Inputs */
.select-input,
.number-input,
.date-input {
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.select-input:focus,
.number-input:focus,
.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.select-input:disabled,
.number-input:disabled {
    background: var(--background);
    cursor: not-allowed;
    opacity: 0.7;
}

.number-input {
    width: 120px;
}

/* Range Input */
.range-input {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    margin-top: 0.5rem;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: transform 0.15s;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    min-width: 120px;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-text,
.btn-loading {
    display: inline-block;
}

.btn-loading.hidden,
.btn-text.hidden {
    display: none;
}

/* Chart Containers */
.chart-container {
    width: 100%;
    min-height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
}

.chart-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.chart-section.hidden {
    display: none;
}

/* Status Messages */
.status-message {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-message.error {
    color: var(--error-color);
}

.status-message.success {
    color: var(--success-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

#loading-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

.footer p {
    margin: 0.25rem 0;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

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

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    .card {
        padding: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .number-input {
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .chart-container {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .container {
        padding: 1rem 0.75rem;
    }
}

/* Plotly Overrides */
.js-plotly-plot .plotly .modebar {
    top: 5px !important;
    right: 5px !important;
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Radar */
.radar-map {
    width: 100%;
    height: 520px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: #dfe9f3;
}

.radar-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.radar-slider {
    flex: 1 1 240px;
}

.radar-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 12rem;
}

.radar-opacity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.radar-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-title {
    font-weight: 600;
    color: var(--text-primary);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Data availability table */
.avail-table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.avail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.avail-table th,
.avail-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.avail-table thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

.avail-table thead th:hover {
    color: var(--primary-color);
}

.avail-table tbody tr:nth-child(even) {
    background: var(--background);
}

.avail-table tbody tr:hover {
    background: #eef2ff;
}

/* Station map markers + legend */
.stn-label {
    background: rgba(255, 255, 255, 0.85);
    border: none;
    box-shadow: none;
    padding: 0 3px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
}
.stn-label::before { display: none; } /* hide Leaflet tooltip arrow */

/* Wind barb icons: transparent container, no marker chrome */
.stn-barb { background: none; border: none; }

.stn-scale-bar {
    display: inline-block;
    width: 160px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    vertical-align: middle;
}

.stn-scale-min, .stn-scale-max {
    font-variant-numeric: tabular-nums;
}

table.obs-popup {
    border-collapse: collapse;
    margin-top: 4px;
    font-size: 0.8rem;
}
table.obs-popup td {
    padding: 1px 8px 1px 0;
}
.muted { color: var(--text-secondary); font-weight: normal; }
