/* ============================================================
   MOBILE ADAPTATION OVERRIDE — linkorae.com
   ============================================================
   作用范围：仅 max-width: 768px（手机端）生效
   设计原则：
   1. 不覆盖/不影响 PC 端任何样式（全部包在 @media 里）
   2. 不改业务逻辑、不改 DOM、不改品牌色
   3. 解决溢出、字号、按钮点击区、WhatsApp 遮挡、表格、表单等
   ============================================================ */

/* ---------- 基础：防止横向滚动（全局生效，但只处理溢出）---------- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
*, *::before, *::after { box-sizing: border-box; }
img, video, iframe { max-width: 100%; height: auto; }

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

  /* ---------- 1. 容器与安全边距 ---------- */
  .container,
  .container-wide {
    padding-left: 16px !important;
    padding-right: 16px !important;
    max-width: 100% !important;
  }

  .section { padding: 48px 0 !important; }

  /* 禁止任何子元素造成横向溢出 */
  body, main, section, header, footer, nav, div {
    max-width: 100vw;
  }

  /* 换行保护：任何长单词/URL */
  p, span, li, td, th, a, h1, h2, h3, h4, h5, h6, label, button {
    word-break: break-word;
    overflow-wrap: break-word;
  }

  /* ---------- 2. 图片 ---------- */
  img { width: 100%; height: auto; display: block; }
  .hero-bg, .hero-grid-overlay { width: 100%; }

  /* ---------- 3. 排版 ---------- */
  body { font-size: 15px; line-height: 1.6; }

  h1, .hero-title {
    font-size: clamp(1.75rem, 8vw, 2.35rem) !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em;
    word-break: keep-all;
  }
  h2 { font-size: clamp(1.4rem, 6vw, 1.85rem) !important; line-height: 1.25 !important; }
  h3 { font-size: clamp(1.15rem, 5vw, 1.4rem) !important; line-height: 1.3 !important; }
  h4 { font-size: 1.05rem !important; line-height: 1.35 !important; }

  p, li, td, .hero-subtitle, .section-subtitle {
    font-size: 15px !important;
    line-height: 1.6 !important;
  }
  .hero-subtitle { margin-bottom: 28px !important; }
  small, .text-small, .badge { font-size: 13px !important; }

  /* ---------- 4. Hero 区块 ---------- */
  .hero { min-height: auto !important; padding: 90px 0 48px !important; }
  .hero-content { padding: 0 4px; }
  .hero-actions {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 36px;
    width: 100%;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .hero-stats {
    flex-direction: column !important;
    gap: 16px !important;
    padding-top: 28px !important;
  }
  .hero-stat {
    width: 100%;
    border-right: none !important;
    padding-right: 0 !important;
    margin-right: 0 !important;
    text-align: left;
  }
  .hero-badge { font-size: 12px !important; padding: 6px 12px !important; }

  /* ---------- 5. 按钮（44x44 点击区）---------- */
  .btn,
  button:not(.nav-toggle):not(.mobile-close):not(.acct-mobile-menu-btn):not([type="checkbox"]):not([type="radio"]),
  a.btn, input[type="submit"], input[type="button"] {
    min-height: 44px !important;
    min-width: 44px;
    padding: 12px 20px !important;
    font-size: 15px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
  }
  .btn-sm { padding: 10px 16px !important; font-size: 14px !important; }
  .btn-lg { padding: 14px 24px !important; font-size: 16px !important; }

  /* 主 CTA 宽度 */
  .btn-primary.btn-hero,
  .hero-actions .btn,
  .cta-section .btn,
  .quote-section .btn {
    width: 100%;
    max-width: 100%;
  }

  /* ---------- 6. 导航栏 ---------- */
  .nav-toggle {
    display: flex !important;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    gap: 5px;
  }

  .nav-inner, .nav-container {
    padding: 0 16px !important;
  }

  .nav-logo img, .logo img { max-height: 36px !important; }

  /* 汉堡展开后的菜单（已有逻辑，优化样式） */
  .nav-mobile-open .nav-links {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: var(--nav-height, 64px) !important;
    left: 0; right: 0;
    background: var(--navy, #0A1628) !important;
    padding: 16px 0 28px !important;
    gap: 4px !important;
    max-height: calc(100vh - var(--nav-height, 64px));
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 998;
  }
  .nav-mobile-open .nav-link {
    padding: 14px 24px !important;
    font-size: 16px !important;
    min-height: 48px;
    display: flex;
    align-items: center;
    border-radius: 0 !important;
    color: rgba(255,255,255,0.9) !important;
  }
  .nav-mobile-open .nav-link:active,
  .nav-mobile-open .nav-link:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #fff !important;
  }
  .nav-mobile-open .nav-cta {
    display: block !important;
    padding: 14px 24px 0 !important;
    width: 100%;
  }
  .nav-mobile-open .nav-cta .btn { width: 100%; }

  /* ---------- 7. WhatsApp 悬浮按钮 ---------- */
  .whatsapp-float {
    bottom: 16px !important;
    right: 16px !important;
    width: 52px !important;
    height: 52px !important;
    box-shadow: 0 4px 14px rgba(37,211,102,0.45) !important;
  }
  .whatsapp-float svg { width: 26px !important; height: 26px !important; }
  /* 首页底部 CTA 不被 WhatsApp 按钮遮挡 */
  body { padding-bottom: 0; }
  footer { padding-bottom: 80px !important; }

  /* ---------- 8. Grid 统一降为单列 ---------- */
  .grid-2, .grid-3, .grid-4,
  .service-cards, .cargo-types, .steps-grid,
  .cases-grid, .services-grid, .feature-detail-grid,
  .advantage-grid, .transit-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    text-align: left;
  }
  .footer-bottom {
    flex-direction: column !important;
    gap: 12px;
    text-align: center;
  }

  /* advantage-item 边框整理 */
  .advantage-item {
    border-right: none !important;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.1));
    padding: 20px 16px !important;
  }
  .advantage-item:last-child { border-bottom: none !important; }

  /* ---------- 9. 表单/输入框 ---------- */
  input, select, textarea {
    font-size: 16px !important;        /* 防止 iOS Safari 自动缩放 */
    min-height: 44px;
    padding: 10px 12px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  textarea { min-height: 100px; }
  .form-row, .quote-form .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .quote-form, .contact-form, form {
    padding: 20px 16px !important;
  }
  label { font-size: 14px !important; }

  /* 让表单 focus 后滚动不被导航遮挡 */
  input:focus, select:focus, textarea:focus {
    scroll-margin-top: 80px;
  }

  /* ---------- 10. 卡片、阴影、圆角 ---------- */
  .card, .service-card, .case-card, .feature-card {
    padding: 20px 16px !important;
    border-radius: 10px !important;
  }

  /* ---------- 11. 高亮条 / Pills ---------- */
  .highlight-strip {
    padding: 12px 16px !important;
  }
  .highlight-strip .container {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .highlight-strip .sep { display: none !important; }
  .highlight-strip span { font-size: 13px !important; }

  /* ---------- 12. 表格（所有通用表格响应式）---------- */
  table {
    display: block;
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px !important;
  }
  th, td { padding: 8px 10px !important; white-space: nowrap; }

  /* ---------- 13. FAQ / 折叠 ---------- */
  .faq-item, details {
    padding: 14px 16px !important;
  }
  .faq-question, summary {
    font-size: 15px !important;
    line-height: 1.4 !important;
  }

  /* ---------- 14. 页脚 ---------- */
  footer .container { padding: 32px 16px !important; }

  /* ---------- 15. 账户中心（account.html）---------- */
  .acct-shell { display: block !important; }
  .acct-sidebar {
    position: fixed !important;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px !important;
    height: 100vh;
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  .acct-sidebar.open { left: 0; }
  .acct-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 998;
    display: none;
  }
  .acct-sidebar.open + .acct-sidebar-overlay { display: block; }

  .acct-main {
    padding: 70px 16px 40px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .acct-mobile-menu-btn-floating {
    display: flex !important;
  }

  /* 订单卡 & 账单卡 */
  .acct-order-card, .acct-bill-card {
    padding: 16px !important;
    border-radius: 10px !important;
  }
  .acct-order-head, .acct-bill-head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }
  .acct-order-meta, .acct-bill-meta {
    flex-wrap: wrap;
    gap: 8px !important;
    font-size: 13px !important;
  }

  /* 订单提交表单的产品行 */
  .acct-product-row, .acct-form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Tab/按钮组 */
  .acct-tabs, .acct-filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ---------- 16. 后台（admin.html）---------- */
  .admin-shell { display: block !important; }
  .admin-sidebar {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px !important;
    gap: 6px;
    white-space: nowrap;
  }
  .admin-nav {
    flex-direction: row !important;
    flex-wrap: nowrap;
    gap: 6px !important;
    overflow-x: auto;
  }
  .admin-nav-item {
    min-width: max-content;
    padding: 10px 14px !important;
    font-size: 13px !important;
    min-height: 40px;
  }
  .admin-main {
    padding: 16px !important;
    width: 100% !important;
  }
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .admin-toolbar input,
  .admin-toolbar select {
    width: 100% !important;
  }
  .admin-table-wrap { overflow-x: auto; }
  .admin-modal-body {
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 80px) !important;
    overflow-y: auto;
  }
  .admin-form-grid {
    grid-template-columns: 1fr !important;
  }
  .admin-pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  .admin-pager button { min-height: 36px; min-width: 36px; }

  /* ---------- 17. 登录/注册模态框 ---------- */
  .auth-modal-body, .auth-dialog {
    max-width: calc(100vw - 24px) !important;
    margin: 20px 12px !important;
    padding: 24px 20px !important;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }
  .auth-tabs { font-size: 14px; }

  /* ---------- 18. 溢出/滚动流畅度 ---------- */
  body { -webkit-overflow-scrolling: touch; }
  .scroll-x, [data-scroll-x] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---------- 19. 去除部分硬编码宽度 ---------- */
  [style*="width:100"], [style*="width: 100"] { /* 保留 */ }
  [style*="min-width:"]:not([style*="min-width:0"]) {
    max-width: 100%;
  }
  [style*="max-width:"] { max-width: 100% !important; }

  /* ---------- 20. 流程页 process.html 内联栅格兜底 ---------- */
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  div[style*="position:sticky"], div[style*="position: sticky"] {
    position: relative !important;
    top: auto !important;
  }
}

