/* Tema Escuro (padrão) */
:root {
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --primary-blue: #14addb;
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --border-color: #334155;
    --status-verde: #13d85c;
    --status-amarelo: #f3c33e;
    --status-laranja: #e6520e;
    --status-vermelho: #ff0000;
    --chovendo: #ffffffd8;
    --semchuva: #ffffff0e;
    --track-bg: rgba(255, 255, 255, 0.07);
}

/* Tema Claro */
:root.light-theme {
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --primary-blue: #0284c7;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --border-color: #cbd5e1;
    --status-verde: #16a34a;
    --status-amarelo: #eab308;
    --status-laranja: #d97706;
    --status-vermelho: #dc2626;
    --chovendo: #3b82f6;
    --semchuva: #9ca3af;
    --track-bg: rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    padding: 5px;
    background-image: radial-gradient(circle at top right, #1e293b, #0f172a);
    min-height: 100vh;
    font-family: "Inter", sans-serif;
    transition: background-color 0.4s ease, color 0.4s ease, background-image 0.4s ease;
}

:root.light-theme body {
    background-image: radial-gradient(circle at top right, #f0f4f8, #f8fafc);
}

header {
    text-align: center;
    margin-bottom: 16px;
}

h1 {
    font-family: "Outfit", sans-serif;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: scale(1.1);
}

.update-info {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 100%;
    background-color: var(--status-verde);
    animation: pulse-fade 2s ease-out infinite;
}

@keyframes pulse-fade {
    0% {
        opacity: 1;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.5);
    }
    100% {
        opacity: 0;
        transform: scale(2.5);
    }
}

.auto-update-text {
    font-size: 13px;
    color: var(--text-dim);
    margin: 10px 0;
    font-weight: 500;
}

#critical-alert-banner {
    display: none;
    margin: 12px auto;
    max-width: 1000px;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

#critical-alert-banner.show {
    display: block;
}

.alert-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 2px;
}

.alert-header i {
    font-size: 16px;
    flex-shrink: 0;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 0;
}

.alert-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 10px;
    border-radius: 4px;
    border-left: 3px solid;
    font-size: 12px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.alert-item.critico {
    border-color: #ef4444;
}

.alert-item.atencao {
    border-color: #f59e0b;
}

.alert-item.observacao {
    border-color: #f3c33e;
}

#rain-section {
    margin: 12px auto;
    max-width: 1000px;
    padding: 0 4px;
}

#rain-section h3 {
    font-family: "Outfit", sans-serif;
    font-size: 15px;
    color: #60a5fa;
    margin-bottom: 6px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.rain-list-compact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    line-height: 1.1;
    color: #e2e8f0;
}

.rain-item-compact {
    background: rgba(20, 173, 219, 0.06);
    border: 0px solid rgba(20, 173, 219, 0.15);
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 16px;
    display: flex;
    max-width: 1000px;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
}

