/**
 * CDRRMO Dam and Reservoir Monitoring Widget Styles
 * Inspired by Bulacan PDRRMO dam level monitoring design
 *
 * @version 1.0.0
 */

/* ============================================================
   CONTAINER
   ============================================================ */

.dam-reservoir-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.95), rgba(15, 23, 42, 0.98));
    border-radius: 12px;
    border: 1px solid rgba(0, 168, 232, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.dam-section {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.dam-section .section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.2), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dam-section .section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
}

.dam-section .section-icon {
    font-size: 1.3rem;
}

.dam-section .live-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    background: #22c55e;
    color: white;
    border-radius: 4px;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================================
   DAM GRID
   ============================================================ */

.dam-widget-content {
    padding: 1rem;
}

.dam-basis {
    padding: 0.65rem 1rem 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.35);
}

.dam-basis-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dam-basis-label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
}

.dam-basis-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.dam-basis-chip {
    font-size: 0.65rem;
    color: #e2e8f0;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
}

.dam-basis-chip.active {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(34, 197, 94, 0.18);
}

.dam-basis-chip.inactive {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(148, 163, 184, 0.12);
}

.dam-context-row {
    margin-top: 0.45rem;
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    font-size: 0.68rem;
    color: #cbd5e1;
}

.dam-policy-note {
    margin-top: 0.45rem;
    font-size: 0.67rem;
    color: #fbbf24;
}

.dam-nowcast-row {
    margin-top: 0.55rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    gap: 0.5rem;
}

