/* ==========================================================================
   ESTACIO METEOROLOGICA BARADELLO GELAT (ALCOI)
   Modern Weather Dashboard Stylesheet
   ========================================================================== */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Tema Clar (per defecte) */
    --bg: #f1f5f9;
    --bg-alt: #e2e8f0;
    --tile-bg: #ffffff;
    --tile-bg-hover: #f8fafc;
    --tile-border: rgba(148, 163, 184, 0.25);
    --tile-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    
    --fg: #0f172a;
    --fg-muted: #64748b;
    --fg-subtle: #94a3b8;

    --accent: #0284c7;
    --accent-light: #e0f2fe;
    --accent-hover: #0369a1;

    --color-temp: #ea580c;
    --color-hum: #0284c7;
    --color-dew: #0d9488;
    --color-wind: #0891b2;
    --color-gust: #e11d48;
    --color-press: #7c3aed;
    --color-rain: #2563eb;
    --color-solar: #d97706;
    --color-uv: #9333ea;

    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

body.theme-dark {
    --bg: #0b1120;
    --bg-alt: #1e293b;
    --tile-bg: #151f32;
    --tile-bg-hover: #1c283f;
    --tile-border: rgba(255, 255, 255, 0.08);
    --tile-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4), 0 4px 12px -2px rgba(0, 0, 0, 0.25);

    --fg: #f8fafc;
    --fg-muted: #94a3b8;
    --fg-subtle: #64748b;

    --accent: #38bdf8;
    --accent-light: rgba(56, 189, 248, 0.15);
    --accent-hover: #7dd3fc;

    --color-temp: #fb923c;
    --color-hum: #38bdf8;
    --color-dew: #2dd4bf;
    --color-wind: #22d3ee;
    --color-gust: #fb7185;
    --color-press: #a78bfa;
    --color-rain: #60a5fa;
    --color-solar: #fbbf24;
    --color-uv: #c084fc;

    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Capçalera i Alertes
   ========================================================================== */

header {
    background: var(--tile-bg);
    border-bottom: 1px solid var(--tile-border);
    padding: 16px 24px;
    box-shadow: var(--tile-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--fg);
}

.brand-subtitle {
    font-size: 0.82rem;
    color: var(--fg-muted);
    font-weight: 500;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.status-badge.online {
    background: rgba(22, 163, 74, 0.15);
    color: var(--success);
    border: 1px solid rgba(22, 163, 74, 0.3);
}

.status-badge.offline {
    background: rgba(220, 38, 38, 0.15);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.theme-selector select {
    background: var(--bg-alt);
    color: var(--fg);
    border: 1px solid var(--tile-border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
}

/* Banner d'alerta */
.alert-banner {
    max-width: 1400px;
    margin: 16px auto 0;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.12), rgba(2, 132, 199, 0.05));
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--fg);
}

.alert-close {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--fg-muted);
    background: none;
    border: none;
    padding: 0 4px;
}

.alert-close:hover {
    color: var(--fg);
}

/* ==========================================================================
   Navegacio Principal
   ========================================================================== */

nav {
    background: var(--tile-bg);
    border-bottom: 1px solid var(--tile-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-container::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--fg);
    background: var(--bg-alt);
}

.nav-item.active {
    color: #ffffff;
    background: var(--accent);
}

/* ==========================================================================
   Contenidor Principal i Pestanyes
   ========================================================================== */

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Cards / Reixeta d'Informacio
   ========================================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.card {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--tile-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: rgba(2, 132, 199, 0.35);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    font-size: 1.1rem;
}

/* Hero Card (Temperatura Principal) */
.hero-temp-card {
    grid-column: span 12;
    background: linear-gradient(135deg, var(--tile-bg), var(--tile-bg-hover));
    border-left: 6px solid var(--color-temp);
}

@media (min-width: 900px) {
    .hero-temp-card {
        grid-column: span 8;
    }
}

.hero-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
}

.hero-main-metric {
    display: flex;
    align-items: center;
    gap: 20px;
}

.hero-weather-icon {
    font-size: 4.5rem;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.hero-temp-val {
    font-size: 4.2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--fg);
}

.hero-temp-val .unit {
    font-size: 2rem;
    font-weight: 500;
    color: var(--fg-muted);
    margin-left: 2px;
}

.hero-desc {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fg);
    margin-top: 4px;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--bg-alt);
    color: var(--fg);
}

.badge.hot { background: rgba(234, 88, 12, 0.12); color: var(--color-temp); }
.badge.cold { background: rgba(2, 132, 199, 0.12); color: var(--color-hum); }

/* Card Rosa dels Vents */
.wind-compass-card {
    grid-column: span 12;
}

