/*
 * Mobile-first safety layer, loaded last on every page (customer, admin and the public pages).
 *
 * It does not restyle anything. It only enforces the rules a 320 px phone needs, on top of each page's own CSS:
 *   1. nothing pushes the page sideways;
 *   2. text is never smaller than 12 px;
 *   3. buttons and fields are comfortable to tap on touch screens;
 *   4. popups and drawers fit the screen, including a phone on its side;
 *   5. keyboard focus is visible and reduced-motion is respected.
 * Check it with:  node tests/responsive_audit.mjs <label>
 */

/* ---- 1. nothing may scroll the page sideways ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overflow-x: clip; }   /* "clip", not "hidden": no scroll box is created, so sticky headers keep working */
img, svg, video, canvas, iframe { max-width: 100%; }
img, video { height: auto; }
.table-responsive, .overflow-x-auto { -webkit-overflow-scrolling: touch; }
pre, code, .break-all { overflow-wrap: anywhere; }
table { max-width: 100%; }

/* ---- 2. text floor: small labels, badges and pills stay readable ---- */
.marquee-chip-cta, .marquee-tag, .status-pill, .category-badge, .cs-badge, .rb-pill, .new-badge,
.cs-sec__title, .cs-brand__tag, .cs-wallet__label, .kpi-trend, .dash-welcome-date-sub, .svc-fixed,
.vtu-perk, .install-app-icon-text, .provider-badge, .badge,
[class*="text-[10px]"], [class*="text-[11px]"], [class*="text-[0.6"], [class*="text-[0.7"] { font-size: 12px; }
small, .small, code { font-size: max(12px, 0.875em); }
.new-badge { padding-block: 1px; }

/* ---- 3. tap targets (phones, tablets and any touch screen) ---- */
@media (max-width: 1023.98px), (pointer: coarse) {
  button:not(.btn-close):not(.swal2-close):not(.shop-x), .btn, [role="button"], select, textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]):not([type="color"]) {
    min-height: 44px;
  }
  .btn-sm, .btn.btn-sm, .page-link { min-height: 40px; }
  .admin-icon-btn, .copy-key-btn, .lg\:hidden.p-2, .relative.p-2\.5, button[aria-label], a[aria-label].btn {
    min-width: 44px;
    min-height: 44px;
  }
  /* a little air between neighbouring controls */
  .row-actions-menu button, .row-actions-menu a { min-height: 44px; }
  /* iOS zooms the page when a field under 16 px is focused */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: max(16px, 1em); }
}