.dam-nowcast-level {
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.dam-nowcast-level.low {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
}

.dam-nowcast-level.moderate {
    color: #eab308;
    border-color: rgba(234, 179, 8, 0.45);
    background: rgba(234, 179, 8, 0.12);
}

.dam-nowcast-level.high {
    color: #fb923c;
    border-color: rgba(249, 115, 22, 0.45);
    background: rgba(249, 115, 22, 0.12);
}

.dam-nowcast-level.critical {
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
}

.dam-nowcast-score {
    color: #cbd5e1;
}

.dam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .dam-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   DAM GAUGE CARD
   ============================================================ */

.dam-gauge-card {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 10px;
    padding: 1rem;
    border-left: 4px solid #22c55e;
    transition: all 0.3s ease;
}

.dam-gauge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.dam-gauge-card.alert {
    border-left-color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.dam-gauge-card.alarm {
    border-left-color: #f97316;
    background: rgba(249, 115, 22, 0.15);
}

.dam-gauge-card.critical {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, 0.2);
    animation: pulse-critical 1.5s infinite;
}

@keyframes pulse-critical {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ============================================================
   DAM HEADER
   ============================================================ */

.dam-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.dam-title {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.dam-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f1f5f9;
}

.dam-type {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dam-location {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.75rem;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.normal {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.status-badge.alert {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.4);
}

.status-badge.alarm {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.status-badge.critical {
    background: rgba(220, 38, 38, 0.3);
    color: #f87171;
    border: 1px solid rgba(220, 38, 38, 0.5);
    animation: badge-pulse 1s infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================================
   DAM GAUGE VISUAL (TANK STYLE)
   ============================================================ */

.dam-gauge-visual {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.dam-gauge {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tank-container {
    position: relative;
    width: 80px;
    height: 100px;
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.tank-container::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -2px;
    right: -2px;
    height: 10px;
    background: rgba(148, 163, 184, 0.5);
    border-radius: 4px 4px 0 0;
}

.water-level {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transition: height 0.5s ease;
    overflow: hidden;
}

.water-surface {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent);
    animation: wave 2s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(2px); }
}

.tank-markers {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 20px;
}

.tank-markers .marker {
    position: absolute;
    right: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
}

.tank-markers .marker.spillway {
    background: #f97316;
}

.tank-markers .marker.full {
    background: #22c55e;
}

.tank-markers .marker-label {
    position: absolute;
    right: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.5rem;
    color: #94a3b8;
    white-space: nowrap;
    display: none;
}

.tank-container:hover .marker-label {
    display: block;
}

.gauge-reading {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge-reading .current-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}

.gauge-reading .unit {
    font-size: 0.75rem;
    color: #64748b;
}

/* ============================================================
   STORAGE INDICATOR
   ============================================================ */

.storage-indicator {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.storage-bar {
    height: 8px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.storage-fill {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4, #0891b2);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.storage-label {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ============================================================
   DAM DETAILS
   ============================================================ */

.dam-details {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.5rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.detail-label {
    color: #64748b;
}

.detail-value {
    color: #e2e8f0;
    font-weight: 500;
}

.flow-info {
    display: flex;
    justify-content: space-around;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.flow-info .inflow {
    color: #22c55e;
}

.flow-info .outflow {
    color: #f97316;
}

/* ============================================================
   GATE STATUS
   ============================================================ */

.gate-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 6px;
}

.gate-label {
    font-size: 0.75rem;
    color: #64748b;
}

.gate-indicators {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
}

.gate-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.25rem 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 4px;
    cursor: help;
}

.gate-indicator.open {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.gate-indicator.closed {
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.gate-icon {
    font-size: 0.8rem;
}

.gate-percent {
    font-size: 0.6rem;
    color: #94a3b8;
}

/* ============================================================
   AFFECTED AREAS
   ============================================================ */

.affected-areas {
    margin-bottom: 0.5rem;
}

.areas-label {
    font-size: 0.7rem;
    color: #64748b;
    display: block;
    margin-bottom: 0.25rem;
}

.barangay-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.barangay-tag {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    background: rgba(0, 168, 232, 0.15);
    color: #00a8e8;
    border-radius: 3px;
    border: 1px solid rgba(0, 168, 232, 0.3);
}

.barangay-more {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    border-radius: 3px;
}

/* ============================================================
   DAM ALERT
   ============================================================ */

.dam-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 6px;
    margin-top: 0.5rem;
}

.dam-alert .alert-icon {
    font-size: 1rem;
}

.dam-alert .alert-text {
    font-size: 0.75rem;
    color: #fca5a5;
    line-height: 1.3;
}

.dam-stale-note {
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: #fcd34d;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 6px;
    padding: 0.45rem 0.55rem;
}

/* ============================================================
   PROPOSED DAMS SECTION
   ============================================================ */

.proposed-dams-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.proposed-header {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.dam-proposed-card {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    padding: 0.75rem;
    border: 1px dashed rgba(148, 163, 184, 0.3);
}

.dam-proposed-card .proposed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dam-proposed-card .dam-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}

.proposed-badge {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    border-radius: 4px;
    text-transform: uppercase;
}

.proposed-location {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.proposed-benefits {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.proposed-benefits strong {
    color: #e2e8f0;
    display: block;
    margin-bottom: 0.25rem;
}

.proposed-benefits ul {
    margin: 0;
    padding-left: 1rem;
}

.proposed-benefits li {
    margin-bottom: 0.15rem;
}

.dam-proposed-card .barangay-list {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ============================================================
   FOOTER
   ============================================================ */

.dam-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.4);
}

.dam-footer .last-update {
    font-size: 0.75rem;
    color: #64748b;
}

.dam-footer .refresh-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 168, 232, 0.2);
    color: #00a8e8;
    border: 1px solid rgba(0, 168, 232, 0.4);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dam-footer .refresh-btn:hover {
    background: rgba(0, 168, 232, 0.3);
}

.dam-footer .refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   NO DATA STATE
   ============================================================ */

.no-data {
    text-align: center;
    padding: 2rem;
    color: #64748b;
    font-size: 0.9rem;
}

/* ============================================================
   ERROR STATE
   ============================================================ */

.dam-section.error .error-content {
    text-align: center;
    padding: 2rem;
}

.dam-section.error .error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.dam-section.error p {
    color: #94a3b8;
    margin-bottom: 1rem;
}

.dam-section.error .retry-btn {
    padding: 0.5rem 1rem;
    background: rgba(0, 168, 232, 0.2);
    color: #00a8e8;
    border: 1px solid rgba(0, 168, 232, 0.4);
    border-radius: 4px;
    cursor: pointer;
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */

@media (max-width: 768px) {
    .dam-reservoir-container {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .dam-gauge-card {
        padding: 0.75rem;
    }

    .dam-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .dam-gauge {
        flex-direction: column;
    }

    .tank-container {
        width: 100%;
        max-width: 200px;
        height: 80px;
    }

    .gauge-reading {
        flex-direction: row;
        gap: 0.5rem;
    }

    .gauge-reading .current-value {
        font-size: 1.2rem;
    }

    .dam-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* ============================================================
   DARK MODE SUPPORT
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .dam-reservoir-container {
        background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(3, 7, 18, 0.99));
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .dam-gauge-card,
    .water-level,
    .storage-fill {
        transition: none;
    }

    .water-surface,
    .status-badge.critical,
    .dam-gauge-card.critical,
    .live-badge {
        animation: none;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .dam-reservoir-container {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .dam-gauge-card {
        background: white;
        border: 1px solid #ddd;
    }

    .dam-name,
    .dam-header,
    .status-badge {
        color: black !important;
    }

    .dam-footer .refresh-btn {
        display: none;
    }
}