@media (min-width: 900px) {
    .wind-compass-card {
        grid-column: span 4;
    }
}

.compass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
}

.compass-svg-wrapper {
    position: relative;
    width: 170px;
    height: 170px;
}

.compass-svg {
    width: 100%;
    height: 100%;
}

.compass-center-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.compass-speed {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--fg);
}

.compass-unit {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fg-muted);
}

.compass-needle {
    transform-origin: 85px 85px;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Metric Cards Standar */
.metric-card-3 {
    grid-column: span 12;
}
@media (min-width: 640px) { .metric-card-3 { grid-column: span 6; } }
@media (min-width: 1100px) { .metric-card-3 { grid-column: span 3; } }

.metric-card-4 {
    grid-column: span 12;
}
@media (min-width: 640px) { .metric-card-4 { grid-column: span 6; } }
@media (min-width: 1100px) { .metric-card-4 { grid-column: span 4; } }

.metric-val-large {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--fg);
    margin: 4px 0 8px;
}

.metric-val-large .unit {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--fg-muted);
}

.metric-subtext {
    font-size: 0.85rem;
    color: var(--fg-muted);
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px dashed var(--tile-border);
}

.metric-subtext:last-child {
    border-bottom: none;
}

.metric-subtext .highlight {
    font-weight: 700;
    color: var(--fg);
}

/* ==========================================================================
   Mini Grafics i Seccions Chart.js
   ========================================================================== */

.chart-card-full {
    grid-column: span 12;
}

.chart-card-half {
    grid-column: span 12;
}
@media (min-width: 900px) { .chart-card-half { grid-column: span 6; } }

.chart-canvas-container {
    position: relative;
    width: 100%;
    height: 280px;
    margin-top: 10px;
}

.chart-canvas-container.tall {
    height: 360px;
}

.chart-mode-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-bottom: 20px;
    box-shadow: var(--tile-shadow);
}

.chart-mode-bar select {
    background: var(--bg-alt);
    color: var(--fg);
    border: 1px solid var(--tile-border);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.wd-graphs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.wd-graph-item {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--tile-shadow);
}

.wd-graph-item h4 {
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: var(--fg);
}

.wd-graph-item img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    background: #ffffff;
    display: block;
}

/* ==========================================================================
   Webcams ACIF
   ========================================================================== */

.webcams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 24px;
    margin-top: 16px;
}

.webcam-card {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--tile-shadow);
}

.webcam-card-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--tile-bg-hover);
    border-bottom: 1px solid var(--tile-border);
}

.webcam-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fg);
}

.webcam-img-wrap {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.webcam-img-wrap img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.webcam-img-wrap img:hover {
    transform: scale(1.02);
}

/* ==========================================================================
   Radares i Previsio (RainViewer & Windy)
   ========================================================================== */

.rainviewer-wrap,
.windy-iframe-wrap {
    width: 100%;
    height: 580px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--tile-border);
    box-shadow: var(--tile-shadow);
    margin-top: 14px;
    background: #111827;
}

.rainviewer-wrap iframe,
.windy-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.nav-item.classic-link {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
    font-weight: 700;
}

.nav-item.classic-link:hover {
    background: rgba(245, 158, 11, 0.24);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.6);
}

/* ==========================================================================
   Banners de Xarxes Meteorologiques
   ========================================================================== */

.network-badges-section {
    margin-top: 36px;
    padding: 24px;
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--tile-shadow);
}

.network-badges-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--fg);
}

.badges-flex {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.badge-item img {
    max-height: 70px;
    border-radius: var(--radius-sm);
    transition: transform 0.2s ease;
}

.badge-item img:hover {
    transform: translateY(-2px);
}

/* ==========================================================================
   Taules i Historics
   ========================================================================== */

.records-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.record-kpi-card {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--tile-shadow);
    border-top: 4px solid var(--accent);
}

.record-kpi-card .rec-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
}

.record-kpi-card .rec-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--fg);
    margin: 4px 0;
}

.record-kpi-card .rec-date {
    font-size: 0.78rem;
    color: var(--fg-subtle);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-controls select {
    background: var(--tile-bg);
    color: var(--fg);
    border: 1px solid var(--tile-border);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.month-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
}

.kpi-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--fg-muted);
}

.kpi-card .val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fg);
}

.table-responsive {
    overflow-x: auto;
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: right;
}

.data-table th, .data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--tile-border);
}

