/**
 * 全站 H5 移动端样式
 * 断点与 front.css 一致，≤991.98px 启用底部 Tab 等 H5 组件
 */

:root {
    --h5-tabbar-h: 56px;
    --h5-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 底部 Tab 栏 ---------- */
.h5-tabbar {
    display: none;
}

@media (max-width: 991.98px) {
    body.has-h5-tabbar {
        padding-bottom: calc(var(--h5-tabbar-h) + var(--h5-safe-bottom));
    }

    body.has-h5-tabbar.has-product-mobile-bar {
        padding-bottom: calc(var(--h5-tabbar-h) + 64px + var(--h5-safe-bottom));
    }

    .h5-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1040;
        height: calc(var(--h5-tabbar-h) + var(--h5-safe-bottom));
        padding-bottom: var(--h5-safe-bottom);
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid var(--border, #E2E8F0);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, .08);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .h5-tabbar-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 6px 4px;
        text-decoration: none;
        color: #64748B;
        font-size: 11px;
        font-weight: 500;
        transition: color .15s;
        -webkit-tap-highlight-color: transparent;
    }

    .h5-tabbar-item i {
        font-size: 20px;
        line-height: 1;
    }

    .h5-tabbar-item.active {
        color: var(--primary, #2563EB);
        font-weight: 600;
    }

    .h5-tabbar-item:active {
        opacity: .75;
    }

    /* 顶部信息栏精简 */
    body.has-h5-tabbar .top-bar .top-bar-item.d-none.d-md-inline {
        display: none !important;
    }

    /* 悬浮客服上移，避免与 Tab 重叠 */
    body.has-h5-tabbar .cs-float-wrap {
        bottom: calc(var(--h5-tabbar-h) + 12px + var(--h5-safe-bottom));
    }

    body.has-h5-tabbar.has-product-mobile-bar .cs-float-wrap {
        bottom: calc(var(--h5-tabbar-h) + 76px + var(--h5-safe-bottom));
    }

    body.has-h5-tabbar .cs-popup {
        bottom: calc(var(--h5-tabbar-h) + 68px + var(--h5-safe-bottom));
    }

    body.has-h5-tabbar.has-product-mobile-bar .cs-popup {
        bottom: calc(var(--h5-tabbar-h) + 132px + var(--h5-safe-bottom));
    }

    /* 页脚底部留白 */
    body.has-h5-tabbar .site-footer {
        margin-bottom: 0;
    }
}

/* ---------- 产品详情移动端购买栏 ---------- */
.product-mobile-bar {
    display: none;
}

@media (max-width: 991.98px) {
    .product-mobile-bar {
        display: flex;
        bottom: calc(var(--h5-tabbar-h) + var(--h5-safe-bottom));
    }

    body:not(.has-h5-tabbar) .product-mobile-bar {
        bottom: 0;
    }

    .product-detail-page .page-wrap--product,
    .product-detail-page.page-wrap,
    .product-detail-full {
        padding-bottom: calc(72px + var(--h5-tabbar-h) + var(--h5-safe-bottom)) !important;
    }

    body:not(.has-h5-tabbar) .product-detail-page .page-wrap--product,
    body:not(.has-h5-tabbar) .product-detail-page.page-wrap {
        padding-bottom: 88px !important;
    }

    /* 移动端隐藏桌面购买按钮行，保留演示链接 */
    .product-detail-page .product-btn-row .btn-product-cart,
    .product-detail-page .product-btn-row .btn-product-buy {
        display: none;
    }

    .product-detail-page .product-btn-row {
        justify-content: flex-start;
    }
}

/* ---------- 会员中心 H5 导航 ---------- */
.member-h5-nav {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: var(--radius, 10px);
    padding: 8px;
    box-shadow: var(--shadow, 0 2px 8px rgba(15, 23, 42, .06));
}

.member-h5-nav-scroll {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0;
}

.member-h5-nav-scroll::-webkit-scrollbar {
    display: none;
}

.member-h5-nav-item {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #64748B;
    text-decoration: none;
    background: #F8FAFC;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: all .15s;
}

.member-h5-nav-item i {
    font-size: 14px;
}

.member-h5-nav-item.active {
    background: #EFF6FF;
    color: var(--primary, #2563EB);
    border-color: #BFDBFE;
    font-weight: 600;
}

.member-h5-menu-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 52px;
    padding: 6px 4px;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 10px;
    background: #F8FAFC;
    color: #475569;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

.member-h5-menu-btn i {
    font-size: 18px;
}

.member-h5-offcanvas {
    width: min(320px, 85vw);
}

.member-h5-offcanvas .member-sidebar-card {
    border: none;
    box-shadow: none;
    margin-bottom: 0 !important;
    border-radius: 0;
}

.member-h5-offcanvas .member-sidebar-nav {
    border-radius: 0;
    border-left: none;
    border-right: none;
}

/* 会员表格 → 卡片式（H5） */
@media (max-width: 767.98px) {
    .member-h5-table-cards .table-responsive {
        border: none;
    }

    .member-h5-table-cards .table {
        display: block;
    }

    .member-h5-table-cards .table thead {
        display: none;
    }

    .member-h5-table-cards .table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .member-h5-table-cards .table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border, #E2E8F0);
        border-radius: var(--radius, 10px);
        padding: 12px 14px;
        box-shadow: 0 1px 4px rgba(15, 23, 42, .04);
    }

    .member-h5-table-cards .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 5px 0;
        border: none;
        font-size: 13px;
    }

    .member-h5-table-cards .table tbody td::before {
        content: attr(data-label);
        flex-shrink: 0;
        color: #94A3B8;
        font-weight: 500;
        font-size: 12px;
    }

    .member-h5-table-cards .table tbody td:first-child {
        font-weight: 600;
        color: var(--text, #0F172A);
        padding-bottom: 8px;
        margin-bottom: 4px;
        border-bottom: 1px dashed #E2E8F0;
    }

    .member-h5-table-cards .table tbody td:first-child::before {
        display: none;
    }
}

/* ---------- 专题页 / 列表 H5 优化 ---------- */
@media (max-width: 991.98px) {
    .biz-topic-hero-title {
        font-size: clamp(22px, 5vw, 28px);
    }

    .list-card {
        border-radius: var(--radius, 10px);
    }

    .page-hero .breadcrumb {
        font-size: 12px;
        flex-wrap: wrap;
    }

    /* 联系页表单全宽 */
    .contact-topic-form-row .col-md-6 {
        width: 100%;
    }
}

/* ---------- 触屏 H5 交互 ---------- */
@media (hover: none) and (pointer: coarse) {
    .h5-tabbar-item,
    .member-h5-nav-item,
    .member-h5-menu-btn {
        min-height: 44px;
    }

    .btn,
    .nav-link,
    .list-filter-bar .btn {
        min-height: 40px;
    }
}

/* ---------- 暗色模式 H5 ---------- */
@media (prefers-color-scheme: dark) {
    @media (max-width: 991.98px) {
        .h5-tabbar {
            background: rgba(30, 41, 59, .97);
            border-top-color: #334155;
        }

        .h5-tabbar-item {
            color: #94A3B8;
        }

        .h5-tabbar-item.active {
            color: #93C5FD;
        }

        .member-h5-nav {
            background: #1E293B;
            border-color: #334155;
        }

        .member-h5-nav-item {
            background: #0F172A;
            color: #94A3B8;
        }

        .member-h5-nav-item.active {
            background: rgba(37, 99, 235, .15);
            color: #93C5FD;
            border-color: rgba(37, 99, 235, .3);
        }

        .member-h5-menu-btn {
            background: #0F172A;
            border-color: #334155;
            color: #CBD5E1;
        }

        .product-mobile-bar {
            background: rgba(30, 41, 59, .96);
            border-top-color: #334155;
        }
    }
}
