/**
 * SCADA监控面板样式
 */

#realtime-monitor {
    padding-top: calc(4rem + 70px);
}

/* 顶部区域：上下两排，减少遮挡 */
.status-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, rgba(58, 154, 217, 0.65) 0%, rgba(13, 148, 136, 0.65) 100%);
    padding: 12px 16px;
    border-radius: 10px;
    color: white;
    backdrop-filter: blur(10px);
}

.status-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.status-header-row-1 {
    align-items: flex-start;
}

.status-header-title h1 {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 2px;
}

.status-header-title p {
    font-size: 0.85rem;
    opacity: 0.95;
}

.status-header-row-2 {
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

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

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4CAF50;
    animation: scada-pulse 2s infinite;
}

.time-display {
    text-align: right;
    flex-shrink: 0;
}

.time-display--center {
    width: 100%;
    text-align: center;
    padding: 4px 8px 2px;
}

.time-display--center .last-update-label {
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
    opacity: 0.85;
}

.time-display--center .last-update-time {
    font-size: clamp(1.15rem, 2.8vw, 1.65rem);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.last-update-label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 2px;
    font-weight: 500;
}

.last-update-time {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: bold;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.data-card {
    background: rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
    /* 预留联动提示行，避免告警显隐时整页高度跳动 */
    display: flex;
    flex-direction: column;
    min-height: 168px;
}

.data-card:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.14);
}

.data-card.critical {
    border-left: 5px solid #f44336;
}

.data-card.warning {
    border-left: 5px solid #ff9800;
}

.data-card.normal {
    border-left: 5px solid #4CAF50;
}

.param-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.param-value-wrap {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 10px 0;
    min-height: 1.2em;
}

.param-value {
    font-size: 28px;
    font-weight: bold;
    margin: 0;
    color: #ffffff;
}

.param-trend-group {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    margin-left: 2px;
    user-select: none;
}

.param-trend {
    font-weight: 700;
    line-height: 1;
    opacity: 0;
    min-width: 0.7em;
    text-align: center;
    transition: opacity 0.2s ease, transform 0.25s ease, color 0.2s ease;
}

.param-trend--lg { font-size: 18px; }
.param-trend--md { font-size: 13px; opacity: 0; }
.param-trend--sm { font-size: 10px; opacity: 0; }

.param-trend.is-up {
    color: #4ade80;
    opacity: 1;
}

.param-trend--md.is-up { opacity: 0.85; }
.param-trend--sm.is-up { opacity: 0.65; }

.param-trend.is-down {
    color: #f87171;
    opacity: 1;
}

.param-trend--md.is-down { opacity: 0.85; }
.param-trend--sm.is-down { opacity: 0.65; }

.param-trend.is-flat {
    color: #a3a3a3;
    opacity: 0.5;
}

.param-trend.is-empty {
    opacity: 0;
    min-width: 0;
}

.param-trend.is-flash {
    animation: scada-trend-flash 0.55s ease-out;
}

@keyframes scada-trend-flash {
    0% { transform: translateY(3px) scale(0.9); opacity: 0.35; }
    45% { transform: translateY(0) scale(1.12); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.param-unit {
    font-size: 14px;
    opacity: 0.95;
    color: #ffffff;
}

.param-range {
    font-size: 12px;
    color: #f8fafc;
    margin-top: 5px;
}

/* 操作三键：对齐电能分析 / Power Lab 风格 */
.analysis-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}

.analysis-controls .scada-action-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.analysis-controls .scada-action-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.refresh-btn,
.analysis-controls .btn {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #3a3a3a;
    background: linear-gradient(180deg, #2a2a2a 0%, #151515 100%);
    color: #f5f5f5;
    font-family: "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    backdrop-filter: none;
    white-space: normal;
    word-break: keep-all;
    text-align: center;
}

.refresh-btn:hover,
.analysis-controls .btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.refresh-btn:disabled,
.analysis-controls .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* 实时监控：绿边 */
.refresh-btn {
    border-color: #22c55e;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.refresh-btn:hover:not(:disabled) {
    border-color: #4ade80;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
}

.btn-primary {
    border-color: #4a90e2;
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.2);
    color: #e8f1fc;
}

.btn-primary:hover:not(:disabled) {
    border-color: #6aa8f0;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.35);
}

.btn-secondary {
    border-color: #e8a23a;
    box-shadow: 0 0 0 1px rgba(232, 162, 58, 0.22);
    color: #fff6e8;
}

.btn-secondary:hover:not(:disabled) {
    border-color: #f0b85a;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    box-shadow: 0 0 0 1px rgba(232, 162, 58, 0.35);
}

.data-source {
    text-align: center;
    padding: 10px;
    background: rgba(245, 245, 245, 0.7);
    border-radius: 5px;
    margin-top: 20px;
    font-size: 14px;
    backdrop-filter: blur(5px);
}

/* SCADA设备状态面板（第二排内） */
.device-status-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 8px;
    flex-wrap: wrap;
}

.device-status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.device-icon {
    font-size: 1.2em;
}

.device-detail-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.device-detail-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.scada-badge {
    display: inline-block;
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    margin-left: 10px;
    font-weight: normal;
}

.linkage-status {
    margin-top: auto;
    padding: 4px 8px;
    background: transparent;
    border-radius: 4px;
    font-size: 12px;
    color: #4bc0c0;
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    box-sizing: border-box;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.linkage-status.is-on {
    visibility: visible;
    opacity: 1;
    background: rgba(75, 192, 192, 0.2);
    pointer-events: auto;
}

.linkage-status i {
    color: #ffa500;
}

.refresh-btn.is-live {
    border-color: #22c55e;
    color: #ecfdf5;
}

.refresh-btn.is-live:hover {
    border-color: #4ade80;
}

.refresh-btn.is-paused {
    border-color: #64748b;
    color: #e2e8f0;
    box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.25);
}

.refresh-btn.is-paused:hover {
    border-color: #94a3b8;
}

.refresh-btn .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    animation: scada-live-pulse 1.4s ease-out infinite;
    flex: 0 0 auto;
}

.refresh-btn.is-paused .live-dot {
    background: #94a3b8;
    animation: none;
    box-shadow: none;
}

@keyframes scada-live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(134, 239, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0); }
}

/* AI分析结果样式 */
.ai-analysis, .ai-suggestions {
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.streaming-indicator {
    color: #666;
    font-style: italic;
    padding: 10px;
}

.streaming-indicator::after {
    content: '...';
    animation: scada-dots 1.5s steps(4, end) infinite;
}

.ai-analysis h4, .ai-suggestions h4 {
    margin-top: 15px;
    margin-bottom: 8px;
    color: #333;
    border-left: 4px solid #3a9ad9;
    padding-left: 10px;
}

.ai-analysis p, .ai-suggestions p {
    margin-bottom: 10px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.result-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.result-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: bold;
    padding: 0 14px;
    min-height: 34px;
    border-radius: 6px;
    background: #4CAF50;
    color: white;
    line-height: 1;
    box-sizing: border-box;
    white-space: nowrap;
}

.result-status.warning {
    background: #ff9800;
}

.result-status.critical {
    background: #f44336;
}

.result-content {
    padding: 20px;
    background: rgba(249, 249, 249, 0.8);
    border-radius: 5px;
    min-height: 100px;
    border: 1px solid rgba(224, 224, 224, 0.5);
    backdrop-filter: blur(5px);
}

.result-content.single-column {
    display: block;
}

.result-content.dual-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.result-panel {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.panel-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.panel-header h4 {
    margin: 0;
    color: #333;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.left-panel .panel-header h4 {
    color: #3a9ad9;
}

.right-panel .panel-header h4 {
    color: #4CAF50;
}

.panel-content {
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.compliance-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #28a745;
    color: white;
    padding: 0 12px;
    min-height: 34px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: normal;
    line-height: 1;
    box-sizing: border-box;
    white-space: nowrap;
}

.btn-export {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.btn-export:hover {
    background: #218838;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #17a2b8;
    color: white;
    border: none;
    padding: 0 12px;
    min-height: 34px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    line-height: 1;
    box-sizing: border-box;
    white-space: nowrap;
    transition: background 0.2s;
}

.export-btn:hover {
    background: #138496;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* ============================================
   SCADA 分析结果内容排版（对齐 water-analysis）
   ============================================ */

/* 分析/建议内容容器：白底、左边框、圆角、阴影 */
#result-content,
#analysis-content,
#suggestion-content {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #3a9ad9;
    line-height: 1.8;
    font-size: 1rem;
    color: #333;
}

/* 标题分级 */
#result-content h1,
#result-content h2,
#result-content h3,
#result-content h4,
#analysis-content h1,
#analysis-content h2,
#analysis-content h3,
#analysis-content h4,
#suggestion-content h1,
#suggestion-content h2,
#suggestion-content h3,
#suggestion-content h4 {
    margin: 1.5rem 0 1rem 0;
    font-weight: 600;
}

#result-content h1,
#analysis-content h1,
#suggestion-content h1 {
    font-size: 1.3rem;
    color: #1a73e8;
    border-bottom: 2px solid #fbbc05;
    padding-bottom: 0.5rem;
}

#result-content h2,
#analysis-content h2,
#suggestion-content h2 {
    font-size: 1.2rem;
    color: #1a73e8;
}