/* =============================================================
   ≤ 480px 极窄屏（小手机）额外收紧
   ============================================================= */
@media (max-width: 480px) {
  .container, .container-wide {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  h1, .hero-title { font-size: 1.75rem !important; }
  h2 { font-size: 1.35rem !important; }
  h3 { font-size: 1.1rem !important; }

  .hero { padding: 80px 0 40px !important; }
  .hero-subtitle { font-size: 14.5px !important; }

  .btn { padding: 11px 16px !important; font-size: 14.5px !important; }

  .whatsapp-float {
    bottom: 14px !important;
    right: 14px !important;
    width: 48px !important;
    height: 48px !important;
  }
  .whatsapp-float svg { width: 24px !important; height: 24px !important; }

  /* 卡片/章节紧凑 */
  .section { padding: 40px 0 !important; }
  .card, .service-card, .case-card, .feature-card {
    padding: 16px 14px !important;
  }

  /* 账户/后台 */
  .acct-main { padding: 66px 14px 32px !important; }
  .admin-main { padding: 14px !important; }
  .admin-nav-item { padding: 9px 12px !important; font-size: 12.5px !important; }

  table { font-size: 12.5px !important; }
  th, td { padding: 6px 8px !important; }
}

/* =============================================================
   ≤ 360px 超小屏兜底
   ============================================================= */
@media (max-width: 360px) {
  h1, .hero-title { font-size: 1.55rem !important; }
  .btn { font-size: 14px !important; padding: 10px 14px !important; }
  .nav-logo img, .logo img { max-height: 32px !important; }
}

/* =============================================================
   高分屏/Retina 图片清晰
   ============================================================= */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img { image-rendering: -webkit-optimize-contrast; }
}

