/* =============================================
   移动端响应式完整修复 - www.hiib.cn
   版本：2.0 | 移动优先设计
   修复：排版错乱、文字过小、按钮难点击、图片拉伸、横向滚动
   ============================================= */

/* ===== 全局基础：防止横向滚动 ===== */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
*, *::before, *::after {
  box-sizing: border-box;
}

/* ===== 图片自适应：禁止拉伸 ===== */
img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== 按钮基础规范（全端生效）===== */
.btn, button:not(.mobile-nav-close):not(#kiki-back-top),
[type="button"]:not(.mobile-nav-close),
[type="submit"],
[type="reset"],
a.btn {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* ===== 平板端 (≤1024px) ===== */
@media (max-width: 1024px) {
  .container {
    padding: 0 24px;
    width: 100%;
  }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
}

/* ===== 手机端 (≤768px) ===== */
@media (max-width: 768px) {

  /* --- 容器 --- */
  .container {
    padding: 0 16px;
    width: 100%;
  }

  /* --- 导航：确保汉堡菜单按钮可见、尺寸合规 --- */
  .menu-btn {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 10001;
    flex-shrink: 0;
  }
  .menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--dark, #1a1a2e);
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  /* --- 移动端抽屉菜单链接间距 --- */
  .mobile-nav-links a {
    padding: 16px 24px;
    font-size: 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .mobile-nav-links .mobile-nav-sub {
    min-height: 44px;
    padding: 12px 24px 12px 36px;
    font-size: 0.92rem;
  }
  .mobile-nav-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- Hero 区域 --- */
  .hero {
    padding: 80px 0 50px;
    text-align: center;
    min-height: auto;
  }
  .hero h1 {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    line-height: 1.3;
    margin-bottom: 16px;
  }
  .hero-desc, .hero p {
    font-size: clamp(0.9rem, 3.5vw, 1.05rem);
    line-height: 1.7;
  }
  .hero-btns, .hero .btn-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
  }
  .hero-btns .btn, .hero .btn-group .btn {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
  .hero-stats {
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
  }
  .hero-visual { display: none; }

  /* --- 按钮：尺寸 ≥ 44×44px，间距 ≥ 8px --- */
  .btn, button:not(.mobile-nav-close):not(#kiki-back-top),
  [type="button"]:not(.mobile-nav-close),
  [type="submit"] {
    min-height: 44px;
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  /* 按钮组间距 */
  .btn + .btn,
  button + button,
  .btn-group > * + * {
    margin-left: 8px;
  }
  .btn-group.flex-col > * + * {
    margin-left: 0;
    margin-top: 8px;
  }

  /* --- 网格布局：单列 --- */
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  [class*="col-"] {
    width: 100% !important;
    float: none !important;
  }

  /* --- 卡片 --- */
  .card, .service-card, .product-card,
  .case-card, .partner-card, .news-card,
  .credential-card {
    width: 100%;
    margin-bottom: 16px;
  }

  /* --- 字体层级 --- */
  h1 { font-size: clamp(1.5rem, 6vw, 2rem); }
  h2, .section-title { font-size: clamp(1.3rem, 5vw, 1.7rem) !important; }
  h3 { font-size: clamp(1.1rem, 4vw, 1.4rem); }
  p, li, .section-subtitle {
    font-size: clamp(0.875rem, 3.5vw, 1rem);
    line-height: 1.7;
  }

  /* --- Section 间距 --- */
  .section, section { padding: 50px 0 !important; }
  .section-title { margin-bottom: 24px; }

  /* --- 图片自适应 --- */
  .img-fluid, .banner-img, .about-img,
  .case-img img, .product-img img,
  .partner-logo img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }

  /* --- Flex 布局修复 --- */
  .flex-row, .d-flex:not(.flex-column):not(.mobile-nav-header) {
    flex-wrap: wrap;
  }
  .flex-row > *, .d-flex > * { min-width: 0; }

  /* --- 表格横向滚动 --- */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* --- 表单 --- */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="search"],
  select, textarea {
    width: 100%;
    font-size: 16px; /* 防止 iOS 自动缩放 */
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 6px;
  }
  textarea { min-height: 120px; }

  /* --- 联系/详情双列 → 单列 --- */
  .contact-grid, .detail-grid, .about-preview-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* --- CTA 区域 --- */
  .cta-section {
    padding: 50px 16px !important;
    text-align: center;
  }
  .cta-section h2 { font-size: clamp(1.3rem, 5vw, 1.8rem); }
  .cta-section .btn-group {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  /* --- Footer --- */
  .footer-grid {
    grid-template-columns: 1fr !important;
    text-align: center;
    gap: 24px !important;
  }
  .footer-brand, .footer-social { justify-content: center; }
  .footer-links { padding-left: 0; }
  .footer { padding: 40px 0; }

  /* --- 显示/隐藏辅助类 --- */
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
}

/* ===== 小屏手机 (≤480px) ===== */
@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .hero { padding: 70px 0 40px; }
  .hero h1 { font-size: clamp(1.3rem, 7vw, 1.8rem); }
  .footer-grid {
    grid-template-columns: 1fr !important;
  }
  .btn {
    padding: 12px 20px;
    font-size: 14px;
    width: 100%;
    max-width: 320px;
  }
  /* 统计数字紧凑排列 */
  .hero-stats { gap: 16px; }
  .stat-num { font-size: 1.8rem; }
  .stat-label { font-size: 0.85rem; }
}
