/**
 * 三汇咨询向导 v2 样式（增长诊断 Modal + PC 悬浮 FAB + 移动条三按钮）
 *
 * 设计要点：
 * - 全部使用全新 sanhui-dx- / sanhui-consult-fab 类名，与旧版问题容器的
 *   「display:none + .is-active」双轨显隐地雷（审计 §4）彻底隔离；
 *   本文件加载于所有样式之后，负责覆盖一切。
 * - 显隐唯一机制 = hidden 属性；下方兜底规则保证 author 级 display 永远压不过 [hidden]。
 * - 品牌色沿用 sanhui-frontend.css 的 :root 变量（深海军蓝 + 金 + 白）。
 */

/* ---------- 显隐兜底（结构性根除旧 bug：hidden 必须生效） ---------- */
html body .sanhui-dx-question[hidden],
html body .sanhui-dx-input[hidden],
html body .sanhui-dx-error[hidden],
html body .sanhui-dx-form[hidden],
html body .sanhui-dx-progress[hidden],
html body .sanhui-dx-success[hidden],
html body .sanhui-dx-actions button[hidden],
html body .sanhui-dx-actions button[aria-disabled="true"][hidden] {
    display: none !important;
}

/* =========================================================================
 * Modal 外壳（PC 居中 / 移动端 bottom sheet）
 * ========================================================================= */

html body .sanhui-dx-modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 99990;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 8, 21, 0.66);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
}

html body .sanhui-dx-modal.is-visible {
    display: flex;
}

