:root {
    --bg-color: #1a1a2e;
    --card-bg-color: #16213e;
    --border-color: #0f3460;
    --text-color: #e94560;
    --sub-text-color: #dcdcdc;
    --font-family: 'Noto Sans SC', sans-serif;
    --level-normal-bg: #1e847f;
    --level-warning-bg: #f39c12;
    --level-critical-bg: #e74c3c;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--sub-text-color);
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header h1 {
    color: var(--text-color);
    font-weight: 500;
    font-size: 1.8rem;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-meta {
    font-size: 0.85rem;
    color: rgba(220, 220, 220, 0.75);
}

.connection-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.connection-dot.connected { 
    background-color: #2ecc71; 
    box-shadow: 0 0 8px #2ecc71; 
}

.connection-dot.offline { 
    background-color: #e74c3c; 
    box-shadow: 0 0 4px rgba(231, 76, 60, 0.3);
}

.connection-dot.connecting { 
    background-color: #f39c12; 
    box-shadow: 0 0 6px rgba(243, 156, 18, 0.5);
    animation: pulse-connecting 1.5s ease-in-out infinite;
}

@keyframes pulse-connecting {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.status-indicator.online { background-color: #2ecc71; box-shadow: 0 0 8px #2ecc71; }
.status-indicator.offline { background-color: #e74c3c; }
.status-indicator.connecting { background-color: #f39c12; }

.main-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column */
    gap: 20px;
}

.card {
    background-color: var(--card-bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.card-header h3 {
    font-weight: 400;
    flex: 1;
}

.timestamp {
    font-size: 0.75rem;
    color: #888;
    font-weight: 400;
    opacity: 0.8;
    white-space: nowrap;
}

.header-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--text-color), #f39c12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3);
    animation: pulse-glow 2s ease-in-out infinite alternate;
}



@keyframes pulse-glow {
    0% { box-shadow: 0 4px 12px rgba(233, 69, 96, 0.3); }
    100% { box-shadow: 0 6px 20px rgba(233, 69, 96, 0.5); }
}



.header-icon i {
    color: white;
    font-size: 1.2rem;
}

.value-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    padding: 20px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 120px;
    justify-content: center;
}

.card-body .main-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin: 0;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.card-body .main-value .value,
.card-body .main-value .unit {
    color: #fff;
    background: linear-gradient(45deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-body .main-value .value {
    font-size: 3.5rem;
    font-weight: 700;
}

.card-body .main-value .unit {
    font-size: 1.3rem;
    font-weight: 400;
}

.value-label {
    font-size: 0.85rem;
    color: var(--accent-color);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    opacity: 0.9;
}

.status-text {
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 4px;
    padding: 5px 0;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.status-text.status-normal {
    color: #2ecc71;
    background-color: rgba(46, 204, 113, 0.1);
}

.status-text.status-warning {
    color: #f39c12;
    background-color: rgba(243, 156, 18, 0.1);
}

.status-text.status-danger {
    color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

.status-text i {
    margin-right: 8px;
}

.card-body .sub-value {
    text-align: center;
    margin-top: 15px;
    margin-bottom: 10px;
}

.sub-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(155, 89, 182, 0.1) 100%);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(52, 152, 219, 0.2);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sub-item:hover {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(155, 89, 182, 0.15) 100%);
    border-color: rgba(52, 152, 219, 0.3);
    transform: translateY(-1px);
}

.sub-item i {
    color: var(--accent-color);
    font-size: 1rem;
}

.thresholds {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    font-size: 0.9rem;
}

.threshold-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.threshold-item:nth-child(1) {
    border-left-color: #f39c12; /* 警告水位 - 橙色 */
}

.threshold-item:nth-child(2) {
    border-left-color: #e74c3c; /* 危险水位 - 红色 */
}

.threshold-item:nth-child(3) {
    border-left-color: #9b59b6; /* 2024年洪灾水位 - 紫色 */
}

.threshold-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.threshold-item:nth-child(1) i {
    color: #f39c12; /* 警告水位图标 - 橙色 */
    font-size: 0.8rem;
}

.threshold-item:nth-child(2) i {
    color: #e74c3c; /* 危险水位图标 - 红色 */
    font-size: 0.8rem;
}

.threshold-item:nth-child(3) i {
    color: #9b59b6; /* 2024年洪灾水位图标 - 紫色 */
    font-size: 0.8rem;
}

#water-level-card {
    transition: background-color 0.5s ease;
}







/* CCTV Card */
.cctv-card {
    grid-column: auto; /* Reset for mobile */
}

.cctv-container {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    background-color: #000;
    border-radius: 4px;
    min-height: 200px;
}

.cctv-container img, .cctv-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.cctv-container img {
    object-fit: contain;
    background-color: #000;
}

.cctv-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #666;
}

.cctv-placeholder i {
    font-size: 3rem;
    margin-bottom: 10px;
}

.cctv-timestamp {
    text-align: center;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #aaa;
}

.chart-card-water { grid-column: 1 / -1; }


.chart-container {
    flex-grow: 1;
    position: relative;
    height: 300px; /* Give the container a defined height */
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--text-color);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .main-grid {
        grid-template-columns: 3fr 7fr; /* 30% / 70% split */
        grid-template-areas:
            "water-level   cctv"
            "water-chart   water-chart";
    }

    #water-level-card {
        grid-area: water-level;
    }

    .cctv-card {
        grid-area: cctv;
    }

    #water-level-chart-card {
        grid-area: water-chart;
    }

    /* 桌面端增大字体和容器尺寸 */
    .value-container {
        padding: 30px 15px;
        min-height: 150px;
    }

    .card-body .main-value .value {
        font-size: 4.5rem;
    }

    .card-body .main-value .unit {
        font-size: 1.5rem;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Layout - Small phones */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 15px;
        padding-bottom: 15px;
    }

    .header-title {
        width: 100%;
    }

    .header h1 {
        font-size: 1.5rem;
        width: 100%;
        gap: 10px;
    }
    
    .header h1 i {
        margin-right: 0;
    }
    
    .connection-dot {
        width: 10px;
        height: 10px;
    }
    
    .status {
        width: 100%;
        justify-content: space-between;
        background: rgba(255, 255, 255, 0.05);
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 0.85rem;
    }
    
    .main-grid {
        gap: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    .card-header {
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .header-icon {
        width: 35px;
        height: 35px;
    }
    
    .header-icon i {
        font-size: 1rem;
    }
    
    .card-header h3 {
        font-size: 1.1rem;
    }
    
    .card-body .main-value .value {
        font-size: 2.2rem;
    }
    
    .card-body .main-value .unit {
        font-size: 1rem;
    }
    
    .thresholds {
        gap: 6px;
    }
    
    .threshold-item {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
    

    
    .chart-container {
        height: 250px;
    }
    
    .cctv-container {
        /* 保持4:3宽高比 - 不覆盖padding-top: 75% */
        min-height: 160px;
    }
    
    .cctv-placeholder i {
        font-size: 2rem;
    }
    
    .sub-item {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .value-label {
        font-size: 0.8rem;
    }
}

/* Mobile Layout - Large phones and small tablets */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        padding: 15px;
    }

    .header {
        margin-bottom: 18px;
    }

    .header-title {
        width: 100%;
    }

    .header h1 {
        font-size: 1.6rem;
    }
    
    .status {
        font-size: 0.9rem;
    }
    
    .main-grid {
        gap: 18px;
    }
    
    .card {
        padding: 18px;
    }
    
    .card-body .main-value .value {
        font-size: 2.5rem;
    }
    
    .chart-container {
        height: 280px;
    }
    
    .cctv-container {
        /* 保持4:3宽高比 */
        min-height: 200px;
    }
}

/* Tablet Layout */
@media (min-width: 769px) and (max-width: 1023px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .chart-card-water {
        grid-column: 1 / -1;
    }
    
    .cctv-card {
        grid-column: 1 / -1;
    }
} 