/* ============================================================
   海昊出口网 - 手机端增强样式 v2
   mobile-enhance.css v2.0
   完整重写，解决 4 大问题：
   ① 汉堡按钮在手机端正确显示
   ② Header 重新排序（汉堡|Logo|购物车，搜索独占第二行）
   ③ 筛选抽屉按钮正确显示在产品页
   ④ WhatsApp/返回顶部按钮避让
   ============================================================ */

/* ============================================================
   基础变量（避免与 style.css 冲突）
   ============================================================ */
:root {
    --mobile-menu-width: 280px;
    --mobile-filter-width: 320px;
    --header-h: 56px;
    --bottom-bar-h: 60px;
    --m-primary: #E94560;
    --m-secondary: #16213E;
    --m-text: #1a1a1a;
    --m-text-light: #666;
    --m-border: #f0f0f0;
    --m-bg: #f8f9fa;
}

/* ============================================================
   ① 汉堡菜单按钮 - 桌面隐藏
   ============================================================ */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--m-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(0.95);
}

.mobile-menu-btn.active {
    background: var(--m-primary);
    color: #fff;
}

/* ============================================================
   ② Header 重新排序 - 手机端（768px 以下）
   ============================================================ */
@media (max-width: 768px) {
    /* 关键：设置 flex 顺序 */
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    .header-content {
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 8px 0;
    }

    .header .logo {
        order: 2;
        flex: 1;
        min-width: 0;
    }

    .header .logo-text {
        overflow: hidden;
    }

    .header .logo-main {
        font-size: 16px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 140px;
    }

    .header .logo-sub {
        display: none !important;
    }

    .header-search {
        order: 4;
        flex: 0 0 100%;
        max-width: 100% !important;
        width: 100%;
        margin: 8px 0 0 0 !important;
        padding: 0;
    }

    .header-search form {
        display: flex;
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    .header-search input {
        flex: 1;
        height: 40px;
        padding: 0 16px;
        font-size: 14px;
        border: 1px solid #e0e0e0;
        border-right: none;
        border-radius: 24px 0 0 24px;
        background: #f5f5f5;
    }

    .header-search button {
        width: 50px;
        height: 40px;
        background: var(--m-primary);
        color: #fff;
        border: 1px solid var(--m-primary);
        border-radius: 0 24px 24px 0;
        font-size: 16px;
    }

    /* 顶部操作按钮组 */
    .header-cart,
    .header-wishlist,
    .header-compare {
        order: 3;
        position: relative;
    }

    .header-cart {
        margin-left: auto;
    }

    .header-cart .cart-text,
    .header-wishlist .cart-text,
    .header-compare .cart-text {
        display: none;
    }

    .header-cart a,
    .header-wishlist a,
    .header-compare a {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        color: var(--m-secondary);
    }

    /* 显示汉堡菜单按钮（关键：之前没设显示规则） */
    .mobile-menu-btn {
        display: inline-flex;
        order: 1;
    }
}

@media (max-width: 480px) {
    .header .logo-main { max-width: 110px; }
    .header .logo-icon { font-size: 22px !important; }

    /* 480px 隐藏 wishlist / compare 减少拥挤 */
    .header-wishlist,
    .header-compare { display: none !important; }
}

/* ============================================================
   ③ 汉堡导航面板 - 左侧滑出
   ============================================================ */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.mobile-nav-overlay.open {
    display: block;
    animation: fadeIn 0.2s ease;
}

.mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--mobile-menu-width);
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.mobile-nav.open {
    transform: translateX(0);
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--m-primary), #d63048);
    color: #fff;
    flex-shrink: 0;
}

.mobile-nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}

.mobile-nav-logo i { font-size: 20px; }

.mobile-nav-logo span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-nav-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.mobile-nav-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-nav-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav-section {
    padding: 14px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: #fafafa;
}

.mobile-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--m-text);
    border-bottom: 1px solid var(--m-border);
    text-decoration: none;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav a:active {
    background: #f0f0f0;
}

