/* ════════════════════════════════════════════════════════════════════
   Ibtikar Store — Mobile Responsiveness & UX Fixes
   ----------------------------------------------------------------
   Loaded after main.css. Targets:
     • Header overflow on small viewports (≤ 920 / ≤ 480 / ≤ 360 px)
     • Exit-intent popup sizing + close-button tap target
     • Announcement (tabby) bar close button + safe wrap
     • General mobile hygiene (overflow guard, tap target sizes,
       16px form input to prevent iOS zoom, safe-area insets)
   Uses !important where overriding inline styles from snippet HTML.
   ════════════════════════════════════════════════════════════════════ */

/* ── Global overflow guard (defense in depth) ───────────────────── */
html, body { max-width: 100%; }
html { overflow-x: clip; }
body { overflow-x: clip; }

/* Some elementor sections set explicit min-width — clamp them */
.elementor-section, .elementor-container, .e-con, .e-con-inner {
  max-width: 100% !important;
}

/* ════════════════════════════════════════════════════════════════════
   HEADER — Mobile layout fixes
   ════════════════════════════════════════════════════════════════════ */

/* On tablets and below: hide the inline "Request a Quote" CTA in the
   header. The same CTA is already rendered inside the mobile nav
   drawer, so this is just removing the duplicate that was causing
   horizontal overflow. */
@media (max-width: 920px) {
  .ebt-header-actions > a.ebt-btn-primary { display: none !important; }

  /* Allow the grid's auto column to actually shrink */
  .ebt-header { min-width: 0; }
  .ebt-header > * { min-width: 0; }

  /* Tighten the gap between header icon buttons */
  .ebt-header-actions { gap: 6px !important; }

  /* Make the mobile menu button properly tappable on the right side */
  .ebt-mobile-menu-btn {
    display: inline-flex !important;
    min-height: 44px;
    min-width: 44px;
  }
}

/* Below 480px (most phones in portrait): drop the brand sub-title to
   keep the logo from competing with the action buttons. Keep the
   primary brand text so users still see the name. */
@media (max-width: 480px) {
  .ebt-brand-composed .ebt-brand-text span { display: none; }
  .ebt-brand-composed .ebt-brand-text strong { font-size: 20px; }
  .ebt-brand-symbol { width: 40px !important; height: 40px !important; }

  /* On very small phones (≤ 380px) also shrink icon buttons one notch */
  .ebt-header-actions .ebt-icon-btn {
    min-width: 38px;
    min-height: 38px;
    padding: 0 8px !important;
  }
}

/* Below 360px (e.g. iPhone SE 1st gen, Galaxy Fold cover): show only
   logo symbol + cart + menu button so nothing wraps. */
@media (max-width: 360px) {
  .ebt-brand-composed .ebt-brand-text { display: none; }
  .ebt-header-actions { gap: 4px !important; }
}

/* Topbar (the AR | EN + quick links bar above the header) — keep it
   readable on tiny screens and never let the language pill collapse. */
@media (max-width: 640px) {
  .ebt-topbar { padding-block: 6px; }
  .ebt-topbar-inner { gap: 6px; flex-wrap: wrap; justify-content: center; }
  .ebt-lang-btn--topbar {
    min-height: 36px;
    padding: 0 10px;
    font-size: 11.5px;
  }
}

/* ════════════════════════════════════════════════════════════════════
   EXIT-INTENT POPUP — Mobile sizing + accessible close button
   The popup is injected via inline styles, so we override with
   higher specificity + !important.
   ════════════════════════════════════════════════════════════════════ */

#ibt-exit-popup {
  padding: 16px !important;
  /* Respect device safe area (notches / rounded corners) */
  padding: max(16px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left)) !important;
  /* Allow vertical scroll on tall content / short viewports */
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Inner card */
#ibt-exit-popup > div {
  max-width: min(480px, calc(100vw - 32px)) !important;
  width: 100% !important;
  margin: auto !important;
  /* Keep the close button anchor reliable */
  position: relative !important;
}

/* Bigger, more visible close button — proper 44×44 tap target.
   The popup is RTL so the close sits on the left (start side in RTL). */
#ibt-exit-popup > div > button {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  border-radius: 999px !important;
  background: rgba(15, 23, 42, 0.06) !important;
  color: #475569 !important;
  font-size: 22px !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  top: 12px !important;
  left: 12px !important;
  z-index: 2 !important;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
#ibt-exit-popup > div > button:hover,
#ibt-exit-popup > div > button:focus-visible {
  background: rgba(15, 23, 42, 0.12) !important;
  color: #0f172a !important;
  outline: none;
}
#ibt-exit-popup > div > button:active { transform: scale(.96); }

/* On small screens: tighter inner padding so the coupon code box and
   CTA stay readable; let the popup scroll if it still overflows. */
@media (max-width: 480px) {
  #ibt-exit-popup > div {
    padding: 56px 18px 22px !important; /* extra top padding for close btn */
    border-radius: 16px !important;
  }
  #ibt-exit-popup > div > div:nth-of-type(1) { font-size: 40px !important; }
  #ibt-exit-popup h2 { font-size: 20px !important; line-height: 1.3 !important; }
  #ibt-exit-popup p { font-size: 13.5px !important; }
  /* The coupon code "WELCOME5" — keep it readable, not overflowing */
  #ibt-exit-popup > div > div:nth-of-type(2) > div:nth-of-type(2) {
    font-size: 24px !important;
    letter-spacing: 2px !important;
    word-break: keep-all;
  }
  #ibt-exit-popup a {
    display: block !important;
    padding: 14px 22px !important;
    font-size: 14.5px !important;
  }
}