/* =============================================================
   横屏手机兜底
   ============================================================= */
@media (max-width: 900px) and (orientation: landscape) {
  .hero { min-height: auto !important; padding: 80px 0 40px !important; }
}

/* =============================================================
   减少动画（系统偏好）
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* =============================================================
   QUOTE FORM — 额外响应式微调（contact.html）
   ============================================================= */
@media (max-width: 768px) {
  #quoteForm .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  #quoteForm .form-group { margin-bottom: 0 !important; }
  #quoteForm label {
    font-size: 13.5px !important;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    display: block;
  }
  #quoteForm input,
  #quoteForm select,
  #quoteForm textarea {
    width: 100% !important;
    min-height: 46px !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    box-sizing: border-box;
  }
  #quoteForm textarea {
    min-height: 110px !important;
    resize: vertical;
  }
  #quoteForm .form-submit {
    margin-top: 20px !important;
  }
  #quoteForm .form-submit .btn {
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    border-radius: 28px !important;
    font-size: 15.5px !important;
    font-weight: 600;
    letter-spacing: 0.01em;
  }
  #quoteForm .form-note,
  #quoteForm .form-privacy-note {
    font-size: 12px !important;
    line-height: 1.5 !important;
  }

  /* Loading spinner on submit */
  #quoteForm button[disabled] .spin-icon {
    animation: qf-spin 0.8s linear infinite;
  }
}
@keyframes qf-spin { to { transform: rotate(360deg); } }
