/* ============================================================
   FILE: css/mobile.css
   JOEBEST A1 — Mobile-First Optimisation Layer
   Add this AFTER style.css and premium.css on every page
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   GLOBAL MOBILE TOUCH & PERFORMANCE
   ───────────────────────────────────────────────────────────── */

/* Eliminate ALL 300ms tap delays site-wide */
* { touch-action: manipulation; }

/* Prevent text resize on rotate */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Prevent horizontal scroll from any overflow */
body { overflow-x: hidden; }

/* Larger tap targets on every interactive element */
a, button, .btn, select, input[type="checkbox"], input[type="radio"] {
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

/* Inputs — bigger font so iOS doesn't auto-zoom */
input, select, textarea {
  font-size: 16px !important; /* iOS zooms in if < 16px */
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────
   TOP BAR — hide on small screens to save space
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .top-bar { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   NAVBAR — mobile-first compact design
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --nav-h: 56px; }

  .nav-inner {
    padding: 0 14px;
    gap: 10px;
  }

  /* Show hamburger, hide desktop links */
  .nav-links { display: none !important; }
  .hamburger { display: flex !important; }
  .nav-search { display: none !important; } /* search is in mobile nav */

  /* Logo — tighter on mobile */
  .nav-logo { font-size: 17px; gap: 8px; }
  .nav-logo .logo-icon { width: 32px; height: 32px; font-size: 16px; }

  /* Mobile nav — full-width dropdown, proper touch targets */
  .mobile-nav {
    padding: 8px 16px 16px;
    gap: 0;
  }
  .mobile-nav a {
    padding: 14px 4px;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--gray-2);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 50px;
  }
  .mobile-nav a:last-child { border-bottom: none; }
  .mobile-nav .nav-search {
    display: flex !important;
    max-width: 100%;
    margin-bottom: 10px;
    margin-top: 4px;
  }
  .mobile-nav .nav-search input { font-size: 15px !important; }
}

/* ─────────────────────────────────────────────────────────────
   CATEGORY NAV — horizontal scroll strip
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .category-nav .container {
    padding: 0 8px;
    gap: 0;
  }
  .cat-nav-link {
    padding: 10px 13px;
    font-size: 12px;
    gap: 5px;
  }
  .cat-nav-link .cat-icon { font-size: 14px; }
}

/* ─────────────────────────────────────────────────────────────
   HERO SECTION — stacked, compact on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { min-height: auto; }
  .hero-inner {
    grid-template-columns: 1fr;
    padding: 32px 16px 28px;
    gap: 20px;
    text-align: center;
  }
  .hero-image { display: none; } /* remove floating image on mobile */
  .hero-title { font-size: 26px !important; line-height: 1.2; }
  .hero-subtitle { font-size: 14px; margin-bottom: 20px; }
  .hero-actions {
    justify-content: center;
    gap: 10px;
  }
  .hero-actions .btn {
    flex: 1;
    min-width: 120px;
    padding: 13px 16px;
    font-size: 14px;
  }
  .hero-eyebrow { font-size: 11px; }
}

/* ─────────────────────────────────────────────────────────────
   SECTIONS — tighter padding on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .section { padding: 28px 0; }
  .container { padding: 0 14px; }
  .section-header { margin-bottom: 18px; }
  .section-title { font-size: 20px !important; }
}

/* ─────────────────────────────────────────────────────────────
   CATEGORY SHORTCUTS — 2 columns on mobile, 4 on tablet
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cat-shortcuts {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .cat-card { padding: 14px 8px; gap: 8px; }
  .cat-card .icon { width: 42px; height: 42px; font-size: 20px; border-radius: 10px; }
  .cat-card span { font-size: 11px; }
}
@media (max-width: 480px) {
  .cat-shortcuts { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .cat-card { padding: 12px 6px; border-radius: 8px; }
  .cat-card .icon { width: 38px; height: 38px; font-size: 18px; }
  .cat-card span { font-size: 10px; }
}

/* ─────────────────────────────────────────────────────────────
   PRODUCT GRID & CARDS — 2 columns on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}
@media (max-width: 380px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

/* Product card — tighter on mobile */
@media (max-width: 768px) {
  .product-card { border-radius: 8px; }
  .product-body { padding: 10px; }
  .product-name { font-size: 12.5px; line-height: 1.3; height: 2.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .product-category { font-size: 10px; margin-bottom: 4px; }
  .product-price { font-size: 14px; }
  .product-price-original { font-size: 11px; }
  .product-actions { flex-direction: column; gap: 6px; }
  .product-actions .btn { width: 100%; padding: 9px 10px; font-size: 12px; border-radius: 6px; }
  .product-img-wrap { aspect-ratio: 1; }
  /* Badge sizes */
  .badge-sale, .badge-new { font-size: 9px; padding: 2px 6px; }
}

/* ─────────────────────────────────────────────────────────────
   PROMO BANNER
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .promo-banner {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
    gap: 12px;
  }
  .promo-banner .btn { width: 100%; }
}

/* ─────────────────────────────────────────────────────────────
   CART PAGE — full mobile redesign
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cart-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  /* Order summary stacks below cart on mobile */
  #cartSummary { position: static !important; }
}

@media (max-width: 768px) {
  /* Hide table-style header — we show inline labels instead */
  .cart-table-header { display: none !important; }

  /* Cart items — stack product info */
  .cart-item {
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    flex-wrap: nowrap;
  }
  .cart-item-info { flex: 1; min-width: 0; }
  .cart-item-name { font-size: 13px; }
  .cart-item-cat  { font-size: 11px; }

  /* Address dropdowns — full width stacked */
  .addr-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
}

