/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00a8e8;
    --secondary-color: #00c9a7;
    --bg-dark: #0a1628;
    --bg-panel: rgba(16, 30, 60, 0.8);
    --bg-card: rgba(20, 40, 80, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #8ba3c7;
    --border-color: rgba(0, 168, 232, 0.3);
    --success-color: #00c9a7;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --gradient-primary: linear-gradient(135deg, #00a8e8 0%, #00c9a7 100%);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ==================== 登录页面 ==================== */
.login-page {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: 
        radial-gradient(ellipse at top, rgba(0, 168, 232, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(0, 201, 167, 0.1) 0%, transparent 50%),
        var(--bg-dark);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        linear-gradient(90deg, transparent 49%, rgba(0, 168, 232, 0.03) 50%, transparent 51%),
        linear-gradient(0deg, transparent 49%, rgba(0, 168, 232, 0.03) 50%, transparent 51%);
    background-size: 50px 50px;
    pointer-events: none;
}

.login-container {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 390px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 168, 232, 0.1);
    position: relative;
    z-index: 1;
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(0, 168, 232, 0.5));
}

.login-header h1 {
    font-size: 22px;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.2);
}

.login-form input::placeholder { color: rgba(139, 163, 199, 0.5); }

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 4px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 168, 232, 0.4);
}

/* ==================== 主监控页面 ==================== */
.dashboard {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(0, 168, 232, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 201, 167, 0.05) 0%, transparent 50%),
        var(--bg-dark);
    overflow: hidden;
}

.hidden { display: none !important; }

/* 顶部导航栏 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 52px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

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

.header-logo { width: 32px; height: 32px; }

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

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

#current-time {
    color: var(--text-secondary);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.logout-btn {
    padding: 6px 18px;
    background: transparent;
    border: 1px solid var(--danger-color);
    border-radius: 4px;
    color: var(--danger-color);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover { background: var(--danger-color); color: white; }

/* 主内容区 */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 30% 40% 30%;
    gap: 6px;
    padding: 6px;
    min-height: 0;
    overflow: hidden;
}

/* 面板通用 */
.left-panel, .center-panel, .right-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 32px;
    flex-shrink: 0;
    background: rgba(0, 168, 232, 0.1);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
}

.panel-title .icon { font-size: 14px; }

/* ==================== 左侧监控列表 ==================== */
.left-panel .monitor-grid {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    align-content: start;
}

.monitor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s ease;
}

.monitor-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(0, 168, 232, 0.2);
}

.monitor-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 168, 232, 0.3);
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
}

.monitor-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.status.online { background: rgba(0, 201, 167, 0.2); color: var(--success-color); }
.status.offline { background: rgba(231, 76, 60, 0.2); color: var(--danger-color); }

.monitor-preview {
    position: relative;
    padding-bottom: 56.25%;
    background: linear-gradient(135deg, #1a2a4a 0%, #0d1a2d 100%);
}

.monitor-preview .play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 24px; height: 24px;
    background: rgba(0, 168, 232, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    transition: all 0.15s ease;
}

.monitor-card:hover .play-icon {
    background: var(--primary-color);
    transform: translate(-50%, -50%) scale(1.1);
}

/* ==================== 中间区域 ==================== */
.center-panel {
    padding: 6px;
    gap: 4px;
}

.video-container {
    flex: 1;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    position: relative;
}

.placeholder-img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    opacity: 0.85;
}

.placeholder-text {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 16px;
    border-radius: 4px;
    white-space: nowrap;
}

.main-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.current-monitor-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#current-monitor-name { font-size: 14px; font-weight: 600; }

