/* ============================================================
 * 小虻生态 · 手机端专用样式层 (mobile.css)
 * ------------------------------------------------------------
 * 设计原则：
 *   1. 不污染桌面端 —— 全部规则包裹在 @media (max-width: 900px)
 *   2. 不照搬桌面端 —— 按手机该有的格式：底部 Tab、全屏抽屉、
 *      大触摸目标、卡片化列表、单列阅读宽度
 *   3. 渐进增强 —— 叠加在 style.css 之上，只覆盖需要调整的属性
 *
 * 断点策略：
 *   ≤ 900px  平板竖屏 / 小桌面  — 启用手机布局
 *   ≤ 640px  主流手机           — 字体/间距/触摸目标精细优化
 *   ≤ 380px  小屏手机           — 兜底防溢出
 * ============================================================ */

/* ============================================================
 * 1. 全局基础：字体、触摸目标、滚动
 * ============================================================ */
@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    font-size: 15px;           /* 桌面 14px → 手机 15px，阅读更舒适 */
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;  /* iOS momentum scroll */
    /* 给底部 Tab 栏留出空间，避免内容被遮挡 */
    padding-bottom: 60px;
  }

  /* 所有可点击元素最小触摸目标 44×44（iOS HIG / Material 规范） */
  a, button, .btn-primary, .btn-outline, .btn-buy,
  .nav-member-link, .nav-cta, .tool-card, .product-tab,
  .claim-btn, .faq-q, .chat-panel-header button {
    min-height: 44px;
    min-width: 44px;
  }

  /* 链接默认不要那么紧的间距 */
  p, li { font-size: 15px; line-height: 1.7; }
  h1 { font-size: 26px !important; line-height: 1.25 !important; }
  h2 { font-size: 22px !important; line-height: 1.3 !important; }
  h3 { font-size: 18px !important; line-height: 1.35 !important; }
  h4 { font-size: 16px !important; }

  /* 隐藏桌面端"返回顶部"小按钮（底部 Tab 已有更优方案） */
  .footer-back-top { display: none !important; }
}

/* ============================================================
 * 2. 顶部导航栏 + 汉堡菜单全屏抽屉
 * ============================================================ */
@media (max-width: 900px) {
  .navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
  }
  .nav-inner {
    max-width: 100%;
    padding: 0 16px;
    height: 56px;
  }
  .nav-logo span {
    font-size: 16px;
    font-weight: 700;
  }
  .nav-logo .logo-icon {
    width: 32px; height: 32px;
    font-size: 16px;
  }

  /* 汉堡菜单按钮加大触摸区 */
  .nav-toggle {
    width: 44px; height: 44px;
    justify-content: center;
    align-items: center;
  }
  .nav-toggle span {
    width: 22px; height: 2.5px;
    border-radius: 2px;
  }

  /* ── 全屏抽屉式菜单 ── */
  .nav-links {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FFFFFF;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 0 80px;     /* 底部留空给 Tab 栏 */
    overflow-y: auto;
    box-shadow: none;
    border-top: 1px solid var(--gray-200);
    z-index: 999;
  }
  .nav-links.open {
    display: flex;
    animation: mobileNavSlide 0.22s ease-out;
  }
  @keyframes mobileNavSlide {
    from { transform: translateX(100%); opacity: 0.6; }
    to   { transform: translateX(0); opacity: 1; }
  }

  /* 抽屉里的链接：大字、大间距、明确分隔 */
  .nav-links > a,
  .nav-dropdown-trigger {
    display: flex !important;
    align-items: center;
    padding: 16px 20px !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    color: var(--gray-800) !important;
    border-bottom: 1px solid var(--gray-100);
    background: transparent !important;
    border-radius: 0 !important;
    min-height: 52px;
  }
  .nav-links > a:active,
  .nav-dropdown-trigger:active {
    background: var(--green-pale) !important;
  }

  /* dropdown 在手机端默认展开（不再 hover 触发） */
  .nav-dropdown {
    display: block;
    width: 100%;
  }
  .nav-dropdown-menu {
    position: static;
    transform: none;
    box-shadow: none;
    border: none;
    background: var(--gray-50);
    min-width: 0;
    padding: 0;
    display: block;     /* 抽屉模式默认展开 */
  }
  .nav-dropdown-menu a {
    padding: 14px 24px 14px 36px !important;
    font-size: 15px !important;
    color: var(--gray-600) !important;
    border-bottom: 1px solid var(--gray-100);
    min-height: 48px;
    display: flex;
    align-items: center;
  }
  .nav-dropdown-menu a:active {
    background: var(--green-pale);
  }

  /* 分隔线、CTA 按钮 */
  .nav-divider { display: none !important; }
  .nav-cta {
    margin: 16px 20px !important;
    text-align: center;
    justify-content: center;
    border-radius: 24px !important;
    font-size: 16px !important;
    padding: 14px 24px !important;
  }
  .nav-member-link {
    text-align: center;
    justify-content: center;
    padding: 14px 24px !important;
    font-size: 16px !important;
  }
  .nav-lang {
    justify-content: center;
    padding: 14px 24px !important;
    font-size: 15px !important;
  }

  /* 会员下拉改静态展开 */
  .nav-member { width: 100%; }
  .nav-member-name {
    width: 100%;
    justify-content: center;
    padding: 14px 24px !important;
    font-size: 16px !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--gray-100);
  }
  .nav-member-dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: var(--gray-50);
    padding: 0;
    min-width: 0;
  }
  .nav-member-dropdown a {
    padding: 14px 24px 14px 36px !important;
    font-size: 15px !important;
    border-bottom: 1px solid var(--gray-100);
  }
}

