/* ===========================================
   SiteForge / 响应式 v2
   =========================================== */

/* Nav: 移动端隐藏desktop导航，显示hamburger */
@media (max-width: 1024px) {
  nav { flex-wrap: wrap; position: relative; }
  nav .nav-links,
  nav .nav-actions { display: none !important; }
  nav .nav-links .mobile-only { display: none; }
  .mobile-toggle { display: flex; }
  .hero, .product-grid, .category-tabs { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }

  .nav-top { padding: 4px 12px; gap: 8px; font-size: 11px; overflow: hidden; height: 28px; }
  .nav-top a:first-child { display: none; }
  .nav-top select { font-size: 11px; padding: 0 4px; }

  .hero { padding: 80px 16px 40px; min-height: 300px; }
  .hero h1 { font-size: 22px; }
  .hero .subtitle { font-size: 14px; margin-bottom: 16px; }
  .hero .search-box { gap: 6px; max-width: 100%; }
  .hero .search-box input { flex: 0 0 27%; font-size: 16px; }
  .hero .search-box a.btn-hero { white-space: nowrap; padding: 12px 32px; font-size: 15px; }
}

/* ===== ≤768px ===== */
@media (max-width: 768px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
  .product-card .card-body { padding: 14px; }
  .product-card .product-title { font-size: 1rem; }
  .product-card .product-price { font-size: 1.1rem; }
  .product-card .btn-add-cart { padding: 4px 10px; font-size: 11px; }

  .category-tabs {
    justify-content: flex-start;
    padding: 12px 12px 0;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .category-tabs .tab-item {
    padding: 6px 14px;
    font-size: 13px;
  }

  .page-content { padding: var(--space-lg) 14px; }
  .form-box { margin: var(--space-lg) 14px; padding: var(--space-lg); }
  .field input, .field textarea, .field select { padding: 12px 14px; font-size: 16px; }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
  .brand-col { grid-column: 1 / -1; }

  footer { padding: var(--space-lg) 16px var(--space-md); }
  footer .grid { grid-template-columns: 1fr 1fr; gap: var(--space-lg); }

  /* Account table */
  .order-table td, .order-table th { padding: 8px 6px; font-size: 11px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Checkout */
  .page-content > div[style*="flex-direction"] { flex-direction: column; }

  /* Cart */
  .cart-desktop { display: none !important; }
  .cart-mobile { display: block !important; }
  #cartActions > div:last-child { flex-direction: column !important; align-items: stretch !important; }
}

/* ===== ≤480px ===== */
@media (max-width: 480px) {
  .hero { padding: 48px 12px 28px; min-height: 200px; }
  .hero h1 { font-size: 20px; margin-bottom: 8px; }
  .hero .subtitle { font-size: 13px; margin-bottom: 16px; }
  .search-box {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    gap: 8px !important;
  }
  .search-box input#searchInput {
    flex: 0 0 63% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
  }
  .search-box .btn-hero {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    text-align: center !important;
    box-sizing: border-box !important;
    display: inline-block !important;
  }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px; }
  .product-card .card-body { padding: 12px; }
  .product-card .product-title { font-size: 0.9rem; }
  .product-card .product-price { font-size: 1rem; }
  .product-card .btn-add-cart { padding: 4px 8px; font-size: 10px; }
  .category-tabs .tab-item {
    padding: 5px 12px;
    font-size: 12px;
  }
  .footer-grid { 
    grid-template-columns: 1fr 1fr; 
    gap: 20px; 
  }
  .brand-col { grid-column: 1 / -1; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .footer-legal { justify-content: center; flex-wrap: wrap; }
  .footer-col:last-child { align-items: flex-start; text-align: left; }
  .site-footer { padding: 40px 16px 0; margin-top: 40px; }
  .page-content { padding: var(--space-md) 12px; }
  footer .grid { grid-template-columns: 1fr; gap: var(--space-md); }
}

/* ===== 移动端导航独立强化 ===== */
@media (max-width: 768px) {
  /* 1. 导航容器为下拉菜单提供定位锚点 */
  nav { position: relative; }

  /* 2. 隐藏横向排列的菜单项，改为绝对定位的下拉抽屉 */
  .nav-links {
    display: none !important;
    flex-direction: column !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    background-color: var(--color-primary) !important;
    padding: 8px 0 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.15) !important;
    z-index: 9999 !important;
  }

  /* 3. 当 JS 注入 active 时，强制显示下拉菜单 */
  .nav-links.active {
    display: flex !important;
  }
  .nav-links.active .mobile-only {
    display: block !important;
  }

  /* 4. 移动端菜单项的间距与主题统一 */
  .nav-links a, .nav-links .nav-item a {
    width: 100% !important;
    padding: 14px 20px !important;
    box-sizing: border-box !important;
    color: rgba(255,255,255,.85) !important;
    font-size: 15px !important;
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
    text-align: center !important;
  }
  .nav-links a:active { background: rgba(200,169,110,.15) !important; }

  .nav-links .sub-nav {
    position: static !important;
    box-shadow: none !important;
    background: rgba(0,0,0,.15) !important;
    padding: 4px 0 4px 20px !important;
  }
  .nav-links .sub-nav a {
    font-size: 14px !important;
    padding: 10px 20px !important;
    border-bottom: none !important;
  }
  .nav-links .arrow { display: none !important; }

  /* 5. 汉堡按钮变成叉的简单 CSS 动画 */
  .mobile-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  .mobile-toggle.open span:nth-child(2) {
    opacity: 0;
  }
  .mobile-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
  }
}

/* ===== Print ===== */
@media print {
  nav, nav + main, footer { display: none; }
  body { background: #fff; color: #000; }
}
