﻿/* 4S淘车网 - 移动端适配 v5.4
   目标：手机浏览器（iOS Safari / 安卓 Chrome / 微信内置浏览器）单手可用。
   加载顺序：common.css -> pages.css -> used-cars.css -> mobile.css（最后覆盖）。
   兼容：IE8 及更老浏览器不识别 media query，自动保持原桌面布局，不受影响。 */

/* ============ 基础 ============ */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  html, body { max-width: 100%; overflow-x: hidden; }
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
  .container { padding: 0 12px; }
  img { max-width: 100%; height: auto; }
  a, button { -webkit-tap-highlight-color: rgba(0,0,0,0); }
  button { touch-action: manipulation; }
  input, select, textarea { font-size: 16px; } /* 防止 iOS 聚焦自动放大 */
  .field input, .field select, .field textarea,
  .hero-search input, .header-search input,
  .brand-search-wrap input, .brand-filter-line input { font-size: 16px; }

  /* 顶部栏：手机端隐藏（信息已并入菜单/底部导航） */
  .topbar { display: none !important; }

  /* 主导航：汉堡按钮放大到易点尺寸 */
  .header-inner { height: 56px; gap: 8px; }
  .logo { flex: 1; min-width: 0; }
  .logo-mark { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; flex: none; }
  .logo-text { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .logo-sub { display: none; }
  .nav-toggle { display: block !important; flex: none; order: 9; margin-left: auto; padding: 12px 8px; }
  .nav-toggle span { width: 24px; height: 2px; margin: 5px 0; }
  .header-search, #headerLogin, .nav-spacer { display: none !important; }
  .site-header { position: sticky; top: 0; z-index: 120; }
  .main-nav {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    background: #fff; flex-direction: column; align-items: stretch; height: auto;
    max-height: calc(100vh - 110px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    box-shadow: 0 8px 20px rgba(0,0,0,.12); border-bottom: 1px solid var(--line); z-index: 130;
  }
  .main-nav.open { display: flex !important; }
  .main-nav a { height: 50px; line-height: 50px; padding: 0 22px; font-size: 16px; border-bottom: 1px solid #f2f3f5; }
  .main-nav a.active { color: var(--price); background: #fffcf0; }
  .main-nav a.active::after { display: none; }

  /* 频道栏：横向滑动，隐藏滚动条 */
  .channel-bar { position: relative; }
  .channel-inner { height: 44px; gap: 2px; -webkit-overflow-scrolling: touch; overflow-x: auto; }
  .channel-item { padding: 0 12px; font-size: 13px; height: 44px; }
  .channel-item.active { font-weight: 700; }

  /* 通用区块 */
  .section { margin: 22px 0; }
  .section-head { margin-bottom: 12px; }
  .section-title { font-size: 18px; }
  .section-more { font-size: 12px; white-space: nowrap; }
  .card-hover:hover { transform: none; }
  .empty { padding: 42px 16px; }

  /* 首页焦点区 */
  .hero-section { margin-top: 12px; }
  .hero-banner, .hero-banner.has-image { min-height: 250px; border-radius: 10px; }
  .hero-banner { padding: 24px 18px; }
  .hero-banner.has-image .hero-content {
    padding: 26px 18px !important; max-width: 100% !important; border-radius: 10px;
    background: linear-gradient(90deg, rgba(16,19,23,.94) 0%, rgba(16,19,23,.78) 100%) !important;
  }
  .hero-content { max-width: 100%; }
  .hero-tag { font-size: 11px; padding: 3px 9px; margin-bottom: 10px; }
  .hero-content h1 { font-size: 25px !important; line-height: 1.35; }
  .hero-content p { font-size: 13px; margin: 10px 0 16px; }
  .hero-search { max-width: 100%; padding: 4px 4px 4px 12px; }
  .hero-search .btn { padding: 9px 14px; font-size: 13px; white-space: nowrap; }
  .hero-hot { flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
  .hero-art, .art-car, .art-circle, .art-badge { display: none !important; }
  .slogan-bar { margin-top: 12px; }

  /* 卡片网格：手机端两列为主 */
  .banner-grid, .news-grid, .vehicle-grid, .cars-grid, .dealer-grid,
  .promo-grid, .promos-grid, .tool-grid, .stores-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .banner-card { height: 130px; border-radius: 10px; }
  .banner-caption { padding: 20px 10px 9px; }
  .banner-caption b { font-size: 13px; }
  .banner-caption i { font-size: 11px; }
  .news-card .news-thumb { height: 110px; }
  .news-card-body { padding: 10px; }
  .news-card-body h4 { font-size: 13px; line-height: 1.45; height: 38px; overflow: hidden; }
  .news-card-body p { display: none; }
  .news-card-meta { font-size: 11px; margin-top: 6px; }
  .vc-img { height: 110px; }
  .vc-body { padding: 10px; }
  .vc-name { font-size: 13px; }
  .vc-meta { font-size: 11px; margin: 3px 0 6px; }
  .vc-price { font-size: 12px; }
  .vc-price b { font-size: 16px; }
  .dealer-card, .promo-card { padding: 12px; }
  .dc-name, .pc-title { font-size: 13px; }
  .dc-addr { font-size: 11px; min-height: 0; }
  .tool-card { padding: 14px 8px; }
  .tool-emoji { font-size: 24px; }
  .tool-card h4 { font-size: 13px; }
  .tool-card p { font-size: 11px; line-height: 1.4; }

  /* 品牌卡片 */
  .brand-summary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bs-item { padding: 10px; }
  .bs-item b { font-size: 18px; }
  .brand-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .brand-card { padding: 10px; gap: 8px; }
  .bc-logo { width: 40px; height: 40px; font-size: 17px; }
  .bc-title { font-size: 13px; }
  .bc-en, .bc-meta { font-size: 10px; }
  .bc-actions a { font-size: 10px; padding: 3px 5px; }
  .brand-search-wrap { min-width: 0; width: 100%; }
  .brand-search-wrap input { min-width: 0; }
  .brand-filter-line input { min-width: 0; flex: 1; }

  /* 列表页筛选 */
  .page-head { padding: 16px; margin: 12px 0; }
  .page-head h1 { font-size: 20px; }
  .page-head p { font-size: 12px; }
  .filter-panel { padding: 12px; margin-bottom: 12px; }
  .filter-row { padding: 8px 0; gap: 6px; }
  .filter-label { width: 100%; font-size: 12px; color: var(--ink-2); font-weight: 600; }
  .filter-options { gap: 6px; }
  .filter-opt { padding: 6px 10px; font-size: 12px; }
  .cascader { gap: 6px; }
  .cascader select { flex: 1; min-width: 30%; padding: 8px 6px; font-size: 13px; }
  .toolbar { padding: 10px 12px; gap: 8px; }
  .sort-btn { padding: 6px 8px; font-size: 12px; }
  .result-total { font-size: 12px; }
  .pagination { margin: 20px 0; gap: 4px; }
  .pagination button { padding: 8px 10px; font-size: 12px; }

  /* 门店卡片：地址较长，手机端单列 */
  .stores-grid { grid-template-columns: 1fr; }
  .store-card { padding: 14px; }
  .sc-info { font-size: 12px; }
  .sc-actions .btn { padding: 10px 8px; font-size: 13px; }

  /* 资讯列表 / 详情 */
  .news-layout { grid-template-columns: 1fr; gap: 14px; }
  .news-item { padding: 10px; gap: 10px; }
  .news-thumb { width: 96px; height: 72px; }
  .news-body h3 { font-size: 14px; }
  .news-body p { font-size: 12px; }
  .news-aside, .detail-side, .ucd-side { position: static !important; }
  .aside-card { padding: 14px; }
  .article-content, .page-content { font-size: 14px; line-height: 1.85; word-wrap: break-word; }
  .article-cover img { border-radius: 8px; }

  /* 详情页：主图瘦身、参数两列、侧栏置底 */
  .detail-layout { grid-template-columns: 1fr; gap: 14px; margin: 12px 0; }
  .detail-main { padding: 14px; }
  .detail-hero { height: 190px; }
  .detail-hero .dh-car { width: 230px; height: 65px; }
  .detail-main h1 { font-size: 21px; }
  .detail-specs { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .spec-item { padding: 10px; }
  .detail-line .l { width: 80px; }
  .side-panel { padding: 14px; }

  /* 二手车（仿瓜子）：手机单列，详情页图高收敛 */
  .uc-hero { padding: 22px 18px; border-radius: 10px; margin: 12px 0; }
  .uc-hero h1 { font-size: 23px; }
  .uc-hero p { font-size: 13px; }
  .uc-grid { margin: 0 -6px; }
  .uc-card { width: 100%; padding: 0 6px; margin-bottom: 12px; }
  .uc-card .uc-img { height: 190px; border-radius: 10px 10px 0 0; }
  .uc-body { padding: 12px; }
  .uc-title { font-size: 16px; }
  .uc-model { height: auto; }
  .ucd-layout { flex-direction: column; gap: 14px; }
  .ucd-side { width: 100%; }
  .ucd-gallery { height: 250px; border-radius: 10px; }
  .ucd-title { font-size: 19px; }
  .ucd-section { padding: 12px; }
  .ucd-price b { font-size: 28px; }
  .ucd-promise span { display: block; margin: 4px 0; }
  .uc-home-head { margin-bottom: 10px; }
  .uc-home-intro { font-size: 12px; }

  /* 登录 / 弹层 */
  .auth-wrap { min-height: calc(100vh - 200px); padding: 24px 12px; }
  .auth-body { padding: 20px; }
  .modal { width: 94vw; max-height: 86vh; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 0 16px 16px; }
  .toast { bottom: 76px; width: max-content; max-width: 88vw; text-align: center; }
  /* v5.7.1 页脚横幅：手机上通栏满宽、上下留白收敛，黑色页脚保持原样 */
  .footer-banner-wrap { margin-top: 28px; padding-bottom: 18px; }
  .footer-banner { border-radius: 8px; }
  .footer-banner-wrap + .site-footer { margin-top: 0; }
  .site-footer { padding: 30px 0 12px; margin-top: 32px; }
  .footer-top { grid-template-columns: 1fr; gap: 22px; }
  .footer-links { grid-template-columns: 1fr 1fr; gap: 16px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* 表格：允许横向滚动，避免撑破页面 */
  .page-content table, .article-content table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 更窄屏幕（iPhone SE 等）：进一步收敛 */
@media (max-width: 400px) {
  .hero-content h1 { font-size: 22px !important; }
  .hero-hot button { font-size: 11px; }
  .banner-grid, .news-grid, .vehicle-grid, .cars-grid,
  .promo-grid, .promos-grid { grid-template-columns: 1fr; }
  .banner-card { height: 150px; }
  .news-card .news-thumb { height: 140px; }
  .news-card-body p { display: block; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .brand-grid { grid-template-columns: 1fr; }
  .cascader select { min-width: 45%; }
  .section-title { font-size: 17px; }
  .footer-logo-text { font-size: 20px; }
  .footer-quick a { padding: 4px 8px; }
}

/* ============ 底部固定导航（由 common.js 注入） ============ */
.mobile-tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  height: calc(58px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff; border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.mobile-tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; min-width: 0; height: 58px; color: #7b818a; font-size: 11px; text-decoration: none;
}
.mobile-tabbar a .tb-ico { font-size: 21px; line-height: 1; margin-bottom: 3px; }
.mobile-tabbar a.active { color: var(--price, #ff5000); font-weight: 700; }
.mobile-tabbar a.active .tb-ico { transform: translateY(-1px); }
@media (max-width: 768px) { .mobile-tabbar { display: flex; } }

/* 横屏矮屏：底部导航不遮挡内容 */
@media (max-height: 480px) and (orientation: landscape) {
  .mobile-tabbar { height: calc(46px + env(safe-area-inset-bottom, 0px)); }
  .mobile-tabbar a { height: 46px; }
  body { padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }
}