html body .sanhui-dx-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(640px, 100%);
    max-height: calc(100vh - 48px);
    margin: auto;
    overflow: hidden;
    border: 1px solid rgba(217, 180, 109, 0.28);
    border-radius: 20px;
    color: var(--sanhui-white, #f7fbff);
    background:
        radial-gradient(circle at 85% -10%, rgba(54, 163, 255, 0.16), transparent 42%),
        linear-gradient(160deg, #0b1d35 0%, #071426 58%, #020815 100%);
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: sanhuiDxPanelIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes sanhuiDxPanelIn {
    from { opacity: 0; transform: translateY(18px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

html body .sanhui-dx-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(117, 201, 255, 0.24);
    border-radius: 50%;
    color: rgba(234, 245, 255, 0.85);
    background: rgba(3, 14, 31, 0.72);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

html body .sanhui-dx-close:hover,
html body .sanhui-dx-close:focus-visible {
    color: #fff;
    border-color: rgba(217, 180, 109, 0.65);
    transform: rotate(90deg);
}

/* ---------- 头部 ---------- */

html body .sanhui-dx-head {
    padding: 24px 30px 0;
}

html body .sanhui-dx-head__badge {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 5px 10px;
    border: 1px solid rgba(217, 180, 109, 0.26);
    border-radius: 999px;
    color: var(--sanhui-gold, #d9b46d);
    background: rgba(217, 180, 109, 0.08);
    font-size: 12px;
    font-weight: 800;
}

html body .sanhui-dx-head__title {
    margin: 0;
    color: #fff;
    font-size: 25px;
    font-weight: 800;
    line-height: 1.25;
}

html body .sanhui-dx-head__desc {
    margin: 8px 0 0;
    color: rgba(234, 245, 255, 0.76);
    font-size: 13.5px;
    line-height: 1.7;
}

/* ---------- 进度区（内容全部由 JS 填充） ---------- */

html body .sanhui-dx-progress {
    display: grid;
    gap: 8px;
    padding: 16px 30px 4px;
}

html body .sanhui-dx-progress__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: rgba(234, 245, 255, 0.72);
    font-size: 13px;
    font-weight: 800;
}

html body .sanhui-dx-progress__name {
    color: var(--sanhui-gold, #d9b46d);
}

html body .sanhui-dx-progress__bar {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(117, 201, 255, 0.14);
}

html body .sanhui-dx-progress__bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #76c7ff 0%, #d9b46d 100%);
    transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- 表单滚动区 + 步骤 ---------- */

html body .sanhui-dx-form {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 12px;
    overflow-y: auto;
    padding: 0 30px 6px;
    -webkit-overflow-scrolling: touch;
}

html body .sanhui-dx-steps {
    display: block;
}

html body .sanhui-dx-question {
    padding: 14px 0 10px;
}

html body .sanhui-dx-question__title {
    margin: 0 0 6px;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.45;
    outline: none;
}

html body .sanhui-dx-question__hint {
    margin: 0 0 12px;
    color: rgba(234, 245, 255, 0.66);
    font-size: 13px;
    line-height: 1.65;
}

/* ---------- 选项（选中态：金色 + 明显过渡，绝不"点了不知道有没有选中"） ---------- */

html body .sanhui-dx-options {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 12px;
}

html body .sanhui-dx-option {
    min-height: 40px;
    padding: 8px 15px;
    border: 1px solid rgba(117, 201, 255, 0.26);
    border-radius: 999px;
    color: rgba(234, 245, 255, 0.88);
    background: rgba(3, 14, 31, 0.72);
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease,
        box-shadow 0.18s ease, transform 0.18s ease;
}

html body .sanhui-dx-option:hover {
    border-color: rgba(217, 180, 109, 0.55);
    color: #fff;
    transform: translateY(-1px);
}

html body .sanhui-dx-option:focus-visible {
    outline: 2px solid var(--sanhui-gold, #d9b46d);
    outline-offset: 2px;
}

html body .sanhui-dx-option.is-selected {
    border-color: rgba(255, 236, 190, 0.9);
    color: #07111f;
    background: linear-gradient(135deg, #ffe9b3 0%, #d9b46d 55%, #b98335 100%);
    box-shadow: 0 6px 18px rgba(217, 180, 109, 0.35);
    transform: translateY(-1px);
}

/* ---------- 子输入 ---------- */

html body .sanhui-dx-input {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

html body .sanhui-dx-input__label {
    color: rgba(234, 245, 255, 0.78);
    font-size: 13px;
    font-weight: 700;
}

html body .sanhui-dx-input input {
    width: 100%;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid rgba(117, 201, 255, 0.26);
    border-radius: 10px;
    color: #fff;
    background: rgba(2, 8, 21, 0.65);
    font-size: 14px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

html body .sanhui-dx-input input::placeholder {
    color: rgba(159, 179, 202, 0.6);
}

html body .sanhui-dx-input input:focus {
    border-color: rgba(217, 180, 109, 0.65);
    box-shadow: 0 0 0 3px rgba(217, 180, 109, 0.16);
    outline: none;
}

html body .sanhui-dx-note {
    margin: 14px 0 0;
    color: rgba(159, 179, 202, 0.85);
    font-size: 12px;
    line-height: 1.6;
}

/* ---------- 错误提示（当前题容器内部、选项之下按钮之上、aria-live=polite） ---------- */

html body .sanhui-dx-error {
    margin: 14px 0 0;
    padding: 10px 13px;
    border: 1px solid rgba(255, 138, 128, 0.38);
    border-left: 3px solid #ff8a80;
    border-radius: 10px;
    color: #ffc2ba;
    background: rgba(255, 107, 90, 0.12);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.55;
}

/* ---------- 操作区（sticky 底栏：移动端滚动时按钮常驻） ---------- */

html body .sanhui-dx-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    gap: 10px;
    margin: 8px -30px 0;
    padding: 14px 30px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(117, 201, 255, 0.14);
    background: linear-gradient(180deg, rgba(7, 20, 38, 0.86) 0%, rgba(2, 8, 21, 0.97) 100%);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

html body .sanhui-dx-btn {
    min-height: 46px;
    padding: 11px 22px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease,
        border-color 0.2s ease, background 0.2s ease;
}

html body .sanhui-dx-btn--ghost {
    flex: 0 0 auto;
    border: 1px solid rgba(117, 201, 255, 0.3);
    color: rgba(234, 245, 255, 0.85);
    background: transparent;
}

html body .sanhui-dx-btn--ghost:hover {
    border-color: rgba(217, 180, 109, 0.55);
    color: #fff;
}

html body .sanhui-dx-btn--primary {
    flex: 1 1 auto;
    border: 1px solid rgba(255, 236, 190, 0.5);
    color: #07111f;
    background: linear-gradient(135deg, #ffe9b3 0%, #d9b46d 55%, #b98335 100%);
    box-shadow: 0 10px 26px rgba(217, 180, 109, 0.28);
}

html body .sanhui-dx-btn--primary:hover:not([aria-disabled="true"]):not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(217, 180, 109, 0.38);
}

html body .sanhui-dx-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* is-idle：可聚焦可点击但不假装可用（flow-spec §4.1） */
html body .sanhui-dx-btn.is-idle {
    opacity: 0.55;
    cursor: default;
    box-shadow: none;
    transform: none;
}

html body .sanhui-dx-btn.is-idle:hover {
    transform: none;
    box-shadow: none;
}

html body .sanhui-dx-btn[disabled] {
    opacity: 0.7;
    cursor: wait;
}

/* ---------- 完成页（flow-spec §3：方向建议 + 联系块 + 双按钮） ---------- */

html body .sanhui-dx-success {
    flex: 1 1 auto;
    min-height: 0;
    padding: 24px 30px calc(24px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

html body .sanhui-dx-success__title {
    margin: 4px 0 0;
    color: var(--sanhui-gold, #d9b46d);
    font-size: 26px;
    font-weight: 800;
}

html body .sanhui-dx-success__intro {
    margin: 12px 0 0;
    color: rgba(234, 245, 255, 0.85);
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.7;
}

html body .sanhui-dx-success__list {
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
}

html body .sanhui-dx-success__item {
    padding: 12px 14px;
    border: 1px solid rgba(117, 201, 255, 0.2);
    border-left: 3px solid var(--sanhui-gold, #d9b46d);
    border-radius: 10px;
    color: rgba(234, 245, 255, 0.88);
    background: rgba(255, 255, 255, 0.045);
    font-size: 13.5px;
    line-height: 1.7;
}

html body .sanhui-dx-success__item strong {
    color: var(--sanhui-gold, #d9b46d);
}

html body .sanhui-dx-success__closing {
    margin: 16px 0 0;
    color: rgba(234, 245, 255, 0.78);
    font-size: 13.5px;
    line-height: 1.7;
}

html body .sanhui-dx-success__contact {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    padding: 13px 15px;
    border: 1px solid rgba(217, 180, 109, 0.24);
    border-radius: 12px;
    background: rgba(217, 180, 109, 0.07);
    color: rgba(234, 245, 255, 0.9);
    font-size: 13.5px;
    line-height: 1.6;
}

html body .sanhui-dx-success__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

html body .sanhui-dx-success__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 11px 20px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

html body .sanhui-dx-success__btn--primary {
    flex: 1 1 auto;
    border: 1px solid rgba(255, 236, 190, 0.5);
    color: #07111f;
    background: linear-gradient(135deg, #ffe9b3 0%, #d9b46d 55%, #b98335 100%);
    box-shadow: 0 10px 26px rgba(217, 180, 109, 0.28);
}

html body .sanhui-dx-success__btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(217, 180, 109, 0.38);
}

html body .sanhui-dx-success__btn--quiet {
    flex: 0 0 auto;
    border: 1px solid rgba(117, 201, 255, 0.3);
    color: rgba(234, 245, 255, 0.85);
    background: transparent;
}

html body .sanhui-dx-success__btn--quiet:hover {
    border-color: rgba(217, 180, 109, 0.55);
    color: #fff;
}

/* ---------- 移动端 ≤768px：near 全屏 bottom sheet ---------- */

@media (max-width: 768px) {
    html body .sanhui-dx-modal {
        align-items: flex-end;
        padding: 0;
        background: rgba(2, 8, 21, 0.74);
    }

    html body .sanhui-dx-panel {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 18px);
        margin: 0; /* 覆盖 PC 的 margin:auto 居中：bottom sheet 必须贴底 */
        border-radius: 18px 18px 0 0;
        border-bottom: none;
        animation: sanhuiDxSheetIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    html body .sanhui-dx-head {
        padding: 20px 20px 0;
        padding-right: 56px;
    }

    html body .sanhui-dx-head__title {
        font-size: 21px;
    }

    html body .sanhui-dx-progress {
        padding: 13px 20px 2px;
    }

    html body .sanhui-dx-form {
        padding: 0 20px 4px;
    }

    html body .sanhui-dx-question {
        padding: 10px 0 8px;
    }

    html body .sanhui-dx-question__title {
        font-size: 16.5px;
    }

    html body .sanhui-dx-option {
        min-height: 44px;
        padding: 9px 14px;
        font-size: 14px;
    }

    html body .sanhui-dx-actions {
        margin: 8px -20px 0;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    html body .sanhui-dx-btn {
        min-height: 50px;
    }

    html body .sanhui-dx-success {
        padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    }

    html body .sanhui-dx-success__actions .sanhui-dx-success__btn {
        flex: 1 1 100%;
    }
}

@keyframes sanhuiDxSheetIn {
    from { opacity: 0; transform: translateY(36px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
 * PC 悬浮咨询 FAB（新类名，不复用旧版被全站 CSS 隐藏的悬浮按钮类）
 * ========================================================================= */

html body .sanhui-consult-fab {
    position: fixed;
    right: 24px;
    bottom: 100px;
    z-index: 9990;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px 10px 14px;
    border: 1px solid rgba(217, 180, 109, 0.45);
    border-radius: 999px;
    color: var(--sanhui-white, #f7fbff);
    text-decoration: none;
    background: linear-gradient(135deg, rgba(11, 29, 53, 0.97) 0%, rgba(7, 20, 38, 0.97) 100%);
    box-shadow: 0 12px 32px rgba(2, 8, 21, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease, border-color 0.25s ease;
    animation: sanhuiFabIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) 1.1s backwards;
}

html body .sanhui-consult-fab:hover,
html body .sanhui-consult-fab:focus-visible {
    transform: translateY(-3px);
    border-color: rgba(217, 180, 109, 0.75);
    box-shadow: 0 18px 42px rgba(2, 8, 21, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 呼吸光晕（8s 周期，很轻） */
html body .sanhui-consult-fab::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
    pointer-events: none;
    animation: sanhuiFabBreath 8s ease-in-out 2.4s infinite;
}

/* 每 8s 一次很轻的金色光扫过 */
html body .sanhui-consult-fab::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -70%;
    z-index: 1;
    width: 46%;
    background: linear-gradient(105deg, transparent 0%, rgba(255, 233, 179, 0.22) 50%, transparent 100%);
    transform: skewX(-18deg);
    pointer-events: none;
    animation: sanhuiFabSheen 8s cubic-bezier(0.4, 0, 0.2, 1) 3s infinite;
}

@keyframes sanhuiFabIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes sanhuiFabBreath {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 180, 109, 0); }
    45% { box-shadow: 0 0 0 9px rgba(217, 180, 109, 0.12); }
    60% { box-shadow: 0 0 0 12px rgba(217, 180, 109, 0.05); }
}

@keyframes sanhuiFabSheen {
    0% { left: -70%; }
    34% { left: 130%; }
    100% { left: 130%; }
}

html body .sanhui-consult-fab__icon {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 1px solid rgba(217, 180, 109, 0.5);
    border-radius: 50%;
    color: var(--sanhui-gold, #d9b46d);
    background: rgba(217, 180, 109, 0.12);
}

html body .sanhui-consult-fab__text {
    position: relative;
    z-index: 2;
    display: grid;
    gap: 1px;
    line-height: 1.25;
}

html body .sanhui-consult-fab__text strong {
    color: #fff;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

html body .sanhui-consult-fab__text small {
    color: rgba(159, 179, 202, 0.95);
    font-size: 11.5px;
    font-weight: 600;
}

/* 首次访问轻提示气泡 */
html body .sanhui-consult-fab__bubble {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    z-index: 3;
    max-width: 240px;
    padding: 10px 14px;
    border: 1px solid rgba(217, 180, 109, 0.4);
    border-radius: 12px 12px 4px 12px;
    color: #f7fbff;
    background: rgba(7, 20, 38, 0.96);
    box-shadow: 0 12px 30px rgba(2, 8, 21, 0.5);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.55;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(6px);
    animation: sanhuiFabBubbleIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

html body .sanhui-consult-fab__bubble.is-fading {
    opacity: 0;
}

@keyframes sanhuiFabBubbleIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Modal 打开时隐藏 FAB（body class 驱动） */
html body.sanhui-consult-open .sanhui-consult-fab {
    display: none !important;
}

/* Modal 打开时同时隐藏移动条（双保险，legacy class 已有同类规则） */
html body.sanhui-consult-open .sanhui-mobile-consult,
html body.sanhui-consult-open #sanhui-global-mobile-consult,
html body.sanhui-consult-modal-open #sanhui-global-mobile-consult {
    display: none !important;
}

/* ≤768px 隐藏 FAB（该区间由底部咨询条接管；769-880px 保持 FAB，
 * 避免与 legacy frontend.css 4334 的 min-width:769 条隐藏规则叠加出入口真空带） */
@media (max-width: 768px) {
    html body .sanhui-consult-fab {
        display: none !important;
    }
}

/* =========================================================================
 * 移动端底部条：原 .sanhui-mobile-consult 类名不动，扩为三按钮
 * ========================================================================= */

@media (max-width: 880px) {
    html body .sanhui-mobile-consult {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    html body .sanhui-mobile-consult a[data-sanhui-open-consult] {
        display: grid;
        place-items: center;
        min-height: 44px;
        border-radius: 8px;
        color: #07111f;
        background: linear-gradient(135deg, #ffe9b3 0%, #d9b46d 55%, #b98335 100%);
        font-size: 14px;
        font-weight: 800;
        text-decoration: none;
    }
}

/* ---------- 动效降级 ---------- */

@media (prefers-reduced-motion: reduce) {
    html body .sanhui-consult-fab,
    html body .sanhui-consult-fab::before,
    html body .sanhui-consult-fab::after,
    html body .sanhui-consult-fab__bubble,
    html body .sanhui-dx-panel {
        animation: none !important;
        transition: none !important;
    }

    html body .sanhui-consult-fab {
        opacity: 1;
        transform: none;
    }

    html body .sanhui-consult-fab::before {
        display: none;
    }

    html body .sanhui-dx-progress__bar i {
        transition: none;
    }
}
