/**
 * YiwuPage Mobile UX Enhancement — Phase 13.4
 * themes/yiwupage/assets/css/mobile.css
 * 
 * 加载方式: media="(max-width: 768px)" — 仅手机端加载，不增加PC负担
 * 优先级: 在各页面CSS之后加载，覆盖PC/平板断点样式
 * 
 * 改进项目:
 * - 底部快捷导航栏 (검색/기업디렉토리/기업등록)
 * - Header 搜索栏常驻显示
 * - 企业详情页底部 CTA 增强 (문의하기 + 전화)
 * - Safe-area 适配 (iPhone 刘海屏/底部横条)
 * - 首页移动端精简 (Stats 横向滚动)
 * - 分类/搜索/市场页面移动优化
 * - 触控友好 (44px+ 点击区域)
 * - 图片 CLS 优化 (aspect-ratio)
 * - 滚动优化 (-webkit-overflow-scrolling)
 */

@media (max-width: 768px) {

/* =========================================================
   0. 基础 & Safe Area
   ========================================================= */

body {
    padding-bottom: 60px; /* 为底部导航留空间 */
    -webkit-text-size-adjust: 100%;
}

body.yp-no-bottom-nav {
    padding-bottom: 0; /* 企业详情页自己管理底部空间 */
}

.yp-container {
    padding-left: 14px;
    padding-right: 14px;
}

/* iOS safe-area 适配 */
@supports (padding: env(safe-area-inset-bottom)) {
    body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
    body.yp-no-bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
    .yp-mobile-nav-bar { padding-bottom: env(safe-area-inset-bottom); }
    .yp-cd-mobile-cta { padding-bottom: env(safe-area-inset-bottom); }
}


/* =========================================================
   1. 底部快捷导航栏
   ========================================================= */

.yp-mobile-nav-bar {
    display: none; /* 默认隐藏，此文件 @media 内覆盖 */
}

/* 只有非企业详情页显示底部导航 */
body:not(.yp-no-bottom-nav) > .yp-mobile-nav-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--yp-white);
    border-top: 1px solid var(--yp-gray-200);
    z-index: 50;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.yp-mobile-nav-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    color: var(--yp-gray-500);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    transition: var(--yp-transition);
    -webkit-tap-highlight-color: transparent;
}

.yp-mobile-nav-bar a:active {
    background: var(--yp-gray-100);
}

.yp-mobile-nav-bar a .nav-icon {
    font-size: 20px;
    line-height: 1;
}

.yp-mobile-nav-bar a.active {
    color: var(--yp-blue);
}

.yp-mobile-nav-bar .yp-nav-register {
    background: var(--yp-blue);
    color: white;
    border-radius: 20px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 11px;
    flex-direction: row;
    gap: 4px;
}

.yp-mobile-nav-bar .yp-nav-register .nav-icon {
    font-size: 14px;
}

/* 非企业详情页 footer 底部留空 */
body:not(.yp-no-bottom-nav) .yp-footer {
    margin-bottom: 56px;
}


/* =========================================================
   2. Header 移动端增强
   ========================================================= */

/* 汉堡菜单优化 — 更大触控区域 */
.yp-mobile-menu-btn {
    padding: 10px !important;
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

/* 移动端显示紧凑搜索框（替代隐藏的 header-search） */
.yp-mobile-search-inline {
    display: flex !important;
    flex: 1;
    max-width: 180px;
    margin: 0 8px;
    border: 1px solid var(--yp-gray-200);
    border-radius: 20px;
    overflow: hidden;
    background: var(--yp-gray-50);
}

.yp-mobile-search-inline input {
    flex: 1;
    border: none;
    background: none;
    padding: 6px 12px;
    font-size: 13px;
    outline: none;
    min-width: 0;
    color: var(--yp-gray-800);
}

.yp-mobile-search-inline input::placeholder {
    color: var(--yp-gray-400);
}

.yp-mobile-search-inline button {
    background: var(--yp-blue);
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

/* Header 排列顺序: Logo | 搜索 | 菜单按钮 */
.yp-header-inner {
    gap: 4px !important;
}

.yp-logo {
    flex-shrink: 0;
}

.yp-mobile-menu-btn {
    order: 3;
    flex-shrink: 0;
}

/* 移动导航面板优化 */
.yp-mobile-nav {
    border-top: 1px solid var(--yp-gray-200);
}

.yp-mobile-nav a {
    padding: 14px 0 !important; /* 更大触控区域 */
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}

.yp-mobile-search {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--yp-gray-100);
}

.yp-mobile-search-input {
    padding: 12px !important; /* 更大触控区域 */
    font-size: 15px;
}

.yp-mobile-search button {
    padding: 12px 20px !important;
    font-size: 14px;
}


/* =========================================================
   3. 首页 (Home) 移动端优化
   ========================================================= */

/* Hero 区域 */
.yp-hero {
    padding: 32px 0 28px !important;
}

.yp-hero h1 {
    font-size: 21px !important;
    line-height: 1.35;
}

.yp-hero-subtitle {
    font-size: 13px !important;
    margin-bottom: 20px;
}

.yp-hero-search {
    margin-bottom: 16px !important;
}

.yp-hero-search-input {
    padding: 12px 14px !important;
    font-size: 15px !important; /* iOS <16px 不自动缩放 */
}

.yp-hero-search-btn {
    padding: 12px 18px !important;
    font-size: 14px !important;
}

.yp-hero-keywords {
    gap: 6px;
}

.yp-hero-keyword {
    padding: 5px 10px;
    font-size: 12px;
    -webkit-tap-highlight-color: transparent;
}

/* Stats — 横向滚动，更紧凑 */
.yp-stats-inner {
    gap: 0 !important;
    justify-content: flex-start !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 4px;
}

.yp-stats-inner::-webkit-scrollbar {
    display: none;
}

.yp-stat {
    flex-shrink: 0;
    min-width: 72px;
    padding: 0 10px;
}

.yp-stat-num {
    font-size: 18px !important;
}

.yp-stat-label {
    font-size: 10px !important;
    white-space: nowrap;
}

/* Section 间距 */
.yp-section {
    padding: 24px 0 !important;
}

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

.yp-section-title {
    font-size: 16px !important;
}

/* 分类卡片更紧凑 */
.yp-category-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
}

