/**
 * B-P3: electricity-analysis.html / en_electricity-analysis.html
 * Video background + page stacking (metrics UI lives in main-legacy / page JS)
 */

.video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 1;
    transition: opacity 0.5s ease;
    z-index: 1;
}

.video-poster.hidden {
    opacity: 0;
    pointer-events: none;
}

.video-background video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 2;
}

.video-background video.visible {
    opacity: 0.6;
}

body {
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

/* ========== 响应式：手机 / 平板（替代 body scale 脚本） ========== */

/* 导航：刘海安全区 + 汉堡菜单（覆盖 navbar.css 的 desktop 布局） */
.navbar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(70px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;
}

.navbar .mobile-menu-toggle span {
    background-color: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.navbar .mobile-menu-toggle.active span {
    background-color: #ff3b30 !important;
    box-shadow: none;
}

.navbar .mobile-nav-link {
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.navbar .mobile-menu:not(.ht-drawer-shell) {
    background: rgba(15, 40, 70, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (max-width: 1024px) {
    .navbar {
        padding-left: 16px;
        padding-right: 16px;
        justify-content: flex-end !important;
    }

    .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 !important;
        color: #ffffff !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }

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

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

    .navbar .mobile-menu.active {
        display: block !important;
    }
}

@media (min-width: 1025px) {
    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: 992px) {
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

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

    .chart-container canvas {
        max-height: 280px;
        width: 100% !important;
    }
}

/* 手机竖屏 */
@media (max-width: 768px) {
    .section-title h2 {
        font-size: 1.75rem;
    }

    .section-title p {
        font-size: 1rem;
        padding: 0 0.5rem;
    }

    .animal-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem 0.75rem;
        max-width: 100%;
        padding: 0 0.25rem;
    }

    .animal-option {
        min-width: 0;
        width: 100%;
        flex: none;
        padding: 0.75rem 0.4rem;
    }

    .animal-option span {
        font-size: 0.82rem;
        line-height: 1.25;
        text-align: center;
    }

    .animal-icon {
        font-size: 2rem;
    }

    .color-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .water-quality {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem 1rem;
    }

    .param-control {
        width: 100%;
        margin-bottom: 0;
        padding: 0.85rem;
        box-sizing: border-box;
    }

    .slider-container {
        width: 100%;
    }

    .slider {
        width: 100%;
        min-height: 28px;
    }

    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .range-labels {
        font-size: 0.85rem;
    }

    .controls:not(.btn-group-3d) {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-top: 1.25rem;
    }

    .controls.btn-group-3d {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem;
        margin-top: 1.25rem;
    }

    .controls:not(.btn-group-3d) .btn {
        width: 100%;
        min-height: 44px;
        font-size: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* 加载动画：缩小 Logo 与轨道倒计时 */
    .logo-spinner {
        width: 200px;
        height: 200px;
    }

    .rotating-logo {
        width: 170px;
        height: 170px;
    }

    .countdown-badge {
        width: 42px;
        height: 42px;
        font-size: 15px;
        animation: orbit-mobile 10s linear infinite !important;
    }

    @keyframes orbit-mobile {
        0% {
            transform: rotate(0deg) translateX(72px) rotate(0deg);
        }
        100% {
            transform: rotate(360deg) translateX(72px) rotate(-360deg);
        }
    }
}

/* 微信内置浏览器：底部工具栏安全区 */
.wechat-browser .controls,
.wechat-browser .analysis-result,
.wechat-browser footer {
    margin-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.wechat-browser .container {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* ========== 分析操作按钮：完整可读，避免旧 3D 字被裁切 ========== */
.pq-action-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    margin-top: 1.75rem;
}

.pq-action-btn {
    box-sizing: border-box;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #3a3a3a;
    background: #1a1a1a;
    color: #f5f5f5;
    font-family: "PingFang SC", "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: normal;
    word-break: keep-all;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.pq-action-btn .pq-btn-busy {
    display: none;
}

.pq-action-btn.is-loading .pq-btn-idle {
    display: none;
}

.pq-action-btn.is-loading .pq-btn-busy {
    display: inline;
}

.pq-action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: #6b6b6b;
}

.pq-action-btn:disabled,
.pq-action-btn.is-loading {
    cursor: wait;
    opacity: 0.88;
}

.pq-action-btn--primary {
    background: linear-gradient(180deg, #2a2a2a 0%, #151515 100%);
    border-color: #4a90e2;
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.2);
}

.pq-action-btn--primary:hover:not(:disabled) {
    border-color: #6aa8f0;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
}

.pq-action-btn--accent {
    background: linear-gradient(180deg, #2a2a2a 0%, #151515 100%);
    border-color: #e8a23a;
    box-shadow: 0 0 0 1px rgba(232, 162, 58, 0.22);
}

.pq-action-btn--accent:hover:not(:disabled) {
    border-color: #f0b85a;
}

.pq-action-btn--muted {
    background: #141414;
    border-color: #404040;
    color: #f5f5f5;
}

@media (max-width: 720px) {
    .pq-action-bar {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .pq-action-btn {
        min-height: 46px;
        font-size: 15px;
    }
}

/* ========== App 暗色模式：分析答案 / 表格一律黑底白字 ========== */
html.app-client .analysis-report,
html.app-client .streaming-container {
    background: #141414 !important;
    border: 1px solid #333 !important;
    box-shadow: none !important;
    color: #ffffff !important;
}

html.app-client .ai-content,
html.app-client .streaming-content,
html.app-client .analysis-content {
    background: #1a1a1a !important;
    border-color: #3a3a3a !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

html.app-client .analysis-report h3,
html.app-client .params-section h3,
html.app-client .ai-analysis-section h3,
html.app-client .analysis-content h1,
html.app-client .analysis-content h2,
html.app-client .analysis-content h3,
html.app-client .analysis-content h4,
html.app-client .ai-content h1,
html.app-client .ai-content h2,
html.app-client .ai-content h3,
html.app-client .ai-content h4 {
    color: #ffffff !important;
    border-bottom-color: #555 !important;
}

html.app-client .analysis-content p,
html.app-client .analysis-content li,
html.app-client .analysis-content span,
html.app-client .analysis-content td,
html.app-client .analysis-content th,
html.app-client .ai-content p,
html.app-client .ai-content li,
html.app-client .streaming-content,
html.app-client .streaming-content p {
    color: #ffffff !important;
}

html.app-client .analysis-content strong,
html.app-client .ai-content strong {
    color: #ffffff !important;
    font-weight: 700;
}

html.app-client .analysis-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    background: #111111 !important;
    color: #ffffff !important;
    box-shadow: none !important;
    margin: 0.85rem 0 1.25rem !important;
}

html.app-client .analysis-table td,
html.app-client .analysis-table th {
    color: #ffffff !important;
    border-color: #404040 !important;
    background: transparent;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

html.app-client .analysis-table th:nth-child(1),
html.app-client .analysis-table td:nth-child(1) { width: 28%; }
html.app-client .analysis-table th:nth-child(2),
html.app-client .analysis-table td:nth-child(2) { width: 20%; }
html.app-client .analysis-table th:nth-child(3),
html.app-client .analysis-table td:nth-child(3) { width: 28%; }
html.app-client .analysis-table th:nth-child(4),
html.app-client .analysis-table td:nth-child(4) { width: 24%; }

html.app-client .analysis-table tr:nth-child(even) {
    background-color: #1f1f1f !important;
}

html.app-client .analysis-table tr:nth-child(odd) {
    background-color: #151515 !important;
}

html.app-client .analysis-table tr:first-child,
html.app-client .analysis-table thead tr {
    background: #2a2a2a !important;
    color: #ffffff !important;
}

html.app-client .analysis-table tr:first-child td,
html.app-client .analysis-table tr:first-child th,
html.app-client .analysis-table thead td,
html.app-client .analysis-table thead th {
    color: #ffffff !important;
    font-weight: 700;
}

html.app-client .param-item {
    background: #1f1f1f !important;
    box-shadow: none !important;
    border: 1px solid #333;
}

html.app-client .param-label {
    color: #ffffff !important;
}

html.app-client .param-value {
    color: #ffffff !important;
}

html.app-client .param-value {
    display: inline-block;
    transform-origin: center center;
    will-change: transform;
}

html.app-client .param-value.normal {
    color: #e2efe2 !important;
    background: rgba(122, 148, 122, 0.28) !important;
    border-color: rgba(150, 176, 150, 0.55) !important;
}

html.app-client .param-value.low,
html.app-client .param-value.high {
    color: #f3ddd9 !important;
    background: rgba(168, 104, 98, 0.28) !important;
    border-color: rgba(190, 130, 122, 0.55) !important;
}

html.app-client .param-value.warning {
    color: #f5e6d0 !important;
    background: rgba(196, 154, 108, 0.28) !important;
    border-color: rgba(212, 165, 116, 0.55) !important;
}

@keyframes pq-value-bump {
    0% { transform: scale(1); }
    35% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

html.app-client .param-value.is-bumping {
    animation: pq-value-bump 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

html.app-client .analysis-content .special-text {
    color: #86efac !important;
}

html.app-client .result-content,
html.app-client #result-content {
    color: #ffffff !important;
}

/* 金属旋钮滑条（电力分析参数区） */
.water-quality .slider-container {
    position: relative;
    display: flex;
    width: 100%;
    overflow: visible;
}

.water-quality .slider-icon {
    display: none;
}

.water-quality .slider-wrapper {
    position: relative;
    width: 100%;
    height: 35px;
    background: #d8d8d8;
    border-radius: 30px;
    padding: 6px;
    box-sizing: border-box;
    overflow: visible;
    box-shadow:
        inset 2px 2px 5px rgba(0, 0, 0, 0.4),
        1px 1px 2px rgba(255, 255, 255, 0.8);
}

.water-quality .slider-wrapper .slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 100%;
    flex: none;
    border-radius: 22px;
    outline: none;
    margin: 0;
    padding: 0;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    background-image: none;
}

.water-quality .slider-gradient-1 {
    --pq-track: linear-gradient(to right, #2a1210 0%, #5c3324 48%, #c4a05a 100%);
    background: var(--pq-track);
}

.water-quality .slider-gradient-2 {
    --pq-track: linear-gradient(to right, #0a1e22 0%, #1a4450 48%, #6aa8b4 100%);
    background: var(--pq-track);
}

.water-quality .slider-gradient-3 {
    --pq-track: linear-gradient(to right, #120814 0%, #3e1c34 48%, #a86a7c 100%);
    background: var(--pq-track);
}

.water-quality .slider-gradient-4 {
    --pq-track: linear-gradient(to right, #101810 0%, #2e4a30 48%, #8aaa62 100%);
    background: var(--pq-track);
}

.water-quality .slider-wrapper .slider::-webkit-slider-runnable-track {
    height: 100%;
    border-radius: 22px;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.55);
    background: var(--pq-track);
}

.water-quality .slider-wrapper .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 35px;
    height: 35px;
    margin-top: -6px;
    border-radius: 50%;
    background: conic-gradient(
        from 180deg at 50% 50%,
        #7a8088 0deg,
        #c4c9cf 45deg,
        #eef1f5 90deg,
        #7a8088 135deg,
        #4a4e54 180deg,
        #c4c9cf 225deg,
        #eef1f5 270deg,
        #7a8088 315deg,
        #7a8088 360deg
    );
    border: 2px solid #5a5e63;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.4);
    cursor: grab;
    transition: transform 0.1s ease;
}

.water-quality .slider-wrapper .slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.water-quality .slider-wrapper .slider::-webkit-slider-thumb::before {
    content: none !important;
    display: none !important;
}

.water-quality .slider-wrapper .slider::-moz-range-thumb {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: conic-gradient(
        from 180deg at 50% 50%,
        #7a8088 0deg,
        #c4c9cf 45deg,
        #eef1f5 90deg,
        #7a8088 135deg,
        #4a4e54 180deg,
        #c4c9cf 225deg,
        #eef1f5 270deg,
        #7a8088 315deg,
        #7a8088 360deg
    );
    border: 2px solid #5a5e63;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.4);
    cursor: grab;
}

.water-quality .slider-wrapper .slider::-moz-range-track {
    height: 23px;
    border: none;
    border-radius: 22px;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.55);
    background: var(--pq-track);
}

@media (max-width: 768px) {
    .water-quality .slider-wrapper .slider::-webkit-slider-thumb,
    .water-quality .slider-wrapper .slider::-moz-range-thumb {
        width: 35px;
        height: 35px;
    }

    .water-quality .param-control {
        padding: 0.2rem 0 0.75rem;
    }
}

/* 滑条直接铺在主面板上：去掉每条参数的小卡片；图例留在面板顶部 */
.water-quality .param-control {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.2rem 0 0.85rem;
    margin-bottom: 0;
}

.water-quality .color-legend {
    background: transparent;
    border: none;
    box-shadow: none;
    margin: 0 0 0.35rem;
    padding: 0.15rem 0 0.85rem;
    gap: 1.75rem;
}

html.app-client body:not(.app-launcher-page) .water-quality .param-control {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

html.app-client body:not(.app-launcher-page) .water-quality .color-legend {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

html.app-client body:not(.app-launcher-page) .water-quality .param-header .param-value {
    border-radius: 999px;
    min-width: 2.6rem;
    text-align: center;
    padding: 0.12rem 0.7rem;
}

html.app-client body:not(.app-launcher-page) .water-quality .param-header .param-value.normal {
    color: #c6f0c6 !important;
    background: rgba(72, 148, 80, 0.55) !important;
    border: 1px solid rgba(144, 238, 144, 0.7) !important;
}

html.app-client body:not(.app-launcher-page) .water-quality .param-header .param-value.warning {
    color: #ffe9a0 !important;
    background: rgba(180, 140, 40, 0.5) !important;
    border: 1px solid rgba(255, 215, 0, 0.7) !important;
}

html.app-client body:not(.app-launcher-page) .water-quality .param-header .param-value.low,
html.app-client body:not(.app-launcher-page) .water-quality .param-header .param-value.high {
    color: #ffd0d8 !important;
    background: rgba(176, 80, 96, 0.5) !important;
    border: 1px solid rgba(255, 182, 193, 0.75) !important;
}

/* 场地选择：机械键帽 */
.animal-selection .animal-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.15rem 1.35rem;
    max-width: none;
}

.animal-option.keycap {
    position: relative;
    display: inline-block;
    width: 112px;
    height: 112px;
    min-width: 112px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: linear-gradient(180deg, #282828, #202020);
    box-shadow:
        inset -8px 0 8px rgba(0, 0, 0, 0.15),
        inset 0 -8px 8px rgba(0, 0, 0, 0.25),
        0 0 0 2px rgba(0, 0, 0, 0.75),
        10px 20px 25px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition:
        transform 0.1s ease-in-out,
        box-shadow 0.1s ease-in;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.animal-option.keycap .animal-icon {
    display: none;
}

.animal-option.keycap .letter {
    position: absolute;
    left: 16px;
    top: 16px;
    z-index: 1;
    color: #e9e9e9;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    transition: transform 0.1s ease-in-out;
}

.animal-option.keycap::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 5px;
    bottom: 18px;
    right: 16px;
    background: linear-gradient(90deg, #232323, #4a4a4a);
    border-radius: 10px;
    box-shadow:
        -10px -10px 10px rgba(255, 255, 255, 0.25),
        10px 5px 10px rgba(0, 0, 0, 0.15);
    border-left: 1px solid #0004;
    border-bottom: 1px solid #0004;
    border-top: 1px solid #0009;
    transition: all 0.1s ease-in-out;
}

.animal-option.keycap:hover {
    transform: none;
}

.animal-option.keycap:active,
.animal-option.keycap.selected {
    transform: translateY(2px);
    box-shadow:
        inset -4px 0 4px rgba(0, 0, 0, 0.1),
        inset 0 -4px 4px rgba(0, 0, 0, 0.15),
        0 0 0 2px rgba(0, 0, 0, 0.5),
        5px 10px 15px rgba(0, 0, 0, 0.3);
}

.animal-option.keycap:active::before,
.animal-option.keycap.selected::before {
    top: 6px;
    left: 6px;
    bottom: 14px;
    right: 14px;
    box-shadow:
        -5px -5px 5px rgba(255, 255, 255, 0.15),
        5px 3px 5px rgba(0, 0, 0, 0.1);
}

.animal-option.keycap:active .letter,
.animal-option.keycap.selected .letter {
    transform: translateY(1px);
}

.animal-option.keycap.selected .letter {
    color: #e8c9a0;
}

html.app-client body:not(.app-launcher-page) .animal-option.keycap,
html.app-client body:not(.app-launcher-page) .animal-option.keycap:hover {
    background: linear-gradient(180deg, #282828, #202020) !important;
    border: none !important;
    box-shadow:
        inset -8px 0 8px rgba(0, 0, 0, 0.15),
        inset 0 -8px 8px rgba(0, 0, 0, 0.25),
        0 0 0 2px rgba(0, 0, 0, 0.75),
        10px 20px 25px rgba(0, 0, 0, 0.4) !important;
}

html.app-client body:not(.app-launcher-page) .animal-option.keycap:active,
html.app-client body:not(.app-launcher-page) .animal-option.keycap.selected {
    background: linear-gradient(180deg, #282828, #202020) !important;
    border: none !important;
    box-shadow:
        inset -4px 0 4px rgba(0, 0, 0, 0.1),
        inset 0 -4px 4px rgba(0, 0, 0, 0.15),
        0 0 0 2px rgba(0, 0, 0, 0.5),
        5px 10px 15px rgba(0, 0, 0, 0.3) !important;
}

html.app-client body:not(.app-launcher-page) .animal-option.keycap .letter,
html.app-client body:not(.app-launcher-page) .animal-option.keycap span {
    color: #e9e9e9 !important;
}

html.app-client body:not(.app-launcher-page) .animal-option.keycap.selected .letter {
    color: #e8c9a0 !important;
}

@media (max-width: 768px) {
    .animal-option.keycap {
        width: 92px;
        height: 92px;
        min-width: 92px;
        padding: 0;
    }

    .animal-option.keycap .letter {
        font-size: 16px;
        left: 13px;
        top: 13px;
    }
}
