/* =========================================================
   GHAR TAK — MOBILE APP SHELL (v52)
   Loaded after style.css. Applies only on phones/small tablets
   (<= 768px). Desktop layout is left exactly as it was.
   Coral = browse / add to cart.  Teal = commit (view cart, order).
   ========================================================= */

/* Elements that only exist for the mobile shell are hidden by default (desktop). */
.bottom-nav,
.sheet-head { display: none; }

@media (max-width: 768px) {
  :root {
    --gt-bg: #F3F4F7;
    --gt-card: #FFFFFF;
    --gt-ink: #0F172A;
    --gt-muted: #64748B;
    --gt-line: #E7EAF0;
    --gt-brand: #FF5A36;
    --gt-brand-soft: #FFF1EE;
    --gt-go: #16A085;
    --gt-safe-b: env(safe-area-inset-bottom, 0px);
    --gt-nav-h: 62px;
    --gt-header-h: 118px; /* updated live by app-shell.js */
  }

  /* Only <html> clips sideways overflow. With overflow-x hidden on <body> as well,
     body turns into a scroll container and position: sticky stops working. */
  html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
  html body { overflow-x: visible; }
  body {
    background: var(--gt-bg);
    padding-bottom: calc(var(--gt-nav-h) + var(--gt-safe-b) + 84px);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
  }
  html body.cart-open { overflow: hidden; }
  button, a { touch-action: manipulation; }

  /* ---------- Top strip ---------- */
  body .top-ticker {
    font-size: 12px;
    padding: 6px 14px;
    line-height: 1.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
  }

  /* ---------- Header: brand + language, then full-width search ---------- */
  body .site-header { background: #fff; box-shadow: 0 1px 0 var(--gt-line); backdrop-filter: none; }
  body .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "search search";
    gap: 10px 8px;
    align-items: center;
    padding: 8px 14px 10px;
    max-width: none;
  }
  body .brand-area { grid-area: brand; gap: 10px; min-width: 0; }
  body .brand-logo { width: 40px; height: 40px; flex: none; }
  body .brand-logo img { width: 40px; height: 40px; }
  body .brand-text h1 { font-size: 20px; line-height: 1.4; margin: 0; }
  body .brand-text small { display: none; }
  body .header-actions { grid-area: actions; gap: 8px; }
  body .header-actions .cart-pill { display: none; } /* cart lives in the bottom bar */
  body .install-app-btn { padding: 8px 12px; font-size: 12px; border-radius: 999px; min-height: 36px; }
  body .lang-switcher { padding: 3px; border-radius: 999px; background: #EEF0F4; border: 0; }
  body .lang-btn { min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 13px; }

  body .header-search-bar {
    grid-area: search;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    background: #F1F3F7;
    border: 1px solid transparent;
    transition: border-color .15s, background .15s;
  }
  body .header-search-bar:focus-within { background: #fff; border-color: var(--gt-brand); }
  body .header-search-bar .search-mini-icon { font-size: 20px; color: var(--gt-muted); line-height: 1; }
  body .header-search-bar input {
    flex: 1; min-width: 0; height: 100%;
    border: 0; background: transparent; outline: 0;
    font-size: 16px; /* 16px stops iOS zoom-on-focus */
    padding: 0; box-shadow: none;
  }

  /* ---------- Welcome hero is replaced by banners + search on phones ---------- */
  body .hero-express { display: none; }

  /* ---------- Store status: one slim line ---------- */
  body .store-status-banner { border: 0; border-bottom: 1px solid var(--gt-line); }
  body .store-status-inner {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0;
    padding: 8px 14px; max-width: none;
  }
  body .status-left strong { font-size: 13.5px; line-height: 1.8; }
  body .status-schedule { font-size: 12px; line-height: 1.7; opacity: .85; }

  /* ---------- Main column ---------- */
  body .main-container { padding: 0 14px; margin: 0 auto; max-width: none; z-index: auto; width: 100%; }

  /* ---------- Promo banners ---------- */
  body .promo-slider-wrap { margin: 12px 0 12px; border-radius: 18px; overflow: hidden; }
  body .promo-slide {
    width: 100%; max-width: 100%; box-sizing: border-box; min-height: 0;
    padding: 14px 18px 30px;
    flex-direction: row;
    align-items: center;
    text-align: start;
    border-radius: 18px;
  }
  body .promo-slide-content { align-items: flex-start; text-align: start; max-width: 100%; min-width: 0; flex: 1 1 0; overflow-wrap: anywhere; }
  body .promo-slide h3 { font-size: 17px; line-height: 1.7; margin: 4px 0 8px; }
  body .promo-slide p { display: none; }
  body .promo-badge { font-size: 11px; padding: 2px 10px; }
  body .promo-cta { padding: 7px 16px; font-size: 13px; border-radius: 999px; min-height: 36px; }
  body .slider-nav { display: none; }
  body .slider-dots { bottom: 10px; gap: 6px; }
  body .slider-dot { min-height: 0; width: 7px; height: 7px; padding: 0; border-radius: 4px; }
  body .slider-dot.active { width: 18px; }

  /* ---------- Section headings ---------- */
  body .section-header-row { margin: 4px 0 10px; align-items: center; gap: 10px; }
  body .section-header-row h2 { font-size: 18px; line-height: 1.7; margin: 0; }
  body .section-tag { display: none; }
  body .delivery-badge-pill { font-size: 12px; padding: 4px 10px; white-space: nowrap; }

  /* ---------- Category chips (sticky under header) ---------- */
  body .category-pills {
    position: sticky;
    top: var(--gt-header-h);
    z-index: 40;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -14px 10px;
    padding: 8px 14px;
    background: var(--gt-bg);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  body .category-pills::-webkit-scrollbar { display: none; }
  body .cat-pill {
    flex: none;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--gt-line);
    background: #fff;
    color: var(--gt-ink);
    font-size: 14px;
    font-weight: 600;
    box-shadow: none;
  }
  body .cat-pill.active { background: var(--gt-brand); border-color: var(--gt-brand); color: #fff; }

  /* ---------- Product grid ---------- */
  body .products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body .product-card {
    display: flex; flex-direction: column;
    border-radius: 16px;
    border: 1px solid var(--gt-line);
    background: var(--gt-card);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    overflow: hidden;
    transform: none;
  }
  body .product-card.sold-out { opacity: .6; }
  body .product-media { height: auto; aspect-ratio: 1 / .86; background: #F7F8FA; position: relative; }
  body .product-media img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
  body .badge-category { display: none; }
  body .badge-featured { top: 8px; inset-inline-start: 8px; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; }
  body .badge-stock { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; bottom: 8px; inset-inline-start: 8px; }
  body .badge-stock.ok { display: none; } /* only warn on low / out of stock */

  body .product-body { padding: 10px 11px 11px; display: flex; flex-direction: column; flex: 1; gap: 6px; }
  body .product-title {
    font-size: 14px; font-weight: 650; line-height: 1.6; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  html[lang="ur"] body .product-title { line-height: 1.95; }
  body .product-subtitle { display: none; }
  body .product-footer { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: auto; border-top: 0; padding-top: 0; }
  body .product-price { font-size: 16px; font-weight: 800; line-height: 1.5; }

  body .add-btn {
    box-sizing: border-box; display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 44px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: clip;
    border-radius: 11px;
    background: #fff; color: var(--gt-brand);
    border: 1.5px solid var(--gt-brand);
    font-size: 13.5px; font-weight: 700;
    box-shadow: none;
    transition: background .12s, color .12s, transform .08s;
  }
  body .add-btn:active:not(:disabled) { background: var(--gt-brand); color: #fff; transform: scale(.98); }
  body .add-btn:disabled { background: #EEF0F4; color: #94A3B8; border-color: transparent; }

  body .product-footer .qty-stepper {
    width: 100%; min-height: 40px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--gt-brand); border: 0; border-radius: 11px; padding: 0;
  }
  body .product-footer .qty-stepper button {
    flex: 0 0 44px; height: 40px; background: transparent; color: #fff;
    font-size: 20px; font-weight: 700; border: 0; border-radius: 0;
  }
  body .product-footer .qty-stepper span { color: #fff; font-weight: 800; font-size: 15px; }

  body .empty-state { grid-column: 1 / -1; text-align: center; color: var(--gt-muted); padding: 40px 12px; }

  /* ---------- Floating "view cart" bar (above bottom nav) ---------- */
  body .floating-cart-bar {
    position: fixed;
    left: 12px; right: 12px; width: auto; max-width: none;
    transform: none; animation: none;
    bottom: calc(var(--gt-nav-h) + var(--gt-safe-b) + 10px);
    z-index: 90;
    display: flex; align-items: center; justify-content: space-between;
    min-height: 54px; padding: 8px 8px 8px 16px;
    border-radius: 16px;
    background: var(--gt-go); color: #fff;
    box-shadow: 0 8px 24px rgba(22, 160, 133, .35);
  }
  body .floating-cart-bar[hidden], body.cart-open .floating-cart-bar { display: none !important; }
  html[dir="rtl"] body .floating-cart-bar { padding: 8px 16px 8px 8px; }
  body .floating-cart-info { display: flex; flex-direction: column; line-height: 1.35; }
  body .floating-cart-info span { font-size: 12px; opacity: .9; }
  body .floating-cart-info strong { font-size: 16px; }
  body .floating-cart-cta {
    background: rgba(255, 255, 255, .18); color: #fff; text-decoration: none;
    padding: 0 16px; min-height: 38px; display: inline-flex; align-items: center;
    border-radius: 11px; font-weight: 700; font-size: 14px;
  }

  /* ---------- Bottom navigation ---------- */
  body .bottom-nav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 100;
    display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--gt-nav-h) + var(--gt-safe-b));
    padding-bottom: var(--gt-safe-b);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--gt-line);
    backdrop-filter: blur(10px);
  }
  .bottom-nav button {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--gt-muted); font: inherit; font-size: 11.5px; font-weight: 600; line-height: 1.5;
  }
  .bottom-nav button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav button.active { color: var(--gt-brand); }
  .bottom-nav .nav-badge {
    position: absolute; top: 6px; inset-inline-start: calc(50% + 4px);
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--gt-brand); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  }
  .bottom-nav .nav-badge[hidden] { display: none; }

  /* ---------- Cart & checkout become a full-screen sheet ---------- */
  body #cartSection.cart-panel {
    position: fixed; inset: 0; z-index: 200;
    margin: 0; border-radius: 0; border: 0; box-shadow: none;
    background: var(--gt-bg);
    padding: 0 14px 0;
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateY(100%); visibility: hidden;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
  }
  body.cart-open #cartSection.cart-panel {
    transform: none; visibility: visible;
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s;
  }
  body #cartSection > .section-header-row { display: none; }

  body .sheet-head {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 -14px 10px; padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
    background: var(--gt-bg);
  }
  body .sheet-title { margin: 0; font-size: 20px; line-height: 1.7; }
  body .sheet-close {
    width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
    background: #E6E9EF; color: var(--gt-ink); font-size: 18px; line-height: 1;
  }

  body .free-ship-box { background: #fff; border: 1px solid var(--gt-line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
  body .free-ship-box[hidden] { display: none; }
  body .free-ship-text { font-size: 13px; line-height: 1.8; margin-bottom: 8px; }
  body .free-ship-track { height: 8px; border-radius: 4px; }
  body .free-ship-fill { border-radius: 4px; }

  body #cart { background: #fff; border: 1px solid var(--gt-line); border-radius: 16px; padding: 4px 14px; margin-bottom: 12px; }
  body .cart-row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--gt-line); text-align: start; }
  body .cart-row:last-child { border-bottom: 0; }
  body .cart-row-info { min-width: 0; flex: 1; text-align: start; }
  body .cart-row-info strong { display: block; font-size: 14px; line-height: 1.8; }
  body .cart-row-info small { color: var(--gt-muted); font-size: 12.5px; }
  body .cart-row-actions { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; gap: 6px; flex: none; }
  html[dir="rtl"] body .cart-row-actions { align-items: flex-start; }
  body .cart-line-total { font-weight: 800; font-size: 14px; }
  body .cart-row .qty-stepper {
    display: inline-flex; align-items: center; background: var(--gt-brand-soft);
    border: 0; border-radius: 10px; padding: 0; min-height: 36px;
  }
  body .cart-row .qty-stepper button { width: 36px; height: 36px; background: transparent; color: var(--gt-brand); font-size: 18px; font-weight: 700; border: 0; }
  body .cart-row .qty-stepper span { min-width: 22px; text-align: center; font-weight: 800; }
  body .empty-cart-msg { text-align: center; color: var(--gt-muted); padding: 36px 8px; margin: 0; }

  body .bill-breakdown { background: #fff; border: 1px solid var(--gt-line); border-radius: 16px; padding: 8px 14px; margin-bottom: 12px; }
  body .bill-breakdown[hidden] { display: none; }
  body .bill-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
  body .total-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--gt-ink); color: #fff; border-radius: 16px; padding: 14px 16px; margin-bottom: 16px;
  }
  body .total-bar strong { font-size: 20px; }

  /* Checkout form */
  body .checkout-title-box h3 { font-size: 17px; margin: 0 0 8px; line-height: 1.7; }
  body .form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 0; }
  body .input-group { margin: 0 0 12px; }
  body .input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gt-muted); margin-bottom: 6px; line-height: 1.8; }
  body .input-group input,
  body .input-group select,
  body .input-group textarea {
    width: 100%; min-height: 50px; padding: 10px 14px;
    border-radius: 12px; border: 1.5px solid var(--gt-line); background: #fff;
    font-size: 16px; /* prevents iOS zoom */
    outline: 0; box-shadow: none;
  }
  body .input-group textarea { min-height: 84px; }
  body .input-group input:focus,
  body .input-group select:focus,
  body .input-group textarea:focus { border-color: var(--gt-brand); box-shadow: 0 0 0 3px rgba(255, 90, 54, .15); }
  body .input-group input[readonly] { background: #F7F8FA; color: var(--gt-muted); }
  body .small-label { font-size: 12.5px; color: var(--gt-muted); line-height: 1.8; }

  /* Order buttons stay pinned to the bottom of the sheet */
  body .checkout-btn-group {
    position: sticky; bottom: 0; z-index: 4;
    display: flex; flex-direction: column; gap: 8px;
    margin: 12px -14px 0; padding: 12px 14px calc(12px + var(--gt-safe-b));
    background: var(--gt-bg);
    box-shadow: 0 -10px 16px -10px rgba(15, 23, 42, .18);
  }
  body .primary-checkout-btn,
  body .whatsapp-checkout-btn { width: 100%; border-radius: 14px; font-weight: 700; }
  body .primary-checkout-btn { min-height: 52px; font-size: 16px; background: var(--gt-go) !important; background-image: none !important; color: #fff; border: 0; box-shadow: 0 6px 16px rgba(22, 160, 133, .3); }
  body .whatsapp-checkout-btn { min-height: 44px; font-size: 14px; background: #fff; color: #128C7E; border: 1.5px solid #25D366; box-shadow: none; }

  body #message { font-size: 14px; line-height: 1.8; margin: 8px 0 0; }
  body #cartSection > :last-child { margin-bottom: calc(20px + var(--gt-safe-b)); }
  body .order-eta-card { background: #fff; border: 1px solid var(--gt-line); border-radius: 16px; padding: 14px; margin-top: 12px; }

  /* Empty cart: hide the checkout form until something is added */
  body.cart-empty #cartSection .checkout-title-box,
  body.cart-empty #cartSection .form-grid,
  body.cart-empty #cartSection .input-group,
  body.cart-empty #cartSection .small-label,
  body.cart-empty #cartSection .checkout-btn-group,
  body.cart-empty #cartSection .total-bar,
  body.cart-empty #cartSection .free-ship-box { display: none; }

  /* ---------- Footer ---------- */
  body .site-footer { margin-top: 24px; padding: 18px 14px; }
  body .footer-inner { gap: 12px; }

  /* ---------- Accessibility ---------- */
  button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--gt-brand); outline-offset: 2px;
  }
  @media (prefers-reduced-motion: reduce) {
    body #cartSection.cart-panel { transition: none; }
    body .add-btn { transition: none; }
  }
}

/* Very small phones */
@media (max-width: 359px) {
  body .products { gap: 8px; }
  body .product-title { font-size: 13px; }
  body .brand-text small { display: none; }
}
