:root {
    --bg-base: #0b0f19;
    --bg-card: rgba(18, 24, 38, 0.85);
    --bg-card-hover: rgba(26, 34, 52, 0.95);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(56, 189, 248, 0.25);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --accent-blue: #38bdf8;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-violet: #8b5cf6;
    
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

body.theme-light {
    --bg-base: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(14, 165, 233, 0.3);
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==================== HEADER ==================== */
.main-header {
    background: rgba(11, 15, 25, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.theme-light .main-header {
    background: rgba(248, 250, 252, 0.9);
}

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

.station-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 4px 10px;
    border-radius: 20px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

.live-text {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent-emerald);
}

.station-title h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.station-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.header-nav {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    color: var(--text-main);
}

.nav-tab.active {
    background: var(--accent-blue);
    color: #0b0f19;
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

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

.sync-status {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent-blue);
}

.refresh-progress-container {
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
}

.refresh-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    transition: width 0.2s linear;
}

/* ==================== MAIN PANES ==================== */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

.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); }
}

/* ==================== HERO WEATHER CARD ==================== */
.hero-weather-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.85));
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

body.theme-light .hero-weather-card {
    background: linear-gradient(135deg, #e0f2fe, #ffffff);
    border-color: rgba(56, 189, 248, 0.4);
}

.hero-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.hero-icon-container {
    font-size: 4.5rem;
    filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.4));
    line-height: 1;
}

.hero-temp-block .hero-temp-value {
    font-size: 3.8rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.hero-temp-unit {
    font-size: 2rem;
    font-weight: 400;
    color: var(--accent-blue);
    margin-left: 4px;
}

.hero-condition {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 6px;
}

.hero-center-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.hero-stat-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.pill-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.pill-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.hero-right-highlights {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-left: 1px solid var(--border-color);
    padding-left: 28px;
}

.highlight-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hl-icon {
    font-size: 1.5rem;
}

.hl-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.hl-value {
    font-size: 1.1rem;
    font-weight: 700;
}

/* ==================== DASHBOARD GRID ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 0.98rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    font-size: 1.2rem;
}

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.badge-info { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-primary { background: rgba(139, 92, 246, 0.15); color: var(--accent-violet); }

/* Viento & Brújula */
.wind-body {
    display: flex;
    align-items: center;
    gap: 20px;
}

.compass-wrapper {
    flex-shrink: 0;
}

.compass-dial {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.4);
    background: radial-gradient(circle, rgba(15, 23, 42, 0.8), rgba(2, 6, 23, 0.95));
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
}

.cardinal {
    position: absolute;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-blue);
}

.cardinal.n { top: 6px; }
.cardinal.e { right: 8px; }
.cardinal.s { bottom: 6px; }
.cardinal.w { left: 8px; }

