/* ============================================================
   PINTECH INSTRUMENTS — mobile.css
   All 6 mobile improvements. Zero impact on desktop.
   Upload to: /css/mobile.css
   Add to header.php AFTER existing CSS links:
     <link rel="stylesheet" href="/css/mobile.css">
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   FIX 1 — HIDE TOP BAR ON MOBILE (saves ~60px above the fold)
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .topbar { display: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   FIX 2 — TIGHTEN HEADER ON MOBILE
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hdr-wrap {
    padding: 10px 14px;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
  }
  .site-logo img { height: 38px; }
  .hdr-center { display: none; } /* search visible on products page only */
  .hdr-right { gap: 6px; }
  .hdr-cta { padding: 8px 12px; font-size: 11px; }
  .hdr-contact { display: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   FIX 3 — MOBILE NAV: full-height slide-in drawer
   The backdrop + close button are injected by mobile-nav.js
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {

  /* Drawer */
  .mobile-nav {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 88vw;
    max-width: 340px;
    height: 100dvh; /* dynamic viewport height for mobile browsers */
    background: #0a2455;
    z-index: 10000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 28px rgba(0,0,0,0.4);
    padding-bottom: 80px;
    scrollbar-width: none;
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav.open { transform: translateX(0); }

  /* Dim backdrop */
  #mobNavBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    -webkit-tap-highlight-color: transparent;
  }
  #mobNavBackdrop.open { display: block; }

  /* Sticky drawer header with logo + close */
  .mob-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #0d2d6b;
    border-bottom: 2px solid #2db84b;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .mob-nav-header img { height: 30px; width: auto; }
  .mob-nav-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Hamburger button */
  .nav-toggle {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 6px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }
  .nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #0d2d6b;
    border-radius: 2px;
    transition: all 0.3s;
    flex-shrink: 0;
  }

  /* Top-level plain links */
  .mobile-nav > a {
    display: block;
    padding: 13px 20px;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 0.5px solid rgba(255,255,255,0.07);
    text-decoration: none;
    min-height: 48px;
    line-height: 22px;
  }
  .mobile-nav > a:hover,
  .mobile-nav > a:active { color: #2db84b; background: rgba(255,255,255,0.05); }

  /* Category accordion rows */
  .mob-cat-row {
    display: flex;
    align-items: stretch;
    border-bottom: 0.5px solid rgba(255,255,255,0.07);
    min-height: 50px;
  }
  .mob-cat-link {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 13px 20px;
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
  }
  .mob-cat-link:hover { color: #2db84b; }

  /* Expand/collapse toggle — big tap target */
  .mob-sub-toggle {
    min-width: 52px;
    background: none;
    border: none;
    border-left: 0.5px solid rgba(255,255,255,0.1);
    color: #2db84b;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-sub-toggle.open { transform: rotate(180deg); }

  /* Subcategory list */
  .mob-subs { display: none; background: rgba(0,0,0,0.22); }
  .mob-subs.open { display: block; }
  .mob-subs a {
    display: block;
    padding: 10px 20px 10px 34px;
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    border-bottom: 0.5px solid rgba(255,255,255,0.04);
    text-decoration: none;
    min-height: 42px;
    line-height: 22px;
    display: flex;
    align-items: center;
  }
  .mob-subs a::before {
    content: '›';
    margin-right: 8px;
    color: #2db84b;
    font-size: 14px;
    flex-shrink: 0;
  }
  .mob-subs a:hover { color: #2db84b; background: rgba(255,255,255,0.04); }

  /* Hide desktop nav */
  .nav-wrap { display: none !important; }
  .main-nav {
    padding: 0 14px !important;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
  }
}

/* ─────────────────────────────────────────────────────────────
   FIX 4 — HORIZONTAL CATEGORY SCROLL BAR
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .mobile-cats {
    display: flex !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #0d2d6b;
    border-bottom: 2px solid #2db84b;
    padding: 0;
    gap: 0;
  }
  .mobile-cats::-webkit-scrollbar { display: none; }
  .mobile-cats a {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    font-weight: 500;
    padding: 11px 13px;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    min-height: 44px;
  }
  .mobile-cats a:hover,
  .mobile-cats a.act {
    color: #fff;
    border-bottom-color: #2db84b;
    background: rgba(255,255,255,0.06);
  }
}

/* ─────────────────────────────────────────────────────────────
   FIX 5 — STICKY BOTTOM ACTION BAR
   Injected by mobile-sticky-bar.php (include in footer.php)
───────────────────────────────────────────────────────────── */
.mob-sticky-bar { display: none; }

@media (max-width: 900px) {
  .mob-sticky-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    height: 56px;
    background: #fff;
    border-top: 1px solid #dde5ef;
    box-shadow: 0 -3px 16px rgba(13,45,107,0.12);
  }
  .mob-sticky-bar a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.2px;
  }
  .mob-sticky-bar a:active { opacity: 0.82; }
  .mob-sticky-bar .msb-wa {
    background: #25d366;
    color: #fff;
    border-right: 1px solid rgba(255,255,255,0.25);
  }
  .mob-sticky-bar .msb-wa:hover { background: #1ebe5d; }
  .mob-sticky-bar .msb-quote {
    background: #0d2d6b;
    color: #fff;
  }
  .mob-sticky-bar .msb-quote:hover { background: #112f74; }
  .mob-sticky-bar svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  /* Body padding so content isn't hidden behind the bar */
  body { padding-bottom: 56px !important; }

  /* Move existing WhatsApp float above the bar */
  .wa-float {
    bottom: 68px !important;
    right: 14px !important;
    padding: 9px 14px !important;
    font-size: 12px !important;
  }
  .wa-icon { width: 18px !important; height: 18px !important; }
}

/* ─────────────────────────────────────────────────────────────
   FIX 6 — PRODUCT IMAGES: lazy load + WebP (CSS side only)
   The PHP side is handled by webp-images.php helper
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* 2-column product grid */
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .prod-card { border-radius: 8px; }
  .prod-name { font-size: 12px; }
  .prod-artno { font-size: 10px; }
  .prod-img-wrap { aspect-ratio: 1 / 1; }
  .prod-img-wrap img {
    width: 82%;
    height: 82%;
    object-fit: contain;
  }
}
@media (max-width: 380px) {
  .product-grid { grid-template-columns: 1fr !important; }
}

/* ─────────────────────────────────────────────────────────────
   BONUS — DETAIL PAGE: single column on mobile
───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  .detail-img { min-height: auto; padding: 14px; }
  .detail-actions { flex-direction: column; }
  .detail-actions .btn,
  .detail-actions .cart-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 13px;
    font-size: 14px;
    min-height: 48px;
  }
  .related-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
}

/* ─────────────────────────────────────────────────────────────
   BONUS — FOOTER: clean up on mobile
───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ft-seo-links { display: none !important; }
  .ft-bottom-inner { flex-direction: column; text-align: center; gap: 6px; }
  .ft-col h3 { font-size: 11px; }
  .ft-col a, .ft-col p { font-size: 11px; }
}

/* ─────────────────────────────────────────────────────────────
   BONUS — PAGE LAYOUT: hide sidebar, full width content
───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-body {
    grid-template-columns: 1fr !important;
    padding: 12px !important;
    gap: 12px;
  }
  .sidebar { display: none !important; }
}