/* ---- 4. popups, drawers and sheets fit the screen ---- */
.modal-dialog { max-width: calc(100vw - 24px); margin-inline: auto; }
.modal-content { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.swal2-popup { max-width: calc(100vw - 24px) !important; box-sizing: border-box; }
.shop-panel, .admin-drawer, .cs-sb { max-width: 100vw; }
.admin-drawer-body, .shop-panel { overscroll-behavior: contain; }
@media (max-height: 480px) {              /* a phone on its side */
  .modal-content, .shop-panel, .admin-drawer { max-height: calc(100dvh - 12px); }
  .swal2-popup { max-height: calc(100dvh - 12px); overflow-y: auto; }
}
/* the home-indicator strip on notched phones */
.bottom-nav, .shop-cartbar { padding-bottom: max(env(safe-area-inset-bottom), 0px); }

/* ---- 5. keyboard focus and reduced motion ---- */
:focus-visible { outline: 3px solid rgba(234, 88, 12, 0.45); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---- 6. phones: floating buttons stay out of the way of the content ---- */
@media (max-width: 767.98px) {
  /* The support bubble used to sit bottom-left, on top of wallet and form text. Right edge, smaller, above the bottom bar. */
  body .support-float, body .whatsapp-float {
    left: auto;
    right: 12px;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  body .support-float .floating-action__icon { height: 48px; }
  body .whatsapp-float { bottom: calc(140px + env(safe-area-inset-bottom)); } /* never on top of the support bubble */
  /* The admin top bar has no room for a search box on a phone: the menu, bell and profile matter more. */
  .admin-search { display: none; }
  /* Page title rows: the action button goes under the title, full width */
  .page-header { flex-wrap: wrap; gap: 12px; }
  .page-header > .btn, .page-header .btn-primary:only-child, .page-header a.btn { width: 100%; justify-content: center; text-align: center; }
}

/* Desktop: the whole site is drawn about 12% smaller (rem-based sizes follow). Phones and tablets keep full-size, readable text. */
@media (min-width: 1024px) {
  html { font-size: 14px; }
}

/* ---- 7. narrow phones: side-by-side form fields stack, so labels, placeholders and select options are not cut off ---- */
@media (max-width: 400px) {
  form:not(#registerForm) .grid-cols-2:has(input:not([type="hidden"]), select, textarea) { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---- 8. phones: text-only links (Sign in / Sign up / Forgot password...) get a finger-sized touch area.
   The padding is cancelled by an equal negative margin, so nothing on the page moves. ---- */
@media (max-width: 480px) {
  a.text-orange-600.font-bold, a.text-orange-600.font-semibold, a.text-orange-600.font-medium,
  a.text-sm.font-semibold, a.text-sm.font-medium {
    display: inline-block; padding: .55rem .35rem; margin: -.55rem -.35rem;
  }
}

/* Bottom navigation v2 (2026-10-25): a floating glass bar, orange pill on the current page, glowing Wallet button, press feedback. */
.bottom-nav { left: 10px !important; right: 10px !important; bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important; padding: .35rem .4rem !important; border: 1px solid rgba(251,146,60,.35) !important;
  border-radius: 22px !important; background: rgba(255,255,255,.88) !important; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 18px 36px -18px rgba(194,65,12,.55), 0 2px 6px rgba(15,23,42,.06) !important; }
.bottom-nav > div { gap: .1rem; }
.bottom-nav > div > a, .bottom-nav > div > button { position: relative; flex: 1 1 0; min-width: 0 !important; padding: .35rem .1rem .3rem; border-radius: 16px; transition: background .2s, transform .15s, color .2s; -webkit-tap-highlight-color: transparent; }
.bottom-nav > div > a:active, .bottom-nav > div > button:active { transform: scale(.92); }
.bottom-nav > div > a i { transition: transform .2s; }
.bottom-nav > div > a.text-orange-600 { background: linear-gradient(180deg, #fff1e6, #ffedd5); box-shadow: inset 0 0 0 1.5px #fdba74; }
.bottom-nav > div > a.text-orange-600 i { transform: translateY(-1px) scale(1.12); }
.bottom-nav > div > a.text-orange-600::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 16px; height: 3px; margin-left: -8px; border-radius: 3px; background: #ea580c; }
.bottom-nav > div > button > div { width: 3.4rem !important; height: 3.4rem !important; background: linear-gradient(135deg, #c2410c, #fb923c) !important; border: 4px solid #fff !important;
  box-shadow: 0 12px 22px -8px rgba(234,88,12,.75), 0 0 0 0 rgba(251,146,60,.5); animation: navWallet 2.6s ease-out infinite; }
@keyframes navWallet { 0% { box-shadow: 0 12px 22px -8px rgba(234,88,12,.75), 0 0 0 0 rgba(251,146,60,.5); } 70% { box-shadow: 0 12px 22px -8px rgba(234,88,12,.75), 0 0 0 12px rgba(251,146,60,0); } 100% { box-shadow: 0 12px 22px -8px rgba(234,88,12,.75), 0 0 0 0 rgba(251,146,60,0); } }
.bottom-nav > div > a[href="support.php"]::before { content: ""; position: absolute; top: 4px; left: calc(50% + 6px); width: 8px; height: 8px; border-radius: 50%; background: #22c55e; border: 1.5px solid #fff; }
/* keep page content clear of the floating bar */
@media (max-width: 1023px) { body { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .bottom-nav > div > button > div { animation: none; } .bottom-nav > div > a, .bottom-nav > div > button, .bottom-nav > div > a i { transition: none; } }
html[data-theme="dark"] .bottom-nav { background: rgba(17,28,51,.9) !important; border-color: rgba(251,146,60,.4) !important; }
html[data-theme="dark"] .bottom-nav > div > a.text-orange-600 { background: rgba(251,146,60,.16); }