.stop-btn {
    display: none;
    padding: 5px 14px;
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--danger-color);
    border-radius: 4px;
    color: var(--danger-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.stop-btn:hover {
    background: var(--danger-color);
    color: white;
}

.stop-btn.visible { display: inline-block; }

/* 启闭机控制区（中间底部） */
.hoist-section {
    flex: 0 0 30%;
    background: var(--bg-card);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.hoist-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 36px;
    flex-shrink: 0;
    background: rgba(0, 168, 232, 0.1);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
}

.hoist-section-header .icon { font-size: 16px; }

.hoist-tabs {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.hoist-tab {
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hoist-tab:hover { color: var(--text-primary); }

.hoist-tab.active {
    background: rgba(0, 168, 232, 0.2);
    color: var(--primary-color);
}

/* 加载占位 */
.monitor-loading {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 20px;
    text-align: center;
    grid-column: 1 / -1;
    white-space: nowrap;
}

.hoist-loading { font-size: 13px; color: var(--text-secondary); align-self: center; }

.hoist-control {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.hoist-control-row {
    display: flex;
    align-items: center;
    gap: 0px;
    margin-bottom: 8px;
}

.hoist-info {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-row .label {
    color: var(--text-secondary);
    font-size: 13px;
}

.info-row .value {
    font-size: 15px;
    font-weight: 600;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 13px;
}

.status-badge.running { background: rgba(0, 201, 167, 0.2); color: var(--success-color); }
.status-badge.stopped { background: rgba(139, 163, 199, 0.2); color: var(--text-secondary); }

.hoist-control-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.control-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.open-btn { background: var(--success-color); color: white; }
.open-btn:hover { background: #00b894; }

.close-btn { background: var(--danger-color); color: white; }
.close-btn:hover { background: #c0392b; }

.hoist-opening-set {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

#opening-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    outline: none;
}

#opening-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; height: 18px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
}

#opening-value {
    width: 36px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.set-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.set-btn:hover { background: #0090c9; }

.opening-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.opening-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ==================== 右侧面板 ==================== */
.right-panel { overflow-y: auto; overflow-x: hidden; }

.right-panel .data-section { flex-shrink: 0; }
.right-panel .data-section:last-child { border-bottom: none; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* 气象站 */
.weather-section { border-bottom: 1px solid var(--border-color); }

.weather-data { padding: 6px 10px; }

/* 温度/天气并入面板标题行 */
.weather-section .panel-title {
    justify-content: space-between;
    gap: 8px;
}

.weather-section .panel-title .title-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.weather-main {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
    margin-left: auto;
    padding: 0;
    border-bottom: none;
}

.weather-temp {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 2px;
}

.temp-value {
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.temp-unit {
    font-size: 12px;
    color: var(--text-secondary);
}

.weather-desc {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px 5px;
}

.weather-item {
    background: var(--bg-card);
    padding: 3px 5px;
    border-radius: 4px;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
}

.weather-item .label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}
.weather-item .value {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* 墒情监测站 */
/* 墒情区按内容高度显示，不再拉伸占满剩余空间（避免大片空白） */
.soil-section-wrap { border-bottom: none; flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; }

.soil-tabs {
    display: flex;
    padding: 0 6px;
    gap: 2px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.soil-tab {
    padding: 3px 10px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.soil-tab:hover { color: var(--text-primary); }
.soil-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }

.soil-data {
    padding: 4px 8px;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr;
    gap: 6px;
    align-items: start;
}

/* 三列：含水率 | 温度 | 电导率 */
.soil-moisture-section { margin-bottom: 0; min-width: 0; }
.soil-temp-section, .soil-cond-section { margin-bottom: 0; min-width: 0; }

.soil-section { margin-bottom: 7px; }
.soil-section:last-child { margin-bottom: 0; }

.soil-section h4 {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 3px;
    font-weight: 500;
    white-space: nowrap;
}

.soil-layers {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.layer-name {
    width: 32px;
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.layer-value {
    width: 40px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* 土壤温度横向排列 */
.soil-temp-section h4 { margin-bottom: 4px; }

.soil-temps {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.temp-item {
    background: var(--bg-card);
    border-radius: 4px;
    padding: 2px 4px;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 3px;
}

.temp-item span:first-child {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.temp-item span:last-child {
    font-size: 11px;
    font-weight: 600;
    color: var(--warning-color);
    white-space: nowrap;
}

.conductivity-value {
    font-size: 14px;
    padding: 4px 0;
    font-weight: 600;
    color: var(--secondary-color);
    text-align: center;
    /* padding: 8px; */
    background: var(--bg-card);
    border-radius: 4px;
}

/* 大气温湿度历史曲线 */
.chart-section {
    border-bottom: none;
    flex-shrink: 0;
    min-height: 0;
}

.chart-wrapper {
    padding: 6px 8px;
    height: 245px;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ==================== 闸门流量监测 ==================== */
/* 闸门流量区吸收剩余高度，内部可滚动，避免右栏出现空白或外层滚动条 */
.gateflow-section {
    border-bottom: none;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.gateflow-tip {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: help;
    opacity: 0.7;
}

.gateflow-data {
    padding: 6px 8px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.gateflow-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.gateflow-table th {
    background: rgba(0, 168, 232, 0.12);
    color: var(--primary-color);
    padding: 6px 6px;
    text-align: left;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 168, 232, 0.2);
    white-space: nowrap;
}

.gateflow-table td {
    padding: 5px 6px;
    border-bottom: 1px solid rgba(139, 163, 199, 0.08);
    color: #b0c0d8;
}

.gateflow-table tbody tr:hover td { background: rgba(0, 168, 232, 0.04); }

.gateflow-table .gf-gate { color: var(--text-primary); font-weight: 600; white-space: nowrap; }
.gateflow-table .gf-flow { color: var(--success-color); font-weight: 600; white-space: nowrap; }
.gateflow-table .gf-cum { color: var(--warning-color); white-space: nowrap; }

.gateflow-table tfoot td {
    border-top: 1px solid rgba(0, 168, 232, 0.3);
    border-bottom: none;
    padding: 7px 6px;
    font-size: 12px;
}

.gf-total-label { color: var(--text-secondary); text-align: right; }
.gf-total-val {
    color: var(--primary-color);
    font-weight: 700;
    white-space: nowrap;
}

.gateflow-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 12px 0;
}

.gateflow-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.gateflow-meta strong {
    color: var(--warning-color);
    font-size: 14px;
}

.gateflow-updated { font-size: 11px; opacity: 0.7; }

/* 滚动条 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 2px; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* ==================== 备案信息 ==================== */
.icp-beian {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.icp-beian a,
.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.icp-beian a:hover,
.site-footer a:hover {
    color: var(--primary-color);
}

.site-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 26px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
}

.site-footer .sep { opacity: 0.4; }

/* 响应式 */
@media (max-width: 1400px) {
    .main-content { grid-template-columns: 30% 40% 30%; }
}
@media (max-width: 1200px) {
    .main-content { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
    .left-panel .monitor-grid { grid-template-columns: repeat(4, 1fr); max-height: 180px; }
    .right-panel { max-height: 300px; }
}
