/* =============================================
   HIIB 华羿数联 - 全面响应式样式 v3.0
   加载顺序：最后加载，利用级联优势无需 !important
   ============================================= */

/* === 全局基础重置 === */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ================================================
   断点1：平板端 ≤1024px
   ================================================ */
@media screen and (max-width: 1024px) {
  .container,
  .header-inner,
  .hero-inner {
    padding-left: 24px;
    padding-right: 24px;
    max-width: 100%;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: 40px;
    text-align: center;
  }

  .hero-visual { 
    order: -1; 
    margin: 0 auto;
    max-width: 280px;
  }

  .hero-stats {
    justify-content: center;
    flex-wrap: wrap;
    gap: 30px;
  }

  .hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
  .hero-subtitle { font-size: clamp(1.1rem, 2.5vw, 1.4rem); }
  .hero-desc { font-size: clamp(0.9rem, 2vw, 1.05rem); }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .section { padding: 64px 0; }
  .hero { padding: 100px 0 60px; }
}

/* ================================================
   断点2：手机端 ≤768px
   ================================================ */
@media screen and (max-width: 768px) {
  /* --- 容器 --- */
  .container,
  .header-inner,
  .hero-inner {
    padding-left: 16px;
    padding-right: 16px;
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    float: none;
  }

  /* --- 导航菜单 --- */
  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
  }

  .nav { display: none; }
  .phone { display: none; }

  .menu-btn {
    display: flex;
    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 {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    z-index: 10000;
    overflow-x: visible;
    overflow-y: auto;
    transition: right 0.3s ease;
    background: var(--light, #fff);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  }
  .mobile-nav.show { right: 0; }

  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
  .mobile-nav-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    background: none;
    border: none;
    color: var(--text, #1e293b);
  }

  .mobile-nav-links { padding: 8px 0; }
  .mobile-nav-links a,
  .mobile-nav-links .mobile-nav-sub {
    padding: 16px 24px;
    font-size: 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    color: var(--text, #1e293b);
    text-decoration: none;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
  .mobile-nav-links .mobile-nav-sub {
    padding: 12px 24px 12px 36px;
    font-size: 0.92rem;
    color: var(--text-light, #64748b);
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    display: none;
  }
  .mobile-overlay.show { display: block; }

  /* --- Hero 区域 --- */
  .hero {
    padding: 80px 0 50px;
    text-align: center;
    min-height: auto;
  }
  .hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .hero h1 {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    line-height: 1.3;
    margin-bottom: 16px;
  }
  .hero-subtitle {
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    margin-bottom: 16px;
  }
  .hero-desc, .hero p {
    font-size: clamp(0.9rem, 3vw, 1rem);
    line-height: 1.7;
    margin-bottom: 24px;
  }
  .hero-btns, .hero .btn-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    width: 100%;
  }
  .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;
    padding-top: 24px;
    margin-top: 24px;
  }
  .hero-visual { display: none; }

  /* --- 网格布局 → 单列 --- */
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .row, .cols {
    display: flex;
    flex-wrap: wrap;
  }
  [class*="col-"], [class*="span"] {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    float: none;
    padding-left: 0;
    padding-right: 0;
  }

  /* --- 卡片 --- */
  .card, .service-card, .product-card,
  .case-card, .partner-card, .news-card,
  .credential-card, .feature-card {
    width: 100%;
    margin-bottom: 16px;
  }
  .card-grid, .cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }

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

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

  /* --- 按钮 --- */
  .btn, button:not(.mobile-nav-close):not(#kiki-back-top),
  [type="submit"], a.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .btn-block {
    width: 100%;
    display: block;
  }

  /* --- 双列布局 → 单列 --- */
  .contact-grid, .detail-grid, .about-preview-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .flex-row, .d-flex:not(.flex-column):not(.mobile-nav-header) {
    flex-wrap: wrap;
  }
  .flex-row > *, .d-flex > * { min-width: 0; }

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

  /* --- 表单 --- */
  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; }

  /* --- CTA 区域 --- */
  .cta-section {
    padding: 50px 16px;
    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;
  }

  /* --- 侧边栏 --- */
  .sidebar, .aside, aside {
    width: 100%;
    float: none;
    margin: 0 0 20px 0;
  }

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

  /* --- Logo --- */
  .logo { 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
  }
  .logo-text { 
    display: flex; 
    flex-direction: column; 
  }
  .logo-en { 
    display: block; 
    white-space: nowrap; 
  }

  /* --- 显示/隐藏 --- */
  .hide-mobile { display: none; }
  .show-mobile { display: block; }

  /* --- 返回顶部按钮 --- */
  #kiki-back-top {
    bottom: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  /* --- 备案栏 --- */
  #kiki-beian-bar {
    font-size: 11px;
    padding: 10px 12px;
    line-height: 2;
  }

  /* --- 装饰元素 --- */
  [class*="decor"], [class*="ornament"], [class*="deco-"] { display: none; }
}

/* ================================================
   断点3：小屏手机 ≤480px
   ================================================ */
@media screen and (max-width: 480px) {
  body { overflow-x: hidden; }

  .container,
  .header-inner,
  .hero-inner {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero { padding: 70px 0 40px; }
  .hero h1 { font-size: clamp(1.3rem, 7vw, 1.8rem); }
  .hero-subtitle { font-size: clamp(0.95rem, 4vw, 1.1rem); }

  .footer-grid { grid-template-columns: 1fr; }

  .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; }

  h1 { font-size: clamp(1.25rem, 7vw, 1.6rem); }
  h2 { font-size: clamp(1.1rem, 5.5vw, 1.4rem); }
  h3 { font-size: clamp(1rem, 5vw, 1.2rem); }
}

/* ================================================
   断点4：大屏 ≥1400px
   ================================================ */
@media screen and (min-width: 1400px) {
  .container { max-width: 1320px; }
}