.data-table th {
    background: var(--tile-bg-hover);
    color: var(--fg-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover {
    background: var(--bg-alt);
}

.data-table td:first-child, .data-table th:first-child {
    text-align: left;
}

.text-danger { color: var(--danger); font-weight: 700; }
.text-primary { color: var(--accent); font-weight: 700; }
.rain-highlight { background: rgba(37, 99, 235, 0.12); font-weight: 700; }

/* ==========================================================================
   Modal Lightbox
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.modal-content {
    max-width: 90%;
    max-height: 85%;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.modal-caption {
    color: #fff;
    margin-top: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ==========================================================================
   Peu de Pagina
   ========================================================================== */

footer {
    background: var(--tile-bg);
    border-top: 1px solid var(--tile-border);
    padding: 32px 20px;
    margin-top: 48px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 768px) {
    header { padding: 12px 16px; }
    .brand-title { font-size: 1.15rem; }
    .hero-temp-val { font-size: 3.2rem; }
    .hero-weather-icon { font-size: 3.5rem; }
    .chart-canvas-container { height: 240px; }
    .rainviewer-wrap, .windy-iframe-wrap, #rainviewer-map { height: 420px !important; }
}

/* ==========================================================================
   Panoràmica Hivernal de l'Estació (Hero Banner)
   ========================================================================== */

.station-panorama-banner {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
    height: 150px;
    background: #0f172a url('../img/Background.jpg') center 35% / cover no-repeat;
    border: 1px solid var(--tile-border);
    box-shadow: var(--tile-shadow);
    display: flex;
    align-items: center;
}

.station-panorama-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.88) 0%, rgba(15, 23, 42, 0.52) 55%, rgba(15, 23, 42, 0.22) 100%);
    pointer-events: none;
}

.station-panorama-content {
    position: relative;
    z-index: 2;
    padding: 16px 24px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.station-panorama-text h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 4px 0 2px 0;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    letter-spacing: -0.01em;
}

.station-panorama-text p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.station-panorama-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.station-panorama-btn {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.38);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.station-panorama-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.65);
    color: #ffffff;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .station-panorama-banner {
        height: 130px;
        margin-bottom: 16px;
    }
    .station-panorama-content {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .station-panorama-text h2 {
        font-size: 1.05rem;
    }
    .station-panorama-btn {
        display: none;
    }
}

/* ==========================================================================
   Controles del Radar RainViewer Interactiu
   ========================================================================== */

.radar-interactive-container {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--tile-shadow);
    margin-top: 14px;
}

.radar-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    background: var(--tile-bg);
    border-bottom: 1px solid var(--tile-border);
    flex-wrap: wrap;
}

.radar-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.radar-ctrl-btn {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.radar-ctrl-btn:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.radar-ctrl-btn.play-btn {
    min-width: 105px;
    justify-content: center;
}

.radar-slider-wrap {
    flex: 1;
    min-width: 160px;
    display: flex;
    align-items: center;
}

.radar-slider-wrap input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--accent);
}

.radar-info-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radar-badge {
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid var(--tile-border);
}

.radar-status-text {
    font-size: 0.82rem;
    color: var(--fg-muted);
}

.radar-legend-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 18px;
    background: var(--tile-bg);
    border-top: 1px solid var(--tile-border);
    font-size: 0.8rem;
    flex-wrap: wrap;
}

.legend-label {
    font-weight: 600;
    color: var(--fg-muted);
}

.legend-gradient {
    flex: 1;
    min-width: 140px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, 
        rgba(0, 0, 255, 0.4) 0%, 
        #00aaff 20%, 
        #00ff00 40%, 
        #ffff00 60%, 
        #ff8800 80%, 
        #ff0000 90%, 
        #aa00ff 100%);
    border: 1px solid rgba(0,0,0,0.2);
}

.legend-scale {
    display: flex;
    gap: 14px;
    color: var(--fg-muted);
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .radar-controls-bar {
        padding: 10px 12px;
        gap: 10px;
    }
    .radar-slider-wrap {
        order: 3;
        width: 100%;
        min-width: 100%;
    }
    #rainviewer-map {
        height: 420px !important;
    }
}

/* ==========================================================================
   Pin i Capes Base Esri del Mapa Radar
   ========================================================================== */

.station-map-pin {
    position: relative;
}
.pin-pulse {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(14, 165, 233, 0.45);
    animation: pin-pulse-anim 2s infinite;
}
.pin-dot {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #0284c7;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
@keyframes pin-pulse-anim {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.basemap-switcher-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-basemap {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--tile-border);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-basemap:hover {
    background: var(--tile-border);
}
.btn-basemap.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

/* Indicadors de connexió i retard en dades (Llum roja per desactualitzat) */
.pulse-dot.red {
    background-color: var(--danger) !important;
    animation: pulse-red 1.8s infinite;
}
@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