.mobile-nav a i {
    width: 20px;
    text-align: center;
    color: var(--m-primary);
    font-size: 16px;
    flex-shrink: 0;
}

.mobile-nav a span.badge-mobile {
    margin-left: auto;
    background: var(--m-primary);
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    min-width: 20px;
    text-align: center;
}

.mobile-nav-divider {
    height: 1px;
    background: var(--m-border);
    margin: 6px 0;
}

.mobile-nav-footer {
    padding: 16px 20px 20px;
    background: #fafafa;
    border-top: 1px solid var(--m-border);
    flex-shrink: 0;
}

.mobile-nav-footer-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    font-weight: 600;
}

.mobile-nav-currencies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.mobile-nav-currencies button {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #ddd;
    background: #fff;
    font-size: 12px;
    color: var(--m-text);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-width: 50px;
}

.mobile-nav-currencies button.active {
    background: var(--m-primary);
    color: #fff;
    border-color: var(--m-primary);
}

.mobile-nav-langs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.mobile-nav-langs button {
    padding: 8px 4px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    font-size: 12px;
    color: var(--m-text);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-langs button.active {
    background: var(--m-secondary);
    color: #fff;
    border-color: var(--m-secondary);
}

/* ============================================================
   ④ 筛选抽屉（产品列表页，右侧滑出）
   ============================================================ */
.mobile-filter-btn {
    display: none;
    position: fixed;
    bottom: 88px;
    left: 16px;
    background: var(--m-primary);
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
    z-index: 9980;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mobile-filter-btn:active {
    transform: scale(0.96);
}

.mobile-filter-btn .filter-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* 在产品页显示 */
body.products-page .mobile-filter-btn {
    display: inline-flex;
}

/* 筛选抽屉遮罩 */
.filter-drawer-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.filter-drawer-overlay.open { display: block; }

.filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--mobile-filter-width);
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.filter-drawer.open {
    transform: translateX(0);
}

.filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid var(--m-border);
    flex-shrink: 0;
}

.filter-drawer-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--m-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-drawer-header h3 i { color: var(--m-primary); }

.filter-drawer-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #666;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.filter-drawer-close:active { background: #e0e0e0; }

.filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}

.filter-drawer-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--m-border);
    background: #fff;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.filter-drawer-footer button {
    flex: 1;
    padding: 12px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.filter-drawer-footer .btn-reset {
    background: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
}

.filter-drawer-footer .btn-apply {
    background: var(--m-primary);
    color: #fff;
    border: none;
}

.filter-drawer-footer .btn-apply:active {
    background: #c93a52;
}

/* ============================================================
   ⑤ 返回顶部按钮
   ============================================================ */
.back-to-top {
    display: none;
    position: fixed;
    bottom: 88px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: var(--m-secondary);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    box-shadow: 0 4px 16px rgba(22, 33, 62, 0.3);
    z-index: 9970;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.3s, transform 0.2s, background 0.2s;
    opacity: 0;
}

.back-to-top.show {
    display: flex;
    opacity: 1;
}

.back-to-top:active {
    transform: scale(0.92);
    background: var(--m-primary);
}

/* ============================================================
   ⑥ WhatsApp 避让
   ============================================================ */
.whatsapp-float,
.whatsapp-btn,
.whatsapp-icon,
a[href*="wa.me"],
a[href*="whatsapp"] {
    bottom: 150px !important;
}

/* ============================================================
   ⑦ 通用手机端细节优化
   ============================================================ */