#result-content h3,
#analysis-content h3,
#suggestion-content h3 {
    font-size: 1.1rem;
    color: #ff6b35;
}

#result-content h4,
#analysis-content h4,
#suggestion-content h4 {
    font-size: 1.05rem;
    color: #8e44ad;
}

/* 段落 */
#result-content p,
#analysis-content p,
#suggestion-content p {
    margin: 1rem 0;
}

/* 强调 */
#result-content strong,
#analysis-content strong,
#suggestion-content strong {
    color: #e74c3c;
    font-weight: 600;
}

/* 列表：ul 圆点，ol 数字序号（1. 2. 3.） */
#result-content ul,
#result-content ol,
#analysis-content ul,
#analysis-content ol,
#suggestion-content ul,
#suggestion-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

#result-content ol,
#analysis-content ol,
#suggestion-content ol {
    list-style: none;
    counter-reset: ol-item;
}

#result-content li,
#analysis-content li,
#suggestion-content li {
    margin: 0.5rem 0;
    line-height: 1.6;
    position: relative;
}

/* 无序列表：彩色圆点 */
#result-content ul li::before,
#analysis-content ul li::before,
#suggestion-content ul li::before {
    content: "•";
    color: #ff6b35;
    font-weight: bold;
    position: absolute;
    left: -1.5rem;
}

#result-content ul li:nth-child(odd)::before,
#analysis-content ul li:nth-child(odd)::before,
#suggestion-content ul li:nth-child(odd)::before {
    color: #8e44ad;
}

#result-content ul li:nth-child(3n)::before,
#analysis-content ul li:nth-child(3n)::before,
#suggestion-content ul li:nth-child(3n)::before {
    color: #e74c3c;
}

/* 有序列表：强制 1. 2. 3. 序号 */
#result-content ol li,
#analysis-content ol li,
#suggestion-content ol li {
    list-style: none;
    counter-increment: ol-item;
    padding-left: 0.5em;
}

#result-content ol li::before,
#analysis-content ol li::before,
#suggestion-content ol li::before {
    content: counter(ol-item) ". ";
    color: #1a73e8;
    font-weight: bold;
    position: absolute;
    left: -1.5rem;
}

/* 流式提示：闪烁光标（对齐 water-analysis） */
.streaming-indicator::after {
    content: "|";
    animation: scada-blink 1s infinite;
    color: #1a73e8;
    font-weight: bold;
}

/* 结果区整体背景（对齐 water-analysis） */
#result.analysis-result,
.analysis-result#result {
    background-color: #e8f0fe;
    border-radius: 10px;
    padding: 1.5rem;
}

.result-header {
    margin-bottom: 1rem;
}

.result-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
}

/* 监测站点切换（石墨主题，避免白底刺眼） */
.scene-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 1rem 0 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(180deg, rgba(42, 42, 42, 0.96) 0%, rgba(18, 18, 18, 0.96) 100%);
    border-radius: 12px;
    border: 1px solid #3a3a3a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.scene-switcher-label {
    font-weight: 600;
    color: #e8c49a;
    font-size: 0.95rem;
}

.scene-link {
    border: 1px solid #505050;
    background: linear-gradient(180deg, #2a2a2a 0%, #151515 100%);
    color: #e8e8e8;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.scene-link:hover {
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    border-color: #d4a574;
    color: #fff6e8;
}

.scene-link.active {
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    color: #fff6e8;
    border-color: #d4a574;
    box-shadow: 0 0 0 1px rgba(212, 165, 116, 0.22);
}
