/* =====================================================================
   mobile.css — Phone form-factor layer for the Blazor admin WebApp
   ---------------------------------------------------------------------
   Loaded AFTER app.css and kiosk.css. Persona: a restaurant owner
   glancing at the admin app in portrait on their phone (read/monitor
   first). Navigation is the bottom tab bar in Layout/NavMenu.razor;
   this file owns the surrounding shell, the fixed slide-in panels that
   were hard-coupled to the 72px desktop rail, and portrait polish.

   ── REVERSIBILITY ──────────────────────────────────────────────────
   Every rule is gated behind `body.mobile-layout` (set in index.html
   only on phone-width + coarse-pointer devices). The single
   `if (isPhone)` block in index.html is the master kill-switch:
   remove it and this entire layer goes dormant — nothing here applies
   to any device that lacks the class.

   ── ISOLATION (why mesero + kiosk are safe) ────────────────────────
   Rules are ALSO scoped under `.app-layout` — the root <div> of the
   AUTHENTICATED MainLayout branch (MainLayout.razor:17). Consequences:
     • Mesero /m/* pages use EmptyLayout (`.empty-layout`)   → no match
     • CFD display uses CfdLayout                            → no match
     • Login/Register/Reset use MainLayout's `.public-layout`→ no match
   So even though the mesero pages share the `mobile-layout` body class
   (they run on phones), NOTHING in this file can reach them — verified
   they carry inputs at 0.8–0.85rem we must not touch. Kiosk modes
   (Elo PayTableShell, Samsung Tab landscape PWA) are >768px wide, so
   they never get `mobile-layout` in the first place.

   The two-class `.app-layout` ancestor also gives these rules
   (0,3,x) specificity, so they cleanly beat the per-page inline
   <style> blocks (single-class, rendered into <body>) without
   `!important`.
   ===================================================================== */

body.mobile-layout {
    /* Single source of truth for the bottom-tab-bar height. Mirrors the
       64px in NavMenu.razor's .bottom-tabs rule, plus the iOS home-bar
       safe area so content/panels clear the physical home indicator. */
    --pt-bottom-nav: calc(64px + env(safe-area-inset-bottom, 0px)); /* matches .bottom-tabs height */
}

/* =====================================================================
   1. SHELL — drop the 72px rail offset; reserve room for the tab bar
   ===================================================================== */
body.mobile-layout .app-layout .main-content {
    margin-left: 0;
    /* End the scrollable content area ABOVE the fixed bottom tab bar so
       the bar can never overlap page content. Reducing the height (rather
       than only padding the bottom) means the viewport for the page sits
       fully above the toolbar. dvh tracks the mobile browser's dynamic
       chrome; the vh line is the fallback for older engines. */
    height: calc(100vh - var(--pt-bottom-nav));
    height: calc(100dvh - var(--pt-bottom-nav));
    padding-bottom: 1rem;
}

/* The Index / Panel page is a position:fixed element (escapes
   .main-content) so it carries its own 72px offset. Restore it to the
   left edge and lift its bottom above the tab bar. It is still a DOM
   descendant of .app-layout, so the scope holds. */
body.mobile-layout .app-layout .home-screen {
    left: 0;
    bottom: var(--pt-bottom-nav);
}

/* Fixed full-screen slide-in panels — all were `left:72px; right:0` to
   clear the desktop rail. On phone there is no rail, so anchor them to
   the left edge and keep them above the tab bar. (Owner reaches
   .tab-detail-panel by tapping a tab on the Tabs page, so it is
   in-scope even for the read-only glance persona.) */
body.mobile-layout .app-layout .order-panel,
body.mobile-layout .app-layout .customization-panel,
body.mobile-layout .app-layout .menu-item-panel,
body.mobile-layout .app-layout .tab-detail-panel,
body.mobile-layout .app-layout .table-selection-panel {
    left: 0;
    bottom: var(--pt-bottom-nav);
}

/* =====================================================================
   2. iOS FOCUS-ZOOM GUARD
   We re-enabled pinch-zoom on phone browsers, but iOS still auto-zooms
   when focusing an input whose font-size is < 16px. This is the one
   load-bearing rule kiosk.css used to supply (now suppressed on
   phones); re-supply it — scoped to the admin shell so it can NEVER
   reach the mesero pages' deliberately smaller inputs.
   ===================================================================== */
body.mobile-layout .app-layout input,
body.mobile-layout .app-layout textarea,
body.mobile-layout .app-layout select {
    font-size: 16px;
}

/* =====================================================================
   3. PHASE 2 — PORTRAIT POLISH (read-only glance pages)
   Research confirmed almost every glance-page grid already collapses at
   <=768 (Tabs/Shift/Tables/PaymentDashboard summary/Index main-grid),
   so this section only handles the few rows that did NOT, plus light
   touch/spacing tuning. Conservative by design.
   ===================================================================== */

/* PaymentDashboard: the restaurant picker row is a flex row that never
   stacked — label + <select> get crushed on a 390px screen. Stack it
   and let the select fill the width. */
body.mobile-layout .app-layout .disbursement-selector .selector-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

body.mobile-layout .app-layout .disbursement-selector .form-select {
    max-width: 100%;
}

/* Bootstrap responsive tables (PaymentDashboard breakdown, etc.) — make
   sure wide tables scroll horizontally instead of forcing page-wide
   overflow. Bootstrap's .table-responsive already does this; this is a
   belt-and-suspenders guard for any plain .table that isn't wrapped. */
body.mobile-layout .app-layout .table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Touch-comfort: give primary action buttons a min height so they are
   easy to tap, without disturbing dense kiosk layouts (scoped to phone
   + admin shell only). Mirrors the 44px min-target brand rule. */
body.mobile-layout .app-layout .btn {
    min-height: 44px;
}

/* Page section headers on the glance pages often place a title and
   controls on one flex row; allow them to wrap rather than overflow. */
body.mobile-layout .app-layout .section-header,
body.mobile-layout .app-layout .section-header-row,
body.mobile-layout .app-layout .home-header {
    flex-wrap: wrap;
    gap: 0.5rem;
}