.yp-category-card {
    padding: 10px 6px !important;
    -webkit-tap-highlight-color: transparent;
}

.yp-category-icon {
    font-size: 22px !important;
    margin-bottom: 4px !important;
}

.yp-category-name {
    font-size: 11px !important;
    line-height: 1.3;
}

.yp-category-count {
    font-size: 9px !important;
}

/* 企业卡片移动端紧凑 */
.yp-company-card {
    padding: 14px !important;
}

.yp-card-name {
    font-size: 15px !important;
}

.yp-card-products {
    font-size: 12px !important;
}

.yp-card-location {
    font-size: 11px !important;
}

.yp-card-badges {
    gap: 4px;
    margin-bottom: 6px;
}

.yp-badge {
    font-size: 10px !important;
    padding: 2px 6px !important;
}

.yp-card-footer {
    font-size: 12px;
}

/* Market 卡片 */
.yp-market-card {
    padding: 14px !important;
}

.yp-market-name {
    font-size: 14px !important;
}


/* =========================================================
   4. 企业详情页 (Company Detail) 移动端增强
   ========================================================= */

/* 面包屑 */
.yp-cd-hero nav {
    font-size: 11px;
    margin-bottom: 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.yp-cd-hero nav::-webkit-scrollbar {
    display: none;
}

/* Hero 区域 */
.yp-cd-hero {
    padding: 16px 0 !important;
}

.yp-cd-name {
    font-size: 18px !important;
}

.yp-cd-name-sub {
    font-size: 12px !important;
}

.yp-cd-logo {
    width: 56px !important;
    height: 56px !important;
    font-size: 28px !important;
}

/* Trust Bar 横向滚动 */
.yp-cd-trust-inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start !important;
    gap: 0 !important;
    padding: 0 4px;
}

.yp-cd-trust-inner::-webkit-scrollbar {
    display: none;
}

.yp-cd-trust-item {
    flex-shrink: 0;
    min-width: 72px;
    padding: 0 8px;
}

.yp-cd-trust-num {
    font-size: 14px !important;
}

.yp-cd-trust-label {
    font-size: 9px !important;
    white-space: nowrap;
}

/* 产品图片网格 */
.yp-cd-products {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
}

.yp-cd-product-img {
    aspect-ratio: 1; /* 防止 CLS */
}

.yp-cd-product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yp-cd-product-name {
    font-size: 13px !important;
}

/* Sidebar → 全宽 */
.yp-cd-sidebar {
    border-left: none !important;
    padding-left: 0 !important;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--yp-gray-200);
}

/* 相关企业紧凑 */
.yp-cd-related {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
}

.yp-cd-related-card {
    padding: 10px !important;
}

/* 移动 CTA 底部增强 */
.yp-cd-mobile-cta {
    padding: 8px 14px !important;
    display: flex !important;
    gap: 8px;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.yp-cd-mobile-cta a {
    padding: 12px 8px !important;
    font-size: 14px !important;
    text-align: center;
}

.yp-cd-mobile-cta .yp-cta-inquiry {
    flex: 2;
    background: var(--yp-blue);
    color: white;
    border-radius: var(--yp-radius);
    font-weight: 700;
    text-decoration: none;
    display: block;
    padding: 12px !important;
    font-size: 14px !important;
    text-align: center;
}

.yp-cd-mobile-cta .yp-cta-call {
    flex: 1;
    background: var(--yp-green);
    color: white;
    border-radius: var(--yp-radius);
    font-weight: 700;
    text-decoration: none;
    display: block;
    padding: 12px !important;
    font-size: 14px !important;
    text-align: center;
}

/* Footer 在企业详情页留空间给 CTA */
body.yp-no-bottom-nav .yp-footer {
    margin-bottom: 68px !important;
}


/* =========================================================
   5. 分类目录页 (Directory) 移动端增强
   ========================================================= */

.yp-dir-hero-title {
    font-size: 20px !important;
}

/* 分类网格 */
.yp-dir-cat-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
}