/* Below 360px: still readable */
@media (max-width: 360px) {
  #ibt-exit-popup > div { padding: 52px 14px 18px !important; }
  #ibt-exit-popup > div > div:nth-of-type(2) > div:nth-of-type(2) {
    font-size: 21px !important;
    letter-spacing: 1.5px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   ANNOUNCEMENT BAR (tabby promo) — Mobile UX
   ════════════════════════════════════════════════════════════════════ */
#ibt-announcement-bar {
  /* Reserve room for the close button so text never sits under it */
  padding-inline-start: 44px !important;
  padding-inline-end: 14px !important;
  line-height: 1.45 !important;
}
#ibt-announcement-bar > button {
  width: 36px !important;
  height: 36px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.18) !important;
  color: #fff !important;
  font-size: 18px !important;
  opacity: 1 !important;
  line-height: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#ibt-announcement-bar > button:hover {
  background: rgba(255, 255, 255, 0.28) !important;
}

@media (max-width: 480px) {
  #ibt-announcement-bar {
    font-size: 12px !important;
    padding: 8px 44px !important;
  }
  #ibt-announcement-bar > button {
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
    left: 6px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   GENERAL MOBILE UX HYGIENE
   ════════════════════════════════════════════════════════════════════ */

/* Images and embeds never overflow their container */
img, video, iframe, svg { max-width: 100%; height: auto; }

/* Forms — 16px input prevents iOS Safari auto-zoom on focus */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Tap targets — minimum 40×40 for any anchor/button that's icon-only.
   (Not applied to nav text links to avoid distorting typography.) */
@media (pointer: coarse) {
  .ebt-icon-btn,
  .mobile-nav-close,
  .ebt-mobile-menu-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Mobile drawer header alignment when AR text shrinks */
@media (max-width: 480px) {
  .mobile-nav-header { padding: 16px 18px; }
  .mobile-nav-link { padding: 14px 18px; font-size: 15px; }
  .mobile-nav-ctas { padding: 14px 18px 20px; }
}

/* Cart drawer / WooCommerce mini-cart fragments — respect viewport */
.woocommerce-cart-form,
.woocommerce table.shop_table_responsive,
.woocommerce-mini-cart {
  max-width: 100%;
}

/* WhatsApp / sticky floats — keep above safe area */
.whatsapp-float,
.ibt-whatsapp-float,
#ibt-social-proof {
  bottom: calc(16px + env(safe-area-inset-bottom)) !important;
}

/* Honor reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   PRODUCT PAGE — Sticky ATC + Social-proof popup (snippet-injected)
   ════════════════════════════════════════════════════════════════════ */

/* Sticky add-to-cart bar — respect iOS safe area (home indicator) */
#ibt-sticky-atc {
  padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
}
#ibt-sticky-atc > div { gap: 10px !important; }
#ibt-sticky-atc button {
  min-height: 44px;
  padding: 10px 16px !important;
  white-space: nowrap;
}

/* Very narrow phones: shrink button to icon + small text */
@media (max-width: 360px) {
  #ibt-sticky-atc { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important; }
  #ibt-sticky-atc > div { gap: 8px !important; }
  #ibt-sticky-atc img { width: 38px !important; height: 38px !important; }
  #ibt-sticky-atc button {
    padding: 10px 12px !important;
    font-size: 12.5px !important;
  }
}

/* Social-proof popup — bigger tap target on its close button */
#ibt-social-proof {
  /* Honor safe area on bottom-pinned floating cards */
  bottom: calc(20px + env(safe-area-inset-bottom)) !important;
}
#ibt-social-proof .ibt-sp-close {
  width: 32px !important;
  height: 32px !important;
  top: 4px !important;
  right: 4px !important;
  border-radius: 999px !important;
  background: rgba(15, 23, 42, 0.04) !important;
  font-size: 18px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#ibt-social-proof .ibt-sp-close:hover,
#ibt-social-proof .ibt-sp-close:focus-visible {
  background: rgba(15, 23, 42, 0.1) !important;
  color: #0f172a !important;
  outline: none;
}

/* When sticky ATC is visible, lift social proof above it (the snippet's
   own 480px breakpoint already does this; extend to 768px for safety) */
@media (max-width: 768px) {
  #ibt-social-proof {
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 32px) !important;
    left: 16px !important;
    right: 16px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   SHOP / CATEGORY GRID — Ensure cards never overflow narrow viewports
   ════════════════════════════════════════════════════════════════════ */

/* WooCommerce default product columns can spill on tiny phones */
@media (max-width: 480px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
  .woocommerce ul.products li.product .woocommerce-loop-product__title,
  .woocommerce-page ul.products li.product .woocommerce-loop-product__title {
    font-size: 13px !important;
    line-height: 1.35;
  }
  .woocommerce ul.products li.product .price,
  .woocommerce-page ul.products li.product .price {
    font-size: 13.5px !important;
  }
}
@media (max-width: 360px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    gap: 8px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   CART / CHECKOUT — Mobile readability
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  /* WooCommerce-rendered cart/checkout tables should stack cleanly */
  .woocommerce table.shop_table_responsive thead { display: none; }
  .woocommerce table.shop_table_responsive tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
  }
  .woocommerce table.shop_table_responsive tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    border: 0 !important;
    text-align: end;
  }
  .woocommerce table.shop_table_responsive tbody tr td::before {
    content: attr(data-title);
    font-weight: 700;
    color: #475569;
    margin-inline-end: 12px;
  }
  /* Checkout payment methods + form rows — full width buttons */
  .woocommerce-checkout #payment .button,
  .woocommerce-checkout button[name="woocommerce_checkout_place_order"] {
    width: 100% !important;
    min-height: 48px;
    font-size: 15px;
  }
  .woocommerce form .form-row {
    margin-bottom: 12px;
  }
}