/* ============================================================
 * 3. 底部 Tab 栏（手机端核心导航）
 * ============================================================ */
@media (max-width: 900px) {
  .mobile-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 998;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    padding: 0 4px;
    /* 兼容 iOS safe area */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mobile-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    color: var(--gray-500, #6b7280);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    min-height: 56px;
    transition: color 0.15s, transform 0.25s ease;
  }
  .mobile-tabbar a .tab-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
  }
  .mobile-tabbar a.active {
    color: var(--green-primary, #2E8B57);
    font-weight: 700;
  }
  .mobile-tabbar a.active .tab-icon {
    transform: scale(1.08);
  }
}
/* 桌面端隐藏 Tab 栏 */
@media (min-width: 901px) {
  .mobile-tabbar { display: none !important; }
}

/* ============================================================
 * 4. Footer 简化（手机端只保留版权 + 备案）
 * ============================================================ */
@media (max-width: 900px) {
  .footer { padding: 32px 16px 16px; }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .footer-brand { grid-column: 1 / -1; }
  .footer-tagline { font-size: 13px; line-height: 1.6; }
  .footer-social { justify-content: flex-start; }
  .footer-social .social-icon {
    width: 36px; height: 36px;
    margin-right: 8px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding-top: 16px;
    font-size: 12px;
  }
  .footer-bottom-sep { display: none; }
  .footer-visit { font-size: 12px; }
  .footer-address { font-size: 12px; }
  .footer-bottom-right { flex-direction: column; gap: 4px; }
}

/* ============================================================
 * 5. chatbot 悬浮球避让底部 Tab
 * ============================================================ */
@media (max-width: 900px) {
  #xiaomengeco-chat-bubble {
    bottom: 72px !important;       /* 上移避开 Tab 栏 */
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
  }
  #xiaomengeco-chat-panel {
    bottom: 60px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: 420px;
    height: 70vh !important;
    max-height: 520px;
    border-radius: 14px;
  }
}

/* ============================================================
 * 6. Hero 区简化
 * ============================================================ */