.compass-needle {
    position: absolute;
    width: 4px;
    height: 100px;
    top: 20px;
    transform-origin: center center;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.needle-tip {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 24px solid var(--accent-rose);
    margin: 0 auto;
    filter: drop-shadow(0 0 4px var(--accent-rose));
}

.compass-center {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    z-index: 2;
}

.compass-center small {
    font-size: 0.62rem;
    color: var(--accent-cyan);
}

.wind-metrics {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-row .label { color: var(--text-dim); }
.metric-row .value { font-weight: 700; }

/* Barómetro */
.gauge-display {
    text-align: center;
    margin: 12px 0 18px;
}

.big-metric {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.unit {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Pluviometría */
.rain-rate-box {
    text-align: center;
    margin-bottom: 16px;
    background: rgba(6, 182, 212, 0.06);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.rain-grid-bars {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.rain-col {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 6px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.rain-col.highlight {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.4);
}

.rain-label {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.rain-val {
    font-size: 0.88rem;
    font-weight: 700;
    margin-top: 2px;
}

/* Humedad Dual */
.dual-stat-container {
    display: flex;
    justify-content: space-around;
    margin: 12px 0;
}

.stat-circle {
    text-align: center;
}

.circle-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.sub-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.humidity-bar-container {
    margin-top: 14px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.hum-progress-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f59e0b 0%, #10b981 40%, #06b6d4 80%, #3b82f6 100%);
    position: relative;
}

.hum-progress-indicator {
    position: absolute;
    width: 6px;
    height: 14px;
    top: -3px;
    background: #ffffff;
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
    transition: left 0.5s ease;
}

/* Radiación & UV */
.solar-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
    text-align: center;
}

.solar-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 8px 4px;
    border-radius: var(--radius-sm);
}

.solar-box .big-metric {
    font-size: 1.6rem;
    margin: 4px 0;
}

.uv-scale-bar {
    display: flex;
    height: 18px;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 18px;
}

.uv-low { flex: 2; background: #10b981; }
.uv-mod { flex: 3; background: #f59e0b; }
.uv-high { flex: 2; background: #f97316; }
.uv-vhigh { flex: 3; background: #ef4444; }
.uv-ext { flex: 2; background: #8b5cf6; }

/* Calidad de Aire */
.indoor-air-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.air-metric-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.air-metric-box .big-metric {
    font-size: 1.8rem;
    margin: 4px 0;
}

/* Diagnóstico */
.diag-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.diag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.diag-val-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar-small {
    width: 70px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-small .fill {
    height: 100%;
    background: var(--accent-emerald);
}

/* Colores de texto */
.text-cyan { color: var(--accent-cyan); }
.text-blue { color: var(--accent-blue); }
.text-emerald { color: var(--accent-emerald); }
.text-amber { color: var(--accent-amber); }
.text-warning { color: #f59e0b; }
.text-yellow { color: #eab308; }
.text-success { color: var(--accent-emerald); }

/* ==================== TAB 2: GRÁFICAS ==================== */
.charts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.range-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.btn-range {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-range:hover {
    color: var(--text-main);
}

.btn-range.active {
    background: var(--accent-blue);
    color: #0b0f19;
    border-color: var(--accent-blue);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.chart-header {
    margin-bottom: 12px;
}

.chart-header h4 {
    font-size: 0.92rem;
    font-weight: 700;
}

.chart-canvas-wrapper {
    position: relative;
    height: 260px;
    width: 100%;
}

/* ==================== TAB 3: GRAFANA IFRAME ==================== */
.grafana-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    background: var(--bg-card);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.grafana-dash-select {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-gframe {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-gframe:hover, .btn-gframe.active {
    background: var(--accent-cyan);
    color: #0b0f19;
    border-color: var(--accent-cyan);
    font-weight: 700;
}

.grafana-links {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-blue);
    color: #0b0f19;
}

.btn-primary:hover {
    background: #7dd3fc;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.grafana-iframe-container {
    width: 100%;
    height: 75vh;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #181b1f;
    box-shadow: var(--shadow-card);
}

.grafana-iframe-container iframe {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==================== TAB 4: CONFIGURACIÓN ==================== */
.settings-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.settings-card h3 {
    font-size: 1.05rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.setting-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.form-select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
}

.network-links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.net-link-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s;
}

.net-link-item:hover {
    border-color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
}

.net-icon {
    font-size: 1.4rem;
}

.net-title {
    font-weight: 700;
    font-size: 0.9rem;
}

.net-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.net-arrow {
    margin-left: auto;
    font-size: 1.1rem;
    color: var(--accent-blue);
}

.guide-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.guide-steps {
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.guide-steps a {
    color: var(--accent-blue);
    text-decoration: none;
}

.guide-steps a:hover {
    text-decoration: underline;
}

/* ==================== FOOTER ==================== */
.main-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .main-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .header-nav {
        width: 100%;
        overflow-x: auto;
    }
    .hero-weather-card {
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }
    .hero-right-highlights {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        padding-top: 16px;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
}


/* Info box para Grafana público */
.grafana-box-info {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.grafana-box-info h3 {
    font-size: 1.15rem;
    margin-bottom: 12px;
}

.grafana-box-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.grafana-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.g-feat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.g-icon {
    font-size: 1.6rem;
}

.g-feat strong {
    font-size: 0.92rem;
    color: var(--text-main);
}

.g-feat span {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}
