/* =========================================================================
   APP STYLESHEET - the Android app only
   =========================================================================
   Every rule starts with html.gb-app, a class that header.php adds only when
   the page is opened inside the Android app (user agent word "GroupbuyersApp").
   Ordinary browsers never match, so the website looks exactly as before.

   Five size tiers, by the width of the app window (this also follows rotation,
   split-screen and foldables):
     XS  up to 359px      small phones
     S   360 - 599px      normal phones (phone.css already does most of the work)
     M   600 - 899px      large phones sideways, unfolded foldables, 7-8" tablets upright
     L   900 - 1279px     10-11" tablets, tablets sideways
     XL  1280px and up    big tablets, Chromebooks
   Layout up to 899px uses the same phone layout as the site (header.php turns on
   is-phone-ua for the app below 900px, even on tablets), so the menu is one
   button, not a row that has to scroll.
   ========================================================================= */

/* ---------- All sizes: touch behaviour ---------- */
html.gb-app { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.gb-app a, html.gb-app button, html.gb-app .btn, html.gb-app label,
html.gb-app summary, html.gb-app select {
    -webkit-tap-highlight-color: rgba(47, 82, 51, 0.18);
    touch-action: manipulation;
}
html.gb-app img, html.gb-app video { max-width: 100%; }
html.gb-app .table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
html.gb-app .btn-row { flex-wrap: wrap; }
/* Finger-sized controls on every size, tablets included. */
html.gb-app .btn { min-height: 44px; }
html.gb-app .btn-small { min-height: 40px; }
html.gb-app input[type="text"], html.gb-app input[type="number"], html.gb-app input[type="email"],
html.gb-app input[type="password"], html.gb-app input[type="tel"], html.gb-app input[type="search"],
html.gb-app input[type="date"], html.gb-app input[type="time"],
html.gb-app select, html.gb-app textarea {
    min-height: 44px;
    font-size: 16px;            /* stops the page zooming in when a field is tapped */
}
/* Long words, e-mail addresses and codes must never push the page sideways. */
html.gb-app main, html.gb-app .section, html.gb-app .product-card, html.gb-app .form-card {
    overflow-wrap: break-word;  /* not "anywhere": that shrinks grid columns to nothing */
}
html.gb-app .product-card { min-width: 0; }

/* ---------- Sideways phones and any very short window ---------- */
@media (max-height: 480px) {
    html.gb-app .site-header { position: static; }
    html.gb-app .nav-links { max-height: 70vh; }
}

/* ---------- XS: up to 359px ---------- */
@media (max-width: 359px) {
    html.gb-app { font-size: 86%; }
    html.gb-app .container { padding: 0 10px; max-width: 100%; }
    html.gb-app .product-grid { gap: 10px; }
    html.gb-app .product-card { padding: 14px; margin: 10px 0; }
    html.gb-app .hero h1 { font-size: 1.55rem; }
    html.gb-app .stat-grid, html.gb-app .stat-grid.stat-grid-2 { grid-template-columns: 1fr; }
    html.gb-app .data-table th, html.gb-app .data-table td { padding: 8px 8px; font-size: 0.8rem; }
    html.gb-app .btn-row .btn { width: 100%; justify-content: center; }
    html.gb-app .form-card { padding: 14px; }
}

/* ---------- S: 360 - 599px (normal phones) ---------- */
@media (min-width: 360px) and (max-width: 599px) {
    html.gb-app .product-card { margin: 12px 0; }
    html.gb-app .btn-row .btn { flex: 1 1 140px; justify-content: center; }
}

/* ---------- M: 600 - 899px ---------- */
@media (min-width: 600px) and (max-width: 899px) {
    html.gb-app { font-size: 96%; }
    html.gb-app .container { padding: 0 20px; max-width: 100%; }
    html.gb-app .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    html.gb-app .product-card { margin: 0; padding: 18px; }
    html.gb-app .form-card { max-width: 560px; margin: 24px auto; }
    html.gb-app .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* One-row header: logo | clock and currency | menu button. The phone layout
       stacks four rows, which is a third of a sideways phone's height. */
    html.gb-app .site-header { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; padding: 8px 14px; }
    html.gb-app .brand { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
    html.gb-app .header-ticker { grid-column: 2; grid-row: 1; align-self: end; flex-direction: row; flex-wrap: wrap; gap: 2px 12px; }
    html.gb-app .header-center { grid-column: 2; grid-row: 2; align-self: start; justify-self: start; text-align: left; }
    html.gb-app .nav-toggle-checkbox, html.gb-app .nav-toggle { grid-column: 3; grid-row: 1 / span 2; justify-self: end; align-self: center; }
    /* Intro text on the left, family photos on the right, as on the website. */
    html.gb-app .hero .container { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; margin: 0 auto; }
}

/* ---------- L: 900 - 1279px ---------- */
@media (min-width: 900px) and (max-width: 1279px) {
    html.gb-app .container { padding: 0 24px; }
    html.gb-app .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
    html.gb-app .form-card { max-width: 620px; margin: 28px auto; }
}
/* The three family photos ran off the right edge on tablets (10" and larger): share the row. */
@media (min-width: 900px) {
    html.gb-app .family-row { gap: 10px; flex-wrap: nowrap; min-width: 0; }
    html.gb-app .family-card { flex: 1 1 0; width: auto; min-width: 0; margin: 0; }
    html.gb-app .family-card img { width: 100%; height: auto; }
}

/* ---------- XL: 1280px and up ---------- */
@media (min-width: 1280px) {
    html.gb-app .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
    html.gb-app .container { max-width: 1400px; }
}

/* ---------- Fixes found by checking the real shop page at each size ---------- */
/* The home page intro block has an inline width of 365px: wider than a small phone,
   it clipped the WhatsApp button. */
@media (max-width: 899px) {
    html.gb-app .hero .container > div[style*="width"] { width: auto !important; max-width: 100%; }
}
html.gb-app .hero .btn { white-space: normal; text-align: center; }
/* Shop filters: one control per row on phones, never wider than the card. */
@media (max-width: 599px) {
    html.gb-app .shop-filters select,
    html.gb-app .shop-filters input[type="text"],
    html.gb-app .shop-filters input[type="search"],
    html.gb-app .shop-filters input[type="number"] {
        flex: 1 1 100%; width: 100%; min-width: 0; box-sizing: border-box;
    }
}
@media (min-width: 600px) {
    html.gb-app .shop-filters input[type="text"],
    html.gb-app .shop-filters input[type="search"],
    html.gb-app .shop-filters input[type="number"] { min-width: 150px; }
}

/* ---------- Phone menu: tighter rows, Credits and Alerts (all phones and the app) ---------- */
/* Rows were 49px tall and the Credits balance card stayed open under its row. Now:
   shorter rows, counts (cart, alerts, community, credits) lined up on the right, and
   the "Available" balance as one quiet line under Credits. The current balance is the
   pill on the Credits row, so the card's first line was a duplicate. */
html.is-phone-ua .nav-links a { padding: 11px 18px; gap: 12px; }
html.is-phone-ua .nav-links .nav-label {
    flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0;
}
html.is-phone-ua .credit-tip { width: 100%; display: block; }
html.is-phone-ua .credit-tip > a { border-bottom: 0; padding-bottom: 6px; }
html.is-phone-ua .credit-tip-popup {
    position: static; display: block !important; width: auto; min-width: 0;
    margin: 0; padding: 0 18px 10px 50px;
    background: transparent; border: 0; border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: none; border-radius: 0;
    font-size: 0.78rem; line-height: 1.3; color: rgba(255,255,255,0.62); white-space: normal;
}
html.is-phone-ua .credit-tip-popup .credit-tip-row:first-child { display: none; }
html.is-phone-ua .credit-tip-popup .credit-tip-row { justify-content: flex-start; gap: 6px; }
html.is-phone-ua .credit-tip-popup .credit-tip-label { color: inherit; }
html.is-phone-ua .credit-tip-popup strong { color: #fff; font-weight: 600; }
/* The open menu may be as tall as the room left under the header, measured by a few
   lines of script in header.php (--gb-hdr-bottom); 260px is the fallback. */
html.is-phone-ua .nav-links { max-height: calc(100vh - var(--gb-hdr-bottom, 260px)); max-height: calc(100dvh - var(--gb-hdr-bottom, 260px)); }

/* ===== Phones: compact header, tables, credit cards (v16.8) ===== */
html.is-phone-ua .site-header { position: static; gap: 6px; padding: 8px 10px; }
html.is-phone-ua .header-ticker { font-size: 0.72rem !important; gap: 2px; line-height: 1.3 !important; }
html.is-phone-ua .header-ticker .header-flag { display: inline-block; }
html.is-phone-ua .table-wrap .data-table th,
html.is-phone-ua .table-wrap .data-table td { padding: 8px 8px; font-size: 0.8rem; }
html.is-phone-ua .table-wrap .data-table td[colspan] {
  white-space: normal; position: sticky; left: 0;
  max-width: calc(100vw - 72px); box-sizing: border-box;
}
@media (min-width: 360px) and (max-width: 599px) {
  html.is-phone-ua .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  html.is-phone-ua .stat-card { padding: 12px 10px; }
  html.is-phone-ua .stat-card .value { font-size: 1.25rem; }
}

/* Phones: header scrolls away, but the menu button stays pinned and the
   open menu is a fixed panel under it (v16.8) */
html.is-phone-ua .nav-toggle {
  position: fixed; top: 8px; right: 10px; z-index: 1002;
  background: var(--charcoal); box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
html.is-phone-ua .nav-toggle-checkbox:checked ~ .nav-links {
  position: fixed; top: 64px; left: 0; right: 0; z-index: 1001;
  max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px);
  overflow-y: auto; box-shadow: 0 8px 20px rgba(0,0,0,.5);
}