@media (max-width: 900px) {
  .hero {
    min-height: auto !important;
    padding: 40px 16px 32px;
  }
  .hero-inner {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    padding-top: 0 !important;
  }
  .hero-visual { order: 1 !important; }
  .hero-card {
    padding: 20px 16px;
    max-width: 100% !important;
  }
  .hero-badge { font-size: 12px; padding: 5px 12px; margin-bottom: 14px; }
  .hero-endorsement { font-size: 11px; margin-bottom: 20px; }
  .hero-buttons {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .hero-buttons .btn-primary,
  .hero-buttons .btn-outline {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 13px 24px;
    font-size: 15px;
  }
  .mega-bar {
    gap: 10px !important;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .mega-item { flex: 1 1 30%; min-width: 0; }
  .mega-item .num { font-size: 18px !important; }
  .mega-item .label { font-size: 10px !important; }
}

/* ============================================================
 * 7. 行情速览（首页 + 价格页）卡片化
 * ============================================================ */
@media (max-width: 900px) {
  .price-section,
  .map-section,
  .tool-section {
    padding: 28px 16px !important;
  }
  .price-section h2,
  .map-section h2,
  .tool-section h2 {
    font-size: 22px !important;
    text-align: left !important;
  }
  .price-section .subtitle,
  .map-section .subtitle {
    font-size: 13px !important;
    text-align: left !important;
  }

  /* 行情表格 → 卡片列表（不再横滑） */
  .price-table thead { display: none; }
  .price-table,
  .price-table tbody,
  .price-table tr,
  .price-table td { display: block; width: 100%; }
  .price-table tr {
    background: #FFFFFF;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .price-table td {
    border: none !important;
    padding: 6px 0 !important;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .price-table td::before {
    content: attr(data-label);
    color: var(--gray-500, #6b7280);
    font-size: 13px;
    font-weight: 500;
  }
  .price-table td.rn {
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--gray-100) !important;
    padding-bottom: 8px !important;
    margin-bottom: 4px;
  }
  .price-table td.rn::before { display: none; }
  .price-table .pu { font-size: 15px; }

  /* 价格详情页表格也卡片化 */
  .price-page table thead { display: none; }
  .price-page table,
  .price-page table tbody,
  .price-page table tr,
  .price-page table td,
  .price-page table th {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
  }
  .price-page table tr {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 10px 12px;
  }
  .price-page table td {
    border: none !important;
    padding: 5px 0 !important;
    display: flex;
    justify-content: space-between;
  }
  .price-page table td:first-child {
    font-weight: 700;
    color: var(--green-dark);
    border-bottom: 1px solid var(--gray-100) !important;
    padding-bottom: 6px !important;
    margin-bottom: 4px;
  }

  /* 热力图卡片简化 */
  .overview-panel {
    padding: 14px !important;
    margin-top: 16px;
  }
  #priceHeatmap3d { height: 220px !important; }
}

/* ============================================================
 * 8. 产业地图板块简化
 * ============================================================ */
@media (max-width: 900px) {
  .map-display {
    grid-template-columns: 1fr !important;
    border-radius: 10px;
  }
  .map-visual { padding: 16px !important; min-height: auto !important; }
  .ent-row { padding: 12px !important; }
  .ent-row-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .ent-name { font-size: 14px !important; }
  .ent-total { font-size: 16px !important; }
  .claim-btn {
    margin-left: auto !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
  }
  .ent-regions { gap: 6px 8px !important; }
  .ent-regions .r-tag { font-size: 11px; padding: 3px 8px; }

  /* 右侧 CTA 卡片 */
  .map-cta { padding: 24px 16px !important; }
  .map-cta h3 { font-size: 18px !important; }
  .map-cta .stats-row { gap: 10px !important; }
  .map-cta .stat-item .num { font-size: 20px !important; }
  .map-cta .stat-item .lbl { font-size: 10px !important; }
  .map-cta .btn {
    width: 100%;
    text-align: center;
    padding: 13px 24px;
    font-size: 15px;
  }
}

/* ============================================================
 * 9. 工具入口网格
 * ============================================================ */
@media (max-width: 900px) {
  .tool-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .tool-card {
    padding: 16px 10px !important;
    border-radius: 10px;
  }
  .tool-card .icon { font-size: 26px !important; }
  .tool-card h3 { font-size: 13px !important; margin: 6px 0 2px; }
  .tool-card p { font-size: 11px !important; line-height: 1.4; }
}
@media (max-width: 380px) {
  .tool-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
 * 10. 通用列表 / 卡片 / 表单
 * ============================================================ */
@media (max-width: 900px) {
  /* 各类网格 → 单列或双列 */
  .engine-grid,
  .product-grid,
  .expert-grid,
  .entry-hall-grid,
  .dashboard-grid,
  .process-grid,
  .coop-grid,
  .preview-grid,
  .nav-cards-grid,
  .region-cards-grid,
  .insight-grid,
  .ent-grid,
  .contact-grid,
  .list-grid,
  .library-list .list-grid,
  .knowledge-list .list-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .engine-card,
  .product-card { padding: 20px !important; }

  /* insight hero flex 改纵向 */
  .insight-hero-flex { flex-direction: column !important; gap: 16px !important; }
  .contact-grid { gap: 24px !important; }

  /* section padding */
  .section { padding: 40px 16px !important; }
  .section-inner { padding-left: 16px !important; padding-right: 16px !important; }
  .section-header { margin-bottom: 28px !important; }
  .section-header h2 { font-size: 22px !important; }
  .section-header p { font-size: 14px !important; }

  /* 卡片圆角统一 */
  .product-card,
  .engine-card,
  .brief-card,
  .tool-card { border-radius: 12px !important; }

  /* 表单输入框加大 */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  textarea,
  select {
    width: 100%;
    font-size: 16px !important;     /* ≥16px 防 iOS 缩放 */
    padding: 12px 14px !important;
    border-radius: 10px !important;
    min-height: 48px;
    box-sizing: border-box;
  }
  textarea { min-height: 120px; }

  /* 按钮全宽 */
  .btn-primary,
  .btn-outline,
  .btn-buy,
  .cta-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 14px 24px !important;
    font-size: 16px !important;
  }

  /* 报告/文章列表 */
  .report-list,
  .faq-list,
  .price-page { padding: 0 4px !important; }

  /* 文章/详情页阅读宽度 */
  .article-body,
  .report-content,
  .knowledge-article,
  .insight-body,
  .faq-a {
    font-size: 16px !important;
    line-height: 1.8 !important;
  }
  .article-body img,
  .report-content img,
  .knowledge-article img { max-width: 100%; height: auto; }

  /* 分页按钮加大 */
  .pagination a,
  .pagination span {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 12px !important;
    font-size: 14px;
  }
}

/* ============================================================
 * 11. 错误页 / 空状态 / 加载
 * ============================================================ */
@media (max-width: 900px) {
  .error-page,
  .empty-state,
  .loading-state {
    padding: 40px 20px !important;
    text-align: center;
  }
  .error-page h1 { font-size: 64px !important; }
  .error-page p { font-size: 15px; }
}

/* ============================================================
 * 12. 登录 / 注册 / 会员页
 * ============================================================ */
@media (max-width: 900px) {
  .auth-page { padding: 32px 16px !important; }
  .auth-card,
  .auth-form {
    width: 100% !important;
    max-width: 100% !important;
    padding: 24px 20px !important;
    border-radius: 14px !important;
  }
  .auth-card h2,
  .auth-form h2 { font-size: 22px !important; }

  /* 会员中心 */
  .member-dashboard,
  .profile-page { padding: 24px 16px !important; }
  .member-sidebar {
    width: 100% !important;
    margin-bottom: 16px;
  }
}

/* ============================================================
 * 13. 管理后台
 * ============================================================ */
@media (max-width: 900px) {
  .admin-layout { flex-direction: column !important; }
  .admin-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--gray-200);
  }
  .admin-content { padding: 16px !important; }
  .admin-table,
  .admin-table thead,
  .admin-table tbody,
  .admin-table tr,
  .admin-table th,
  .admin-table td {
    display: block;
    width: 100%;
  }
  .admin-table thead { display: none; }
  .admin-table tr {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 10px;
  }
  .admin-table td {
    border: none !important;
    padding: 6px 0 !important;
    display: flex;
    justify-content: space-between;
  }
  .admin-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-500);
    margin-right: 12px;
  }
}

