/* =========================================================
   Mobile App Shell Styles — LinkoraeFreight USA
   仅 ≤768px 生效，PC 端零影响
   包含：底部 Tab Bar、按钮点击反馈、下拉刷新、首屏精简
   账户中心 APP 化
   ========================================================= */

/* ------ iOS 安全区变量 ------ */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-height: 64px;
}

/* =========================================================
   Tap 反馈（全平台生效，轻量不破坏）
   ========================================================= */
.btn, button, a.btn, .mobile-tab, .acct-nav-item, .nav-link {
  -webkit-tap-highlight-color: transparent;
}
.tap-active {
  transform: scale(0.97);
  opacity: 0.88;
  transition: transform 0.08s ease, opacity 0.08s ease;
}

/* =========================================================
   统一加载动画
   ========================================================= */
.mobile-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(232,101,10,0.2);
  border-top-color: #E85F00;
  border-radius: 50%;
  animation: mobile-spin 0.8s linear infinite;
}
@keyframes mobile-spin { to { transform: rotate(360deg); } }

/* =========================================================
   下拉刷新
   ========================================================= */
.mobile-pull-hint {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #fff;
  color: #333;
  border-radius: 30px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.mobile-pull-hint.visible {
  opacity: 1;
}
.mobile-pull-hint.ready .mobile-pull-text::after {
  content: "Release to refresh";
  display: inline;
}
.mobile-pull-hint.ready .mobile-pull-text {
  font-size: 0;
}
.mobile-pull-hint.ready .mobile-pull-text::after {
  font-size: 13px;
}
.mobile-pull-hint.loading {
  opacity: 1;
  transform: translateX(-50%) translateY(80px) !important;
}

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

  /* ---------- 底部 Tab Bar ---------- */
  .mobile-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(10, 22, 40, 0.98);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 9990;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: rgba(255,255,255,0.62);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 6px 4px;
    transition: color 0.2s ease, transform 0.15s ease;
    min-height: 60px;
    position: relative;
  }

  .mobile-tab-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-tab-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    transition: transform 0.2s ease;
  }
  .mobile-tab-label {
    font-size: 10.5px;
    line-height: 1;
    margin-top: 1px;
  }

  .mobile-tab.is-active {
    color: #E85F00;
  }
  .mobile-tab.is-active .mobile-tab-icon svg {
    transform: scale(1.08);
  }
  .mobile-tab.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: #E85F00;
    border-radius: 0 0 3px 3px;
  }

  .mobile-tab.is-pressing {
    transform: scale(0.94);
  }

  /* body 留出 tab bar 空间 */
  body.has-mobile-tabbar {
    padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom));
  }

  /* WhatsApp 按钮上移避开 Tab Bar */
  body.has-mobile-tabbar .whatsapp-float {
    bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 14px) !important;
    right: 14px !important;
  }

  /* footer 不用再预留 80px（Tab Bar 已顶住） */
  body.has-mobile-tabbar footer {
    padding-bottom: 24px !important;
  }

  /* =========================================================
     首屏精简（Home）
     - 强制 Hero 高度 = 100vh
     - 隐藏非核心 hero 按钮（仅保留 2 个主 CTA）
     ========================================================= */
  .hero {
    min-height: calc(100vh - var(--tabbar-height) - var(--safe-bottom)) !important;
    padding: 90px 0 30px !important;
    display: flex !important;
    align-items: center !important;
  }

  .hero-content {
    width: 100%;
    max-width: 100%;
  }

  /* hero-actions 居中、85% 宽 */
  .hero-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    margin: 28px auto 24px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .hero-actions .btn {
    width: 85% !important;
    max-width: 380px !important;
    height: 50px !important;
    min-height: 50px !important;
    padding: 0 20px !important;
    justify-content: center;
    font-size: 15.5px !important;
    font-weight: 600;
    border-radius: 28px !important;
    letter-spacing: 0.01em;
  }
  /* 只保留第 1/2 个 CTA，其他隐藏（手机端专属转化简化）*/
  .hero-actions .btn:nth-child(n+3) {
    display: none !important;
  }
  /* hero 统计条简化：手机端隐藏，留出首屏转化焦点 */
  .hero-stats {
    display: none !important;
  }
  /* hero-badge 保留但缩小 */
  .hero-badge {
    font-size: 11.5px !important;
    padding: 5px 11px !important;
    margin-bottom: 14px !important;
  }

  /* =========================================================
     账户中心 APP 化（account.html）
     ========================================================= */
  body.has-mobile-tabbar .acct-shell {
    display: block !important;
    min-height: auto;
  }

  /* 侧栏改为：手机端直接隐藏（底部 Tab 替代）或保留为抽屉 */
  body.has-mobile-tabbar .acct-sidebar {
    position: fixed !important;
    left: -290px;
    top: 0; bottom: 0;
    width: 270px !important;
    height: 100vh;
    z-index: 9995;
    transition: left 0.28s ease;
    overflow-y: auto;
    background: #0A1628;
  }
  body.has-mobile-tabbar .acct-sidebar.open { left: 0; }

  /* 顶部 App Bar：logo + 退出按钮 */
  body.has-mobile-tabbar .acct-main {
    padding: 70px 16px 30px !important;
  }

  /* 悬浮汉堡菜单按钮保留（已在上轮加），做成顶部 App Bar 一部分 */
  .acct-mobile-menu-btn-floating {
    display: flex !important;
    width: 40px !important;
    height: 40px !important;
    background: #fff !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  /* 订单卡大卡片化 */
  .acct-order-card, .acct-bill-card, .acct-commission-card {
    padding: 18px 16px !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    margin-bottom: 14px !important;
    background: #fff;
  }
  .acct-order-card:active, .acct-bill-card:active {
    transform: scale(0.99);
    transition: transform 0.12s ease;
  }

  .acct-order-head, .acct-bill-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 6px !important;
  }
  .acct-order-number, .acct-bill-number {
    font-size: 16px !important;
    font-weight: 700;
  }
  .acct-order-status, .acct-bill-status, .acct-status-badge {
    align-self: flex-start;
  }
  .acct-order-meta, .acct-bill-meta {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
    font-size: 13px !important;
    color: #555;
    margin-top: 10px;
  }
  .acct-order-meta > div, .acct-bill-meta > div {
    padding: 6px 10px;
    background: #f6f7f9;
    border-radius: 8px;
  }

  /* 手机端账户 Tab 内切换按钮（订单/账单/物流/个人）做成滑动横条 */
  .acct-tabs {
    display: flex !important;
    overflow-x: auto;
    gap: 6px !important;
    padding: 8px 0 !important;
    margin: 0 -16px 16px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    scrollbar-width: none;
  }
  .acct-tabs::-webkit-scrollbar { display: none; }
  .acct-tabs button, .acct-tabs a {
    flex-shrink: 0;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-size: 13.5px !important;
    min-height: 36px !important;
    white-space: nowrap;
  }

  /* 表单 & 输入 */
  body.has-mobile-tabbar form input,
  body.has-mobile-tabbar form select,
  body.has-mobile-tabbar form textarea {
    font-size: 16px !important;
    border-radius: 10px !important;
  }

  /* 提交按钮固定风格 */
  body.has-mobile-tabbar .acct-submit-btn,
  body.has-mobile-tabbar form button[type="submit"] {
    width: 100%;
    height: 50px !important;
    border-radius: 28px !important;
    font-size: 15.5px !important;
    font-weight: 600;
  }

  /* 拍照/相册上传按钮视觉 */
  body.has-mobile-tabbar input[type="file"] {
    padding: 12px !important;
    border: 1.5px dashed rgba(232,101,10,0.4);
    border-radius: 12px;
    background: rgba(232,101,10,0.04);
    color: #E85F00;
  }

  /* =========================================================
     登录模态/页面 APP 化
     ========================================================= */
  .auth-dialog, .auth-modal-body {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100vw !important;
    width: 100% !important;
    margin: 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    top: auto !important;
    transform: none !important;
    max-height: 92vh !important;
    overflow-y: auto;
    padding: 28px 20px calc(24px + var(--safe-bottom)) !important;
    animation: mobileSheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes mobileSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .auth-dialog input, .auth-modal input {
    height: 48px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
  }
  .auth-dialog button[type="submit"], .auth-modal button[type="submit"] {
    height: 50px !important;
    border-radius: 28px !important;
    font-size: 15.5px !important;
    font-weight: 600;
  }

  /* =========================================================
     导航栏（顶部）APP 化
     ========================================================= */
  .site-nav, .nav {
    padding-top: var(--safe-top) !important;
  }

  /* =========================================================
     平滑滚动
     ========================================================= */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* 防止键盘遮挡：focus 时自动滚到视口内 */
  input:focus, textarea:focus, select:focus {
    scroll-margin-bottom: calc(var(--tabbar-height) + 80px);
  }
}

/* =========================================================
   ≤ 480px 小屏
   ========================================================= */
@media (max-width: 480px) {
  :root { --tabbar-height: 60px; }
  .mobile-tab { min-height: 56px; padding: 5px 3px; }
  .mobile-tab-icon svg { width: 22px; height: 22px; }
  .mobile-tab-label { font-size: 10px; }

  .hero-actions .btn {
    width: 88% !important;
    height: 48px !important;
    font-size: 15px !important;
  }
}

/* =========================================================
   PWA standalone 模式细节（从桌面启动 App 时）
   ========================================================= */
@media (display-mode: standalone) {
  /* 补齐 iOS 状态栏空间 */
  body { padding-top: var(--safe-top); }
  /* 隐藏浏览器相关 "Install" 提示区块 */
  .install-prompt { display: none !important; }
}