/* ========== 移动端菜单：紧凑版 + 避开浮动咨询按钮 ========== */

@media (max-width: 768px) {
    /* 修复非首页页面body顶部间距，确保与首页一致 */
    body:not(.home) {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    html body:not(.home) {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* 确保header在所有页面位置一致 */
    body:not(.home) header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 1000 !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
    }
    
    /* 确保非首页的banner从header下方开始 */
    body:not(.home) .inside-banner,
    body:not(.home) .banner {
        margin-top: 62px !important; /* 匹配header高度 */
        padding-top: 0 !important;
    }
    
    /* 确保非首页的内容区域正确显示 */
    body:not(.home) .full-inside-subnav {
        margin-top: 0 !important;
        padding-top: 62px !important; /* 匹配header高度 */
    }
    /* 1. 容器核心设置：避开右侧浮动按钮 */
    .header-nav.active {
        /* === 核心显形属性 === */
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 2147483647 !important;
        
        /* === 布局定位：避开右侧浮动按钮 === */
        position: fixed !important;
        top: 60px !important;
        left: 15px !important; /* 左边留边 */
        right: 70px !important; /* 右边留更多空间，避开浮动咨询按钮 */
        width: auto !important;
        max-width: calc(100vw - 85px) !important; /* 减去左右边距和浮动按钮宽度 */
        height: auto !important;
        max-height: calc(100vh - 90px) !important;
        
        /* === 背景与滚动 === */
        background-color: #fff !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 8px !important;
        box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
    }

    /* 2. 列表重置 */
    .header-nav.active ul {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
        width: 100% !important;
    }
    
    .header-nav.active ul li {
        display: block !important;
        float: none !important;
        width: 100% !important;
        margin: 0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
        background: #fff !important;
        position: relative !important;
    }

    /* 3. 一级菜单：更紧凑，确保链接正确 */
    .header-nav.active ul li h3 {
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    .header-nav.active ul li h3 a {
        display: block !important;
        padding: 12px 45px 12px 18px !important; /* 右侧留空间给展开按钮 */
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #1a1a1a !important;
        text-decoration: none !important;
        line-height: 1.3 !important;
        text-align: left !important;
        transition: all 0.15s ease !important;
        -webkit-tap-highlight-color: transparent !important;
        /* 确保链接可点击 */
        pointer-events: auto !important;
        cursor: pointer !important;
        position: relative !important;
        z-index: 5 !important;
    }

    /* 选中状态：左侧蓝条指示器 */
    .header-nav.active ul li.cur h3 a {
        color: #0066ff !important;
        background-color: rgba(0, 102, 255, 0.06) !important;
        border-left: 3px solid #0066ff !important;
        padding-left: 15px !important;
    }

    /* 一级菜单强反馈效果 */
    .header-nav.active ul li h3 a:hover,
    .header-nav.active ul li h3 a:active {
        background-color: rgba(0, 102, 255, 0.12) !important;
        transform: scale(1.02) !important;
        box-shadow: 0 2px 8px rgba(0, 102, 255, 0.15) !important;
    }

    /* 4. 展开/收起按钮：确保显示和功能 */
    .header-nav.active .phsearchicon {
        display: flex !important; /* 强制显示 */
        position: absolute !important;
        right: 15px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 32px !important;
        height: 32px !important;
        cursor: pointer !important;
        z-index: 10 !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(0, 102, 255, 0.1) !important;
        border-radius: 4px !important;
        transition: all 0.2s ease !important;
        pointer-events: auto !important;
    }

    .header-nav.active .phsearchicon:after {
        content: '' !important;
        width: 10px !important;
        height: 10px !important;
        border-right: 2px solid #0066ff !important;
        border-bottom: 2px solid #0066ff !important;
        transform: rotate(45deg) !important;
        transition: transform 0.2s ease !important;
    }

    /* 展开状态箭头旋转 */
    .header-nav.active li.cur > .phsearchicon:after {
        transform: rotate(-135deg) !important;
    }

    /* 展开按钮触摸反馈 */
    .header-nav.active .phsearchicon:hover,
    .header-nav.active .phsearchicon:active {
        background: rgba(0, 102, 255, 0.2) !important;
        transform: translateY(-50%) scale(1.1) !important;
    }

    /* 5. 子菜单容器：默认隐藏，点击展开 */
    .header-nav.active .sub-nav {
        display: none !important; /* 默认隐藏 */
        position: static !important;
        width: 100% !important;
        background-color: #f8f9fa !important;
        border-top: 1px solid #eee !important;
        padding: 0 !important;
        opacity: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        transition: all 0.3s ease !important;
    }

    /* 展开状态的子菜单 */
    .header-nav.active li.cur .sub-nav {
        display: block !important;
        opacity: 1 !important;
        max-height: 500px !important;
    }

    /* 6. 子菜单项：更紧凑，确保链接正确 */
    .header-nav.active .sub-nav .sub-item {
        display: block !important;
    }

    .header-nav.active .sub-nav .sub-item h4 {
        margin: 0 !important;
    }

    .header-nav.active .sub-nav .sub-item h4 a {
        display: block !important;
        padding: 10px 18px 10px 30px !important;
        font-size: 13px !important;
        color: #555 !important;
        text-align: left !important;
        border-bottom: 1px solid #f0f0f0 !important;
        font-weight: normal !important;
        transition: all 0.15s ease !important;
        -webkit-tap-highlight-color: transparent !important;
        /* 确保链接可点击 */
        pointer-events: auto !important;
        cursor: pointer !important;
        position: relative !important;
        z-index: 5 !important;
    }

    /* 子菜单强反馈效果 */
    .header-nav.active .sub-nav .sub-item h4 a:hover,
    .header-nav.active .sub-nav .sub-item h4 a:active {
        color: #0066ff !important;
        background-color: rgba(0, 102, 255, 0.1) !important;
        transform: translateX(3px) !important;
        box-shadow: 0 1px 4px rgba(0, 102, 255, 0.1) !important;
    }

    /* 7. 隐藏多余元素 */
    .header-nav.active .childMenu {
        display: none !important;
    }

    /* 8. 确保浮动咨询按钮不被菜单遮挡 */
    #wechatConsultButton {
        z-index: 9999 !important; /* 确保在菜单之上 */
    }
}