/* ======================================================================
   Mobile shell — native-feeling layout for /mobile pages.
   Loaded AFTER css/style.css: reuses all of style.css's component styles
   (cards, tables, modals, badges, forms, buttons) and only replaces the
   outer shell (sidebar+topbar) with a top app bar + bottom tab bar.
   ====================================================================== */

html, body { height: 100%; }

.m-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  container: app / inline-size;
}

/* Pill-shaped primary/secondary buttons everywhere on mobile — a structural,
   not color, borrowing from the reference layout. Same colors as web. */
.m-shell .btn-primary,
.m-shell .btn-secondary,
.m-login-shell .btn-primary,
.m-login-shell .btn-secondary {
  border-radius: 999px;
}

/* Bolder page headings on mobile, matching the reference's typographic
   scale — structure only, still var(--text)/var(--primary), not new colors. */
.m-shell .view-head h2 { font-size: 23px; letter-spacing: -.3px; }

/* Lift toasts above the floating bottom tab bar, and let them span the
   width on phones instead of the desktop-style bottom-right stack. */
.m-view #toastContainer {
  left: 16px;
  right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: none;
}

/* Bottom-sheet modals on every mobile page: slide up from the bottom edge
   with rounded top corners, instead of a centered desktop-style dialog.
   Scoped to .m-view so /web is completely untouched. The image lightbox is
   deliberately excluded — it's a fullscreen photo viewer, not a form, and
   stays centered like it already is. */
.m-view .modal-overlay {
  align-items: flex-end;
  padding: 0;
}
.m-view .modal {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  max-height: 88vh;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: m-sheet-up .2s ease-out both;
}
@keyframes m-sheet-up {
  from { transform: translateY(16px); opacity: 0; }
}

/* ---------- Top app bar ----------
   Deliberately minimal, matching the reference: brand on the left, a single
   tappable user-chip on the right that opens the More menu. No page title
   (the page's own .view-head h2 already carries that), no inline search —
   the ID quick-search lives inside the More menu instead. */
.m-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.m-brand-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.m-brand-row .brand-icon { margin: 0; }
.m-brand-name { font-size: 16px; font-weight: 700; color: var(--text); }

/* the topbar + More-menu user-chip is now a <button>, reusing the same
   .user-chip look web's sidebar footer already has */
button.user-chip {
  font: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
button.user-chip svg { width: 15px; height: 15px; }

.m-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.m-icon-btn:hover { background: var(--primary-soft); border-color: var(--primary); }

.m-search-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
/* common.js stuffs "🔍 Search" text into #idSearchBtn's innerHTML (same as
   the web topbar's full-width button) — give it room to say that instead of
   the fixed 34px icon-only square the other top-bar buttons use. */
.m-search-row .m-icon-btn {
  width: auto;
  height: auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  gap: 4px;
}
.m-search-row .m-icon-btn svg { width: 14px; height: 14px; vertical-align: -2px; }
.m-search-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
}

/* ---------- Main content ---------- */
.m-shell .dash-main {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 16px 14px calc(108px + env(safe-area-inset-bottom));
}

/* ---------- Bottom tab bar: floating pill, not edge-to-edge ---------- */
.m-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 480px);
  display: flex;
  align-items: center;
  padding: 6px;
  gap: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.m-bottom-nav .nav-item {
  flex: 1;
  min-width: 0;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--muted);
  text-decoration: none;
  border: none;
  background: none;
  margin: 0;
}
.m-bottom-nav .nav-item .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 28px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.m-bottom-nav .nav-item .nav-icon svg { width: 18px; height: 18px; }
.m-bottom-nav .nav-item .m-nav-label {
  font-size: 10px;
  font-weight: 600;
}
.m-bottom-nav .nav-item:hover .nav-icon { background: var(--primary-soft); color: var(--primary-dark); }
.m-bottom-nav .nav-item.active { color: var(--primary-dark); }
.m-bottom-nav .nav-item.active .nav-icon { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }

/* ---------- More menu (modal, shared across every mobile page) ---------- */
.m-menu-body { display: flex; flex-direction: column; }
.m-menu-nav { display: flex; flex-direction: column; gap: 2px; }
.m-menu-nav .nav-item.m-menu-link {
  display: flex !important;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  background: none;
  border: none;
}
.m-menu-nav .nav-item.m-menu-link .nav-icon svg { width: 18px; height: 18px; color: var(--muted); }
.m-menu-nav .nav-item.m-menu-link:hover { background: var(--surface-alt); }
.m-menu-nav .nav-item.m-menu-link.active { background: var(--primary-soft); color: var(--primary-dark); }
.m-menu-nav .nav-item.m-menu-link.active .nav-icon svg { color: var(--primary-dark); }
.m-more-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 18px 0 6px;
}
.m-more-section-label:first-child { margin-top: 0; }

/* ---------- Login (mobile) — top-aligned, app-native layout ---------- */
.m-login-body.login-body { align-items: flex-start; }
.m-login-shell {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px 32px;
  background: var(--bg);
}

.m-login-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.m-login-header .brand-icon { margin: 0; }
.m-login-header-text h1 { font-size: 19px; margin: 0; }
.m-login-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.m-login-card.login-card {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}
.m-login-title { font-size: 25px; font-weight: 800; color: var(--text); margin: 0 0 4px; }
.m-login-subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

.m-input-field label { font-size: 12.5px; }
.m-input-icon-wrap { position: relative; display: flex; align-items: center; }
.m-input-icon-wrap input { padding-left: 40px; }
.m-input-icon-wrap input#password { padding-right: 40px; }
.m-input-icon {
  position: absolute;
  left: 13px;
  font-size: 15px;
  opacity: .6;
  pointer-events: none;
}
.m-input-trailing-btn {
  position: absolute;
  right: 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.m-input-trailing-btn:hover { color: var(--text); }

.m-login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 15px;
  padding: 13px 16px;
}
.m-login-submit-arrow { font-weight: 400; }

.m-demo-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.m-demo-box strong { color: var(--text); }

.m-login-footer {
  text-align: center;
  color: var(--muted-dim);
  font-size: 11.5px;
  margin-top: 28px;
}

/* ======================================================================
   Wide screens (tablet landscape, laptop, desktop): the mobile view is
   still reachable at /mobile — someone can open it directly, or switch to
   it from /web — so it needs to look intentional there too, not stretch
   edge to edge. Constrain it to a phone-width column and center it; the
   floating bottom tab bar already centers itself with the same left:50% /
   translateX(-50%) technique, so it lines up under the column automatically
   with no extra positioning math.
   ====================================================================== */
@media (min-width: 560px) {
  body.m-view {
    background: var(--surface-alt);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* The frame's own height (below) caps at 844px, so on a viewport taller
       than 844px + margin it no longer fills the available space — these
       two custom properties compute how much empty space is left above/
       below it once centered, so position: fixed overlays (the bottom tab
       bar, the toast container) can still line up with its actual edges
       at any viewport height instead of assuming a constant offset. */
    --frame-h: min(844px, calc(100vh - 48px));
    --frame-gap: calc((100vh - var(--frame-h)) / 2);
    /* Frame's INNER screen is 390px outer width − 12px bezel × 2 = 366px;
       this is that inner area's horizontal distance from the viewport edge
       once centered, used to keep position: fixed overlays (modals) inside
       the visible screen, not just inside the frame's outer silhouette
       (which would let them cover the bezel itself). */
    --frame-left: calc((100vw - 366px) / 2);
  }
  /* The login body sets align-items: flex-start elsewhere (for the native,
     top-aligned layout on an actual phone) — re-centered here, at equal
     selector specificity, so it wins by source order within this
     wide-screen-only breakpoint. */
  .m-login-body.login-body {
    align-items: center;
  }

  /* Phone-frame treatment on wide screens — dimensions matched exactly to
     the reference app's own .m-phone rule (D:/restaurant_app, assets/css/
     style.css, the "@media (min-width: 521px)" device-frame block): 390px
     wide, height min(844px, viewport − 48px), 12px bezel, 54px corners,
     a 110×30 notch. Only the colors differ — the app's own border/shadow
     tokens throughout, never the reference's literal brown/black bezel. */
  .m-shell,
  .m-login-shell {
    width: 390px;
    max-width: none;
    margin: 0;
    flex-shrink: 0;
    min-height: 0;
    height: var(--frame-h);
    overflow: hidden auto;
    border: 12px solid var(--border-strong);
    border-radius: 54px;
    box-shadow: var(--shadow-md);
    position: relative;
    scrollbar-width: none; /* Firefox */
  }
  /* A real desktop scrollbar inside the frame (reserving ~15-20px of width)
     breaks the clean, seamless device-screen look — reclaimed by hiding it
     while keeping the scroll functionality that the fixed-height frame
     above depends on. */
  .m-shell::-webkit-scrollbar,
  .m-login-shell::-webkit-scrollbar {
    display: none;
  }
  /* .m-shell paints its own background and clips naturally at the bottom;
     only the topbar (a child with its own square background) needs its top
     corners rounded to match the frame instead of using overflow:hidden on
     .m-shell, which would turn it into a new sticky-positioning container
     and break the topbar's position: sticky. */
  .m-shell .m-topbar {
    border-radius: 42px 42px 0 0;
  }
  .m-login-shell {
    padding-top: 56px;
  }
  .m-shell::before,
  .m-login-shell::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    height: 30px;
    border-radius: 20px;
    background: var(--border-strong);
    z-index: 25;
    pointer-events: none;
  }

  /* #toastContainer is appended to <body>, not inside .m-shell, so its
     fixed positioning needs the same centering treatment as the shell and
     the bottom tab bar — otherwise it stays full-viewport-width while
     everything else is a narrow centered card. */
  body.m-view #toastContainer {
    left: 50%;
    right: auto;
    bottom: calc(var(--frame-gap) + 12px + 73px + 10px);
    transform: translateX(-50%);
    width: min(calc(100% - 32px), 342px);
  }

  /* Bottom tab bar docked flush inside the frame on wide screens, matching
     the device-mockup reference: an edge-to-edge bar sitting right at the
     bottom of the "screen," not the floating inset pill used on an actual
     phone (where there's no bezel to dock against). This stays
     position: fixed (viewport-relative, not .m-shell-relative) on purpose:
     .m-shell is the element that scrolls internally, and a descendant of a
     scrolling element — even position: absolute — still scrolls with it,
     since its containing block only fixes its coordinate origin, not its
     exemption from the ancestor's scroll offset. Only position: fixed
     (anchored to the viewport, since .m-shell has no transform) escapes
     that. Its "bottom" offset uses the --frame-gap variable (above) instead
     of a constant, since the frame is centered and only fills the full
     viewport height up to its 844px cap. */
  .m-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(var(--frame-gap) + 12px);
    transform: translateX(-50%);
    width: 366px; /* frame's inner content width: 390px outer − 12px bezel × 2 */
    padding: 8px 6px;
    border: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 0 0 42px 42px;
    box-shadow: none;
    box-sizing: border-box;
  }

  /* Modals (the More menu, add/edit forms, the lightbox) are position:
     fixed and appended outside .m-shell, so without this they cover the
     full browser window instead of staying inside the phone mockup —
     constrained here to the frame's own bounds using the same --frame-gap/
     --frame-left variables as the tab bar and toast above. */
  .m-view .modal-overlay {
    /* --frame-gap/--frame-left (above) locate the frame's OUTER edge; the
       overlay needs the INNER screen edge, 12px (the bezel width) further
       in on every side — without this it was extending over the bezel
       itself instead of staying within the visible screen. */
    top: calc(var(--frame-gap) + 12px);
    left: var(--frame-left);
    right: var(--frame-left);
    bottom: calc(var(--frame-gap) + 12px);
    border-radius: 42px; /* inner screen curve, not the bezel's outer 54px */
  }
  .m-view .modal {
    /* Capped at 88% of the inner screen height (matching the reference
       app's own .modal-box max-height: 88% convention), not the full inner
       height — a modal whose content needs scrolling would otherwise grow
       to fill nearly the entire frame, leaving no gap above it to show the
       page underneath, which reads as a full-screen page takeover rather
       than a bottom-sheet overlay. */
    max-height: calc((var(--frame-h) - 24px) * 0.88);
    /* A modal tall enough to reach the frame's bottom edge (the More menu,
       long forms) otherwise keeps its square bottom-sheet corners, which
       poke out past the frame's curved bezel instead of sitting inside it
       — rounded to match the topbar/tab bar's 42px inner curve. The
       bottom-RIGHT corner is the exception: a vertical scrollbar is always
       a straight bar flush against that edge, so rounding it just moves
       the visual conflict from "square corner past the bezel" to
       "scrollbar cutting through the curve" instead of fixing it — left
       square on purpose, which only costs a small, much less noticeable
       seam against the frame's curve on that one corner. */
    border-radius: 20px 20px 0 42px;
    /* Unlike .m-shell's scrollbar (hidden outright — the bottom tab bar is
       always visible as its own navigation cue), a modal has no other
       affordance telling the viewer there's more content below on a short
       window: hiding this scrollbar entirely made the More menu look like
       it was simply cut off after "Dark Mode," with Account/Logout
       unreachable-looking even though scrolling still worked. Shown here
       instead, as a slim themed bar rather than the bulky native one. */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
  }
  .m-view .modal::-webkit-scrollbar {
    width: 6px;
  }
  .m-view .modal::-webkit-scrollbar-track {
    background: transparent;
  }
  .m-view .modal::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
  }
}