@media (max-width: 768px) {
    /* Hero 优化 */
    .hero-section {
        height: 320px !important;
    }

    .hero-content {
        margin: 40px auto !important;
        padding: 0 16px;
    }

    .hero-content h1 {
        font-size: 22px !important;
        line-height: 1.3;
    }

    .hero-content p {
        font-size: 13px !important;
        margin-bottom: 16px !important;
    }

    .hero-content .btn-lg {
        padding: 10px 22px !important;
        font-size: 13px !important;
    }

    /* 幻灯片指示器 */
    .slide-indicators {
        bottom: 16px !important;
    }

    /* 区块 */
    .section {
        padding: 32px 0 !important;
    }

    .section-header {
        margin-bottom: 20px !important;
    }

    .section-header h2 {
        font-size: 18px !important;
    }

    .section-link {
        font-size: 12px !important;
    }

    /* 分类网格 */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .category-card {
        padding: 16px 8px !important;
    }

    .category-icon {
        font-size: 28px !important;
        margin-bottom: 6px !important;
    }

    .category-card h3 {
        font-size: 13px !important;
    }

    /* 产品卡片 */
    .product-card {
        border-radius: 10px !important;
        overflow: hidden;
    }

    .product-img {
        height: 130px !important;
    }

    .product-info {
        padding: 10px !important;
    }

    .product-info h3 {
        font-size: 12px !important;
        line-height: 1.3;
        height: 32px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .current-price {
        font-size: 14px !important;
    }

    .product-actions {
        opacity: 1 !important;
        transform: translateY(0) !important;
        position: static !important;
    }

    .product-actions .btn {
        font-size: 11px !important;
        padding: 6px 8px !important;
    }

    /* 信任体系 */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .feature-card {
        display: flex;
        align-items: center;
        text-align: left;
        padding: 16px !important;
        gap: 14px;
    }

    .feature-icon {
        font-size: 28px !important;
        margin-bottom: 0 !important;
        flex-shrink: 0;
        width: 48px;
        text-align: center;
    }

    .feature-card h3 {
        font-size: 14px !important;
        margin-bottom: 2px !important;
    }

    .feature-card p {
        font-size: 12px !important;
        margin: 0;
    }

    /* 促销区块 */
    .promo-banner {
        padding: 24px 16px !important;
    }

    .promo-text h2 {
        font-size: 20px !important;
    }

    .promo-text p {
        font-size: 13px !important;
    }

    /* 邮件订阅 */
    .newsletter-form input,
    .newsletter-form button {
        width: 100% !important;
        border-radius: 24px !important;
        margin-bottom: 8px;
    }

    .newsletter-form button { margin-bottom: 0; }

    /* Footer */
    .footer {
        padding-bottom: 80px !important;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 28px !important;
    }

    .footer-widget h3 {
        font-size: 15px !important;
        margin-bottom: 12px !important;
    }

    .footer-widget p,
    .footer-widget li {
        font-size: 13px !important;
    }

    .footer-bottom {
        flex-direction: column !important;
        text-align: center;
        gap: 12px !important;
        padding: 20px 0 !important;
    }

    .footer-bottom p {
        font-size: 11px !important;
    }

    /* 通用按钮 */
    .btn {
        padding: 10px 18px !important;
        font-size: 13px !important;
    }

    .btn-lg {
        padding: 12px 24px !important;
        font-size: 14px !important;
    }

    /* Mini 购物车 */
    .mini-cart-dropdown {
        width: calc(100vw - 24px) !important;
        right: -8px !important;
        max-height: 75vh;
    }

    /* 模态框 */
    .modal-overlay .modal-box {
        width: 92% !important;
        max-height: 88vh;
        border-radius: 12px !important;
    }

    /* 防止 iOS 输入框缩放 */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* 滚动条美化 */
    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 2px; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px !important; }

    .hero-content h1 { font-size: 20px !important; }
    .hero-content p { font-size: 12px !important; }

    .product-img { height: 110px !important; }
    .product-info h3 { font-size: 11px !important; }
    .current-price { font-size: 13px !important; }
}

/* ============================================================
   ⑧ 动画
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   ⑨ 安全区适配 - iPhone X 等刘海屏
   ============================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .back-to-top {
        bottom: calc(88px + env(safe-area-inset-bottom));
    }
    .mobile-filter-btn {
        bottom: calc(88px + env(safe-area-inset-bottom));
    }
    .whatsapp-float,
    a[href*="wa.me"] {
        bottom: calc(150px + env(safe-area-inset-bottom)) !important;
    }
    .footer {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
}

/* ============================================================
   ⑩ body 锁定 - 防止面板打开时背景滚动
   ============================================================ */
body.nav-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