/* ─────────────────────────────────────────────────────────────
   PAYMENT MODAL — edge-to-edge on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Push modal to bottom sheet style */
  #paymentModal > div {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
  }
  #orderSuccessModal > div {
    margin: 16px auto !important;
    width: calc(100% - 24px) !important;
    max-width: 100% !important;
  }
  .payment-methods { grid-template-columns: 1fr !important; gap: 8px !important; }
}

/* Bank transfer copy row — make numbers selectable and large */
.bank-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-2);
  gap: 10px;
}
.bank-copy-value {
  font-family: monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: 1px;
  user-select: all;     /* lets user long-press to select on Android */
  -webkit-user-select: all;
  cursor: text;
}
.bank-copy-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 36px;
  touch-action: manipulation;
}
.bank-copy-btn.copied {
  background: var(--success);
}

/* ─────────────────────────────────────────────────────────────
   ORDER SUMMARY — sticky on desktop, static on mobile
   ───────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  .order-summary {
    position: sticky;
    top: calc(var(--nav-h) + 16px);
  }
}

/* ─────────────────────────────────────────────────────────────
   PROFILE PAGE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .profile-layout { padding-top: 16px; }
  .scb { padding: 14px; }
  .sch { padding: 14px 16px; }
  .pmenu-btn { padding: 14px 16px; font-size: 15px; min-height: 52px; }
  .addr-grid { grid-template-columns: 1fr !important; }
  /* Stack detail rows on narrow screens */
  .profile-detail-row { flex-direction: column; gap: 4px; }
  .pdv { text-align: left !important; }
}

/* ─────────────────────────────────────────────────────────────
   PRODUCT DETAIL PAGE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .product-detail-layout { grid-template-columns: 1fr; }
  .product-gallery { position: static; }
}
@media (max-width: 768px) {
  .detail-price { font-size: 26px !important; }
  .detail-actions { flex-direction: column; gap: 10px; }
  .detail-actions .btn { width: 100%; }
  .specs-table td, .specs-table th { padding: 9px 10px; font-size: 13px; }
}

/* ─────────────────────────────────────────────────────────────
   AUTH / LOGIN PAGE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 24px 16px; border-radius: var(--radius); margin: 12px; }
  .auth-tabs { font-size: 14px; }
}

/* ─────────────────────────────────────────────────────────────
   ADMIN — mobile layout fixes
   ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .admin-topbar { padding: 0 14px; }
  .admin-main { padding: 14px; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
}

/* ─────────────────────────────────────────────────────────────
   FOOTER — single column on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .footer { padding: 28px 0 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; margin-bottom: 24px; }
  .footer-bottom { flex-direction: column; gap: 10px; text-align: center; padding: 14px 0; }
}

/* ─────────────────────────────────────────────────────────────
   TOAST — full width on mobile, bottom centre
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #toast-container {
    bottom: 80px; /* above WhatsApp bubble */
    right: 12px;
    left: 12px;
  }
  .toast {
    min-width: unset;
    max-width: 100%;
    font-size: 13px;
    padding: 12px 14px;
  }
}

/* ─────────────────────────────────────────────────────────────
   MODALS — scroll-aware on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    margin: 0;
    transform: translateY(20px);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
}

/* ─────────────────────────────────────────────────────────────
   SEARCH DROPDOWN — full width on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .search-dropdown {
    position: fixed !important;
    top: var(--nav-h) !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 0 0 var(--radius) var(--radius);
  }
}

/* ─────────────────────────────────────────────────────────────
   PAGE HEADER — compact on mobile
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-header { padding: 20px 0 16px; }
  .page-header h1 { font-size: 22px; }
  .page-header p { font-size: 13px; }
}

/* ─────────────────────────────────────────────────────────────
   FILTER BAR — products page
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .filter-bar { padding: 12px; gap: 8px; }
  .filter-bar .filter-item {
    min-width: calc(50% - 4px);
    flex: none;
  }
  .filter-reset { width: 100%; }
}

/* ─────────────────────────────────────────────────────────────
   WISHLIST PAGE
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #wishlist-empty { padding: 48px 20px; }
  #wishlist-empty .icon { font-size: 44px; }
}

/* ─────────────────────────────────────────────────────────────
   BACK TO TOP — don't overlap WhatsApp bubble
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #back-to-top { bottom: 90px !important; right: 14px !important; }
  #wa-bubble   { bottom: 16px !important; right: 14px !important; }
}

/* ─────────────────────────────────────────────────────────────
   STATS / PROMO GRID
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px 12px; }
}

/* ─────────────────────────────────────────────────────────────
   SMOOTH MOMENTUM SCROLLING — feels native on iOS
   ───────────────────────────────────────────────────────────── */
.category-nav,
.mobile-nav,
.search-dropdown,
#paymentModal,
#orderSuccessModal,
.modal,
.admin-main {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ─────────────────────────────────────────────────────────────
   DARK MODE — fix mobile-specific elements
   ───────────────────────────────────────────────────────────── */
:root.dark .mobile-nav { background: var(--gray-1); border-color: var(--gray-3); }
:root.dark #paymentModal > div { background: var(--white); }
:root.dark .bank-copy-value { color: var(--orange-light); }