.yp-dir-cat-card {
    padding: 10px 6px !important;
    -webkit-tap-highlight-color: transparent;
}

.yp-dir-cat-card .cat-icon {
    font-size: 20px !important;
}

.yp-dir-cat-card .cat-name {
    font-size: 11px !important;
}

/* 统计栏横向滚动 */
.yp-cate-stats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start !important;
    gap: 0 !important;
}

.yp-cate-stats::-webkit-scrollbar {
    display: none;
}

.yp-cate-stat {
    flex-shrink: 0;
    padding: 0 10px;
}

/* 企业列表卡片 */
.yp-dir-company {
    padding: 12px !important;
    -webkit-tap-highlight-color: transparent;
}

/* 排序栏 */
.yp-dir-sort {
    gap: 6px !important;
}

.yp-dir-sort a,
.yp-dir-sort span {
    font-size: 12px !important;
    padding: 5px 8px !important;
}

/* 市场卡片 */
.yp-dir-market-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
}

.yp-dir-market-card {
    padding: 14px !important;
}

/* 目录主页 Hero */
.yp-dir-hero-search {
    flex-direction: column !important;
}

.yp-dir-hero-search input {
    font-size: 15px !important; /* iOS 防缩放 */
    padding: 12px !important;
}


/* =========================================================
   6. 搜索页 (Search) 移动端增强
   ========================================================= */

/* 搜索表单 */
.yp-search-hero-form {
    flex-direction: column !important;
}

.yp-search-hero-form input {
    font-size: 15px !important; /* iOS 防缩放 */
    padding: 12px !important;
}

.yp-search-hero-form button {
    width: 100%;
    padding: 12px !important;
}

/* 筛选面板 — 水平滚动筛选条 */
.yp-filter-panel {
    position: static !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px !important;
    scrollbar-width: none;
    border-bottom: 1px solid var(--yp-gray-200);
    margin-bottom: 16px;
}

.yp-filter-panel::-webkit-scrollbar {
    display: none;
}

.yp-filter-box {
    flex-shrink: 0;
    min-width: 170px;
    margin-bottom: 0 !important;
    border: 1px solid var(--yp-gray-200) !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
}

.yp-filter-box h4 {
    font-size: 12px !important;
    margin-bottom: 6px !important;
}

.yp-filter-box label {
    font-size: 12px !important;
    padding: 3px 0 !important;
    min-height: 30px;
}

/* 触控优化 */
.yp-filter-box a,
.yp-search-result-card,
.yp-hot-tag {
    -webkit-tap-highlight-color: transparent;
}


/* =========================================================
   7. 通用移动端组件优化
   ========================================================= */

/* SEO Block */
.yp-seo-block {
    padding: 18px !important;
}

.yp-seo-block h2 {
    font-size: 15px !important;
}

.yp-seo-block p {
    font-size: 13px !important;
    line-height: 1.7 !important;
}

/* Footer */
.yp-footer {
    padding: 32px 0 20px !important;
}

.yp-footer-title {
    font-size: 13px !important;
}

.yp-footer-text {
    font-size: 12px !important;
}

.yp-footer-links a {
    font-size: 12px !important;
    padding: 4px 0;
    min-height: 30px;
    display: inline-block;
}

/* 分页触控友好 */
.yp-pagination a,
.yp-pagination span {
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 所有链接触控优化 */
a {
    -webkit-tap-highlight-color: transparent;
}

} /* END @media (max-width: 768px) */


/* =========================================================
   8. 超小屏幕 (≤480px) 微调
   ========================================================= */

@media (max-width: 480px) {
    /* 首页分类改为 3 列 */
    .yp-category-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* 目录分类 2 列 */
    .yp-dir-cat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* 市场卡片全宽 */
    .yp-dir-market-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 企业详情 Logo 更小 */
    .yp-cd-logo {
        width: 48px !important;
        height: 48px !important;
        font-size: 24px !important;
    }
    
    .yp-cd-name {
        font-size: 16px !important;
    }
    
    /* 底部导航文字隐藏，只留图标 */
    .yp-mobile-nav-bar a .nav-text {
        display: none;
    }
    
    .yp-mobile-nav-bar a {
        font-size: 0;
    }
    
    .yp-mobile-nav-bar a .nav-icon {
        font-size: 22px;
    }
    
    /* 底部导航注册按钮保持文字 */
    .yp-mobile-nav-bar .yp-nav-register {
        font-size: 11px;
    }
    
    .yp-mobile-nav-bar .yp-nav-register .nav-text {
        display: inline;
    }
}
