/**
 * SCADA响应式样式
 */

/* 导航：刘海安全区 */
.navbar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(70px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
}

@media (max-width: 991px) {
    .navbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .navbar .logo-container {
        position: absolute !important;
        left: max(16px, env(safe-area-inset-left, 0px)) !important;
        right: auto !important;
        top: env(safe-area-inset-top, 0px) !important;
        height: 70px;
        display: flex !important;
        align-items: center;
        margin: 0 !important;
        z-index: 1000;
    }

    .navbar .logo-text {
        font-size: 20px;
    }

    .navbar .nav-menu {
        display: none !important;
    }

    .navbar .mobile-menu-toggle {
        display: flex !important;
        z-index: 1001;
        margin-left: auto;
    }

    .navbar .mobile-menu.active {
        display: block !important;
        background: rgba(10, 25, 47, 0.98) !important;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        border-bottom: 1px solid rgba(0, 198, 251, 0.2);
    }

    .navbar .mobile-menu .mobile-nav-link {
        color: #e8f4fc !important;
    }

    .navbar .mobile-menu .mobile-nav-link:hover,
    .navbar .mobile-menu .mobile-nav-link.active {
        color: #00c6fb !important;
        background-color: rgba(0, 198, 251, 0.12);
    }

    .navbar .mobile-menu-toggle span {
        background-color: #1e6fa8;
    }

    .navbar .mobile-menu-toggle.active span {
        background-color: #ff3b30;
    }
}

@media (min-width: 992px) {
    html:not(.app-client) .navbar .mobile-menu-toggle,
    html:not(.app-client) .navbar .mobile-menu {
        display: none !important;
    }
}

/* 移动端不播背景视频，poster 保底 */
@media (max-width: 991px) {
    .video-background .desktop-bg-video {
        display: none !important;
    }

    .video-poster {
        opacity: 1 !important;
    }
}

@media (max-width: 1200px) {
    .charts-grid.scada-layout {
        grid-template-columns: 1fr;
    }
}

/* 平板及以下：告警置顶（紧跟遥测卡片后） */
@media (max-width: 992px) {
    .charts-grid.scada-layout {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .charts-grid.scada-layout .alert-panel {
        order: 1;
    }

    .charts-grid.scada-layout .trend-chart {
        order: 2;
    }

    .charts-grid.scada-layout .bar-chart-container {
        order: 3;
    }

    .charts-grid.scada-layout .pie-chart-container {
        order: 4;
    }

    .chart-container {
        width: 100%;
        min-height: 320px;
    }

    .chart-container canvas {
        min-height: 260px;
        max-height: 320px !important;
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 12px;
        padding-top: calc(12px + 70px + env(safe-area-inset-top, 0px));
        box-sizing: border-box;
    }

    .status-header {
        padding: 10px 12px;
    }
    
    .status-header-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .status-header-row-1 .status-header-title {
        flex: 1 1 100%;
        min-width: 0;
    }
    
    .time-display,
    .time-display--center {
        width: 100%;
        text-align: center;
        margin-top: 2px;
    }

    .time-display--center .last-update-time {
        white-space: normal;
        line-height: 1.3;
        font-size: clamp(1.05rem, 4.2vw, 1.4rem);
    }
    
    .status-header-row-2 {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .device-status-panel {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .device-status-item {
        font-size: 0.8rem;
    }

    .device-detail-btn {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 0.85rem;
        text-align: center;
    }

    .status-indicator {
        width: 100%;
        justify-content: flex-start;
    }
    
    .nav-menu {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .mobile-menu.active {
        display: block;
    }
    
    .result-content.dual-column {
        grid-template-columns: 1fr;
    }
    
    .analysis-controls {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .btn, .refresh-btn, .btn-export {
        min-width: 0;
        min-height: 46px;
        padding: 12px 14px;
        font-size: 15px;
        width: 100%;
    }
    
    .data-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .data-card {
        padding: 14px 12px;
        min-width: 0;
    }

    .param-name {
        font-size: 13px;
    }

    .param-value {
        font-size: clamp(18px, 5.5vw, 24px);
        word-break: break-word;
        line-height: 1.2;
    }

    .param-unit,
    .param-range {
        font-size: 11px;
    }
    
    .last-update-time {
        font-size: 20px;
    }

    .chart-legend {
        gap: 8px;
    }

    .chart-legend label {
        font-size: 12px;
    }

    .level-ranges {
        flex-direction: column;
        align-items: flex-start;
    }

    /* SCADA 报告顶栏：手机对齐（徽章 / 导出 / 状态同一高度） */
    .result-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
        padding-bottom: 12px;
    }

    .result-title {
        font-size: 1.05rem;
        line-height: 1.35;
        width: 100%;
    }

    .result-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }

    .result-actions .compliance-badge,
    .result-actions .export-btn,
    .result-actions .result-status {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
        min-height: 40px;
        height: 40px;
        margin: 0;
        padding: 0 10px;
        font-size: 13px;
        line-height: 1;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        white-space: nowrap;
    }

    .result-actions .result-status {
        font-weight: 700;
    }
}

@media (max-width: 480px) {
    .btn, .refresh-btn, .btn-export {
        min-width: 100%;
    }
    
    .status-header-title h1,
    .status-header h1 {
        font-size: 1rem;
        line-height: 1.35;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }
    
    .param-value {
        font-size: 22px;
    }
}

/* 竖屏（含移动端竖屏）：Monitoring Site Type 四个按钮 2×2；横屏保持默认横向 */
@media (orientation: portrait) {
    .scene-switcher {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
        gap: 8px;
    }

    .scene-switcher-label {
        grid-column: 1 / -1;
        margin-bottom: 2px;
    }

    .scene-link {
        width: 100%;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        white-space: normal;
        line-height: 1.25;
        border-radius: 12px;
        padding: 0.5rem 0.55rem;
        font-size: 0.78rem;
        box-sizing: border-box;
        flex: none;
    }
}

/* 微信：底部工具栏安全区 + 导出提示样式 */
.wechat-browser .analysis-controls,
.wechat-browser .analysis-result,
.wechat-browser .container {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.wechat-browser .export-btn[disabled],
.wechat-browser .btn-export[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}
