/* Water-themed color scheme - light but not overly white */
:root {
    --water-blue: #4A90E2;
    --water-blue-dark: #357ABD;
    --water-blue-light: #6BA3E8;
    --water-teal: #5FB3B3;
    --water-cyan: #7EC8E3;
    --background-light: #F0F7FA;
    --background-card: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #5A6C7D;
    --border-color: #D1E7F0;
    --shadow: rgba(74, 144, 226, 0.1);
    --shadow-hover: rgba(74, 144, 226, 0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background-light) 0%, #E8F4F8 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--water-blue) 0%, var(--water-teal) 100%);
    color: white;
    padding: 2rem 0 5rem 0;
    box-shadow: 0 4px 6px var(--shadow);
    position: relative;
    overflow: hidden;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
    z-index: 2;
}

.logo {
    height: 120px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.header-text h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.95;
    font-weight: 300;
}

.header-water-scene {
    position: absolute;
    inset: auto -10% -90px -10%;
    height: 220px;
    pointer-events: none;
    z-index: 1;
}

.header-river-glow {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 120px;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.05) 65%);
    opacity: 0.6;
    animation: riverGlow 6s ease-in-out infinite;
}

.wave {
    position: absolute;
    bottom: 0;
    left: -50%;
    width: 200%;
    height: 140px;
    border-radius: 45% 55% 50% 50%;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.15) 70%, rgba(255, 255, 255, 0));
    opacity: 0.55;
    animation: waveDrift 12s linear infinite;
}

.wave::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6) 0%, transparent 45%);
    opacity: 0.4;
}

.wave.wave-back {
    height: 160px;
    opacity: 0.3;
    animation-duration: 20s;
    bottom: 0;
    filter: blur(1px);
}

.wave.wave-mid {
    height: 140px;
    opacity: 0.45;
    animation-duration: 15s;
    animation-direction: reverse;
    bottom: 10px;
}

.wave.wave-front {
    height: 120px;
    opacity: 0.7;
    animation-duration: 10s;
    bottom: 25px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

@keyframes waveDrift {
    0% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(-25%) translateY(6px);
    }
    100% {
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes riverGlow {
    0% {
        opacity: 0.35;
        transform: translateY(0);
    }
    50% {
        opacity: 0.75;
        transform: translateY(-10px);
    }
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
}

.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.reservoir-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.reservoir-card {
    background: var(--background-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.reservoir-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-hover);
}

.card-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.card-header h2 {
    color: var(--water-blue-dark);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.dam-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.dam-name {
    color: var(--text-secondary);
    font-size: 1rem;
    font-style: italic;
    margin: 0;
    flex: 1;
}

.last-updated-header {
    color: var(--text-secondary);
    font-size: 1rem;
    font-style: italic;
    white-space: nowrap;
}

.card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #F8FBFC 0%, #F0F7FA 100%);
    border-radius: 8px;
    align-items: center;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-item-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.stat-label-compact {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value-compact {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--water-blue-dark);
}

.stat-unit-compact {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--water-blue-dark);
    margin-bottom: 0.25rem;
}

.stat-value.stat-timestamp {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.stat-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--background-light);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    color: var(--water-blue-dark);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0 0.5rem 0;
    padding: 0.5rem 0.75rem;
}

.chart-controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.time-range-select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.time-range-select:hover {
    border-color: var(--water-blue);
}

.time-range-select:focus {
    outline: none;
    border-color: var(--water-blue);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* Overlay Charts Section */
.overlay-charts-section {
    max-width: 1200px;
    margin: 3rem auto 2rem;
    padding: 0 1rem;
}

.section-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.overlay-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.overlay-chart-container {
    background: var(--background-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
}

.overlay-chart-container h3 {
    color: var(--water-blue-dark);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
}

.overlay-chart-panel {
    width: 100%;
    min-height: 300px;
    height: 300px;
    position: relative;
}

.overlay-chart-panel canvas {
    max-height: 300px;
}

.chart-container-compact {
    padding: 0.75rem;
    background: var(--background-light);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-container-compact:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.chart-container-compact h4 {
    color: var(--water-blue-dark);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-align: center;
}

.grafana-panel {
    width: 100%;
    min-height: 300px;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.grafana-panel-compact {
    width: 100%;
    min-height: 150px;
    height: 150px;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
}

.grafana-panel-compact canvas {
    max-height: 150px;
}

/* Grafana iframe styling */
.grafana-panel iframe {
    width: 100%;
    height: 400px;
    border: none;
}

.grafana-panel-compact iframe {
    width: 100%;
    height: 150px;
    border: none;
}

/* Chart Modal */
.chart-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

.chart-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-modal-content {
    background-color: white;
    margin: auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
}

.chart-modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.chart-modal-close:hover {
    color: var(--water-blue-dark);
}

#chart-modal-title {
    color: var(--water-blue-dark);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

#chart-modal-body {
    min-height: 500px;
}

#chart-modal-body .grafana-panel {
    min-height: 500px;
    height: 600px;
    position: relative;
}

#chart-modal-body .grafana-panel canvas {
    height: 600px !important;
}

#chart-modal-body .grafana-panel iframe {
    height: 600px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.footer {
    background: var(--water-blue-dark);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

.footer p {
    margin: 0.5rem 0;
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.9;
    font-style: italic;
}

/* Loading states */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--water-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-text h1 {
        font-size: 2rem;
    }

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

    .card-stats {
        grid-template-columns: 1fr;
    }
}