.rain-item-compact strong {
    color: #cbd5e1;
    font-weight: 500;
    min-width: 140px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rain-value {
    color: #7dd3fc;
    font-weight: 600;
}

.level-value {
    font-weight: 500;
}

.stations-grid {
    display: grid;
    gap: 10px;
    max-width: 1400px;
    margin: 0 auto;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, border-color 0.3s ease, background-color 0.4s ease;
    position: relative;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-blue);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.card h2 {
    font-family: "Outfit", sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.river-name {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 200;
    margin-top: 2px;
}

.level-main {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
    gap: 2px;
}

.current-level {
    font-family: "Outfit", sans-serif;
    font-size: 45px;
    font-weight: 800;
}

.lvl-verde {
    color: var(--status-verde);
}

.lvl-amarelo {
    color: var(--status-amarelo);
}

.lvl-laranja {
    color: var(--status-laranja);
}

.lvl-vermelho {
    color: var(--status-vermelho);
}

.lvl-critico {
    color: var(--status-vermelho);
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% {
        opacity: 0.2;
    }
}

.unit {
    font-size: 14px;
    color: var(--text-dim);
    margin-left: 3px;
}

.trend-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.trend-up {
    color: #ff5a5a;
}

.trend-up.strong {
    background: rgba(255, 90, 90, 0.2);
    border: 1px solid #ff5a5a;
}

.trend-down {
    color: #48ff00;
}

.trend-down.strong {
    background: rgba(72, 255, 0, 0.2);
    border: 1px solid #48ff00;
}

.trend-stable {
    color: var(--text-dim);
}

.temp-badge {
    font-size: 11px;
    color: var(--primary-blue);
    font-weight: 700;
    background: rgba(20, 173, 219, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(20, 173, 219, 0.2);
    margin-top: 4px;
    display: inline-block;
}

.rain-accumulated {
    display: flex;
    gap: 12px;
    margin: 10px 0;
    padding: 10px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 8px;
    flex-wrap: wrap;
}

.rain-period {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 100px;
    padding: 6px 8px;
    background: rgba(20, 173, 219, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(20, 173, 219, 0.15);
}

.rain-label {
    font-size: 10px;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rain-period .rain-value {
    font-size: 16px;
    font-weight: 700;
    color: #60a5fa;
}

.video-feed-btn {
    background: linear-gradient(135deg, var(--primary-blue), #0ea5e9);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    transition: all 0.3s ease;
    letter-spacing: 0px;
    box-shadow: 0 4px 12px rgba(20, 173, 219, 0.3);
    flex: 1;
}

.video-feed-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20, 173, 219, 0.4);
    background: linear-gradient(135deg, #0ea5e9, var(--primary-blue));
}

.video-feed-btn:disabled {
    background: rgba(148, 163, 184, 0.3);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.video-feed-btn i {
    font-size: 12px;
}

.map-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    transition: all 0.3s ease;
    letter-spacing: 0px;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    flex: 1;
}

.map-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}

.map-btn:disabled {
    background: rgba(148, 163, 184, 0.3);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.map-btn i {
    font-size: 12px;
}

.buttons-container {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.level-chart {
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.level-chart .chart-title {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    align-items: center;
}

.level-track {
    height: 12px;
    background: var(--track-bg);
    border-radius: 12px;
    position: relative;
}

.level-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--status-verde), #7ee08a);
    border-radius: 12px;
    position: relative;
    transition: width 700ms ease;
}

.threshold {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 20px;
    transform: translateX(-50%);
    z-index: 1;
}

.legend {
    margin-top: 16px;
    font-size: 10px;
    font-stretch: condensed;
    color: var(--text-dim);
    display: block;
    flex-wrap: wrap;
    gap: 0px;
    justify-content: space-between;
    white-space: nowrap;
}

.legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend strong {
    font-weight: 600;
    color: #e2e8f0;
}

.marker-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.progress-alert-container {
    margin: 8px 0 12px 0;
    height: 1px;
    background: rgba(223, 186, 108, 0.411);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-alert-bar {
    height: 100%;
    width: 0%;
    transition: width 800ms ease, background 400ms ease;
}

.progress-alert-label {
    position: absolute;
    top: -20px;
    right: 4px;
    font-size: 10px;
    font-weight: 600;
    color: #e2e8f0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

#loader {
    display: none;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(101, 178, 241, 0.1);
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

main {
    padding-bottom: 20px;
}

.normal-diff {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    text-align: center;
}

.above-normal {
    color: #60a5fa;
}

.below-normal {
    color: #94a3b8;
}

.at-normal {
    color: #86efac;
}

/* ========================================================
   AJUSTES PARA TEMA CLARO
   ======================================================== */

:root.light-theme .card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

:root.light-theme .theme-toggle:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

:root.light-theme #critical-alert-banner {
    background: rgba(248, 250, 252, 0.8);
}

:root.light-theme .alert-item {
    background: rgba(0, 0, 0, 0.03);
}

:root.light-theme .rain-item-compact {
    background: rgba(2, 132, 199, 0.06);
}

:root.light-theme .level-chart {
    background: rgba(0, 0, 0, 0.05);
}

:root.light-theme .video-feed-btn {
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

:root.light-theme .video-feed-btn:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.3);
}

:root.light-theme .map-btn {
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

:root.light-theme .map-btn:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}

:root.light-theme #loader {
    border-color: rgba(2, 132, 199, 0.1);
    border-top-color: var(--primary-blue);
}

:root.light-theme #rain-section h3 {
    color: var(--primary-blue);
}

:root.light-theme .temp-badge {
    border-color: rgba(2, 132, 199, 0.3);
    background: rgba(2, 132, 199, 0.08);
}

:root.light-theme .rain-accumulated {
    background: rgba(2, 132, 199, 0.08);
    border-color: rgba(2, 132, 199, 0.25);
}

:root.light-theme .rain-period {
    background: rgba(2, 132, 199, 0.06);
    border-color: rgba(2, 132, 199, 0.2);
}

:root.light-theme .rain-label {
    color: #475569;
}

:root.light-theme .rain-period .rain-value {
    color: #0284c7;
}

:root.light-theme .legend {
    color: #3f445c;
}

:root.light-theme .legend strong {
    color: #1e293b;
}

:root.light-theme .above-normal {
    color: #0277d1;
}

:root.light-theme .below-normal {
    color: #546e7a;
}

:root.light-theme .at-normal {
    color: #216c3b;
}