/* ============================================================
 * 14. 英文站 / 产业地图 / 知识库等专用页
 * ============================================================ */
@media (max-width: 900px) {
  .en-hero-inner { padding: 40px 16px !important; }
  .library-list .list-grid,
  .knowledge-list .list-grid { grid-template-columns: 1fr !important; }
  #china-map { height: 320px !important; }
  .map-stats-bar { flex-wrap: wrap; gap: 12px !important; }
  .map-stat-num { font-size: 20px !important; }
}

/* ============================================================
 * 15. 微调：≤640px 主流手机
 * ============================================================ */
@media (max-width: 640px) {
  body { font-size: 14px; padding-bottom: 64px; }
  .nav-inner { height: 52px; padding: 0 14px; }
  .nav-links { top: 52px; }

  .hero { padding: 32px 14px 24px; }
  .hero h1 { font-size: 22px !important; }
  .hero-sub { font-size: 14px !important; }

  /* mega-bar 数字进一步紧凑 */
  .mega-item .num { font-size: 16px !important; }
  .mega-item .label { font-size: 10px !important; }

  /* 工具卡片 */
  .tool-grid { gap: 8px !important; }
  .tool-card { padding: 14px 8px !important; }
  .tool-card .icon { font-size: 22px !important; }
  .tool-card h3 { font-size: 12px !important; }
  .tool-card p { display: none; }    /* 小屏隐藏描述，只留图标+标题 */

  /* chatbubble 再小一点 */
  #xiaomengeco-chat-bubble {
    width: 40px !important;
    height: 40px !important;
    bottom: 76px !important;
    right: 12px !important;
  }

  /* footer 进一步紧凑 */
  .footer-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-col h4 { font-size: 14px; }
  .footer-col ul li { font-size: 13px; }
}

/* ============================================================
 * 16. 小屏手机兜底（≤380px）
 * ============================================================ */
@media (max-width: 380px) {
  body { font-size: 13px; }
  .nav-logo span { font-size: 14px; }
  .hero h1 { font-size: 20px !important; }
  .tool-grid { grid-template-columns: 1fr 1fr !important; }
  .tool-card p { display: none; }
  .mobile-tabbar a { font-size: 10px; }
  .mobile-tabbar a .tab-icon { font-size: 18px; }
}

/* ============================================================
 * 17. 打印样式（附赠，不影响手机）
 * ============================================================ */
@media print {
  .mobile-tabbar,
  .nav-toggle,
  #xiaomengeco-chat-bubble,
  #xiaomengeco-chat-panel { display: none !important; }
}
