/* ============================================================================
   mobile.css — ADDITIVE mobile layer for RestaurantOPS CRM (Restaurant EMS)
   ----------------------------------------------------------------------------
   Native app feel: system-consistent spacing, 44px+ touch targets, safe-area
   insets, bottom tab bar as the primary thumb-first navigation, hamburger =
   full menu (drawer). Loaded AFTER styles.css. Desktop/tablet (>900px) CSS is
   untouched. Shell reflow runs on the plain @media breakpoint (zero JS); the
   drawer / scrim / bottom tabs are progressive enhancement via body.mobile
   (set by mobile.js when the viewport is small AND JS is healthy).
   ========================================================================== */

/* ============================================================================
   1) BASE — spacing, type, touch, native feel (pure CSS, zero JS)
   ========================================================================== */
@media (max-width: 900px) {
  :root { --page-pad: 14px; }
  body { font-size: 14px; }
  button, select, input, textarea { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

  /* ---------- app chrome ---------- */
  .sidebar {
    position: fixed; top: 0; left: 0; right: 0; bottom: auto;
    width: 100%; min-width: 0; height: auto;
    display: flex; flex-direction: row; align-items: center; gap: 4px;
    padding: 6px 8px;
    overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid var(--border);
    z-index: 40;
    background: rgba(10, 14, 20, .96);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
  }
  .sidebar .brand { padding: 2px 10px 2px 4px; flex: 0 0 auto; }
  .brand-mark { width: 30px; height: 30px; font-size: 16px; }
  .brand-name { font-size: 14px; }
  .brand-sub, .sidebar-foot { display: none; }
  #nav { flex-direction: row; gap: 2px; overflow-x: auto; flex: 0 1 auto; }
  .nav-btn { white-space: nowrap; padding: 10px 10px; font-size: 13px; border-radius: 10px; }
  .nav-ico { width: auto; margin-right: 4px; }

  body.authed main { margin-left: 0; }
  main { margin-left: 0; }

  /* ---------- top bar: title row + control row ---------- */
  .topbar {
    left: 0; right: 0; top: 48px;
    padding: 8px 14px; gap: 8px;
    flex-wrap: wrap;
    background: rgba(10, 14, 20, .96);
    backdrop-filter: blur(12px);
  }
  .topbar .controls { flex-wrap: wrap; gap: 8px; width: 100%; }
  .view-title { font-size: 17px; }
  .ctl-label { font-size: 10.5px; }
  select, input[type="search"] { height: 40px; font-size: 14px; }
  #search { width: 100%; min-width: 0; }
  .rolebar { left: 0; right: 0; padding: 8px 14px; }

  #view-container { padding: 112px 14px 96px; }

  /* ---------- content: native stacked rhythm ---------- */
  .page-id { font-size: 9px; margin: 0 0 12px; }
  .card { border-radius: 16px; padding: 16px; }
  .card h3 { font-size: 12px; margin-bottom: 12px; }
  .grid { gap: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 24px; }
  .kpi .label { font-size: 10.5px; }
  .dash-filter { gap: 8px; margin-bottom: 12px; }

  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  td, th { padding: 8px 10px; }

  /* ---------- modals: bottom sheet ---------- */
  #modal-overlay { align-items: flex-end; justify-content: center; padding: 0; }
  .modal { width: 100%; max-width: 100%; margin: 0; min-height: 55vh; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }

  /* ---------- SCHEDULER: vertical native agenda ---------- */
  .sched-wrap { gap: 14px; }
  .sched-head-row { flex-wrap: wrap; gap: 10px; }
  .week-title { font-size: 15px; width: 100%; }
  .sched-actions {
    margin-left: 0; width: 100%;
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  }
  .sched-actions .sched-btn { min-height: 44px; white-space: normal; text-align: center; border-radius: 12px; }
  .sched-pref-row { padding: 4px; }
  .sched-prompt { min-height: 60px; }

  .sched-sum-row { flex-wrap: wrap; gap: 6px 12px; padding: 10px 0; }
  .sched-sum-name { flex: 1 1 100%; }
  .sched-sum-hrs { min-width: 0; flex: 1 1 auto; }
  .sched-sum-off { flex: 1 1 100%; }
  .sched-sum-ot { margin-left: auto; text-align: right; }
  .hrs-bar { min-width: 70px; }

  /* 7-day grid → one day card per row (agenda feel, no side scroll) */
  .sched-week-grid { grid-template-columns: 1fr; overflow-x: visible; }
  .sched-day-col { min-width: 0; border-radius: 16px; padding: 12px; }
  .shift-cell { padding: 9px 10px; border-radius: 10px; }
  .shift-name { font-size: 14px; }
  .shift-time { font-size: 12.5px; }

  .cov-row { display: flex; flex-wrap: wrap; gap: 6px; }
  .cov-meter { flex: 1 1 45%; min-width: 0; }
  .cov-label { font-size: 11px; }

  .week-strip, .strip-cols, .week-strip-labels { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sched-legend { flex-wrap: wrap; gap: 6px; font-size: 11px; }
  .sched-ot-panel { padding: 12px; }
  .sched-alerts h3, .sched-ot-panel h3, .sched-summary h3 { font-size: 11px; }
  .alert-line { font-size: 12.5px; padding: 8px 10px; border-radius: 10px; }

  /* ---------- WhatsApp messenger (stacks already ≤860px; finish the tuning) ---------- */
  .wa-msgr { height: calc(100dvh - 210px); min-height: 460px; border-radius: 16px; }
  .wa-msgr-list, .wa-thread-body { -webkit-overflow-scrolling: touch; }
  .wa-thread-body { max-height: none; }

  /* ---------- stat cards & misc drill-down grids ---------- */
  .staff-row, .schedule-row { flex-wrap: wrap; }
}

/* ============================================================================
   2) HAMBURGER — hidden by default; appears when mobile.js sets body.mobile
   ========================================================================== */
#mobile-toggle {
  display: none;
  width: 44px; height: 44px; flex: 0 0 44px;
  align-items: center; justify-content: center;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 20px; line-height: 1; cursor: pointer;
  padding: 0; margin: 0 2px 0 0;
}
#mobile-toggle:hover { border-color: var(--amber); color: var(--amber); }
#mobile-toggle:active { transform: scale(.94); }
body.mobile #mobile-toggle { display: inline-flex; }

/* ============================================================================
   3) DRAWER + SCRIM (JS-injected). Drawer = the COMPLETE menu; #nav clone.
   ========================================================================== */
#mobile-nav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(84vw, 320px);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  transform: translate3d(-100%, 0, 0);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  z-index: 96;
  overflow-y: auto;
  padding: 20px 12px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 2px;
  visibility: visible;
  pointer-events: none;
  will-change: transform;
  -webkit-overflow-scrolling: touch;
}
body.mobile-nav-open #mobile-nav { transform: translate3d(0, 0, 0); pointer-events: auto; }

#mobile-scrim {
  position: fixed; inset: 0;
  background: rgba(4, 7, 12, .6);
  opacity: 0; pointer-events: none;
  transition: opacity .24s ease;
  z-index: 94;
  visibility: visible;
}
body.mobile-nav-open #mobile-scrim { opacity: 1; pointer-events: auto; }

#mobile-nav .mnav-head {
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); padding: 4px 8px 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

#mobile-nav .mnav-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 46px;
  background: none; border: none; border-radius: 12px;
  color: var(--muted); font-size: 15px; font-weight: 500;
  padding: 0 12px; cursor: pointer; text-align: left;
}
#mobile-nav .mnav-btn:hover { background: #22344d; color: var(--text); }
#mobile-nav .mnav-btn.active { background: rgba(255, 215, 0, .12); color: #ffd700; font-weight: 700; }
#mobile-nav .mnav-btn .mnav-ico { font-size: 17px; width: 24px; text-align: center; }

/* ============================================================================
   4) BOTTOM TAB BAR — the primary navigation (native pattern). Shown when
      mobile.js set body.mobile. 5 thumb-first destinations; the hamburger
      above is the complete menu.
   ========================================================================== */
#mobile-bottomnav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 70;
  background: rgba(10, 14, 20, .94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}
#mobile-bottomnav .bnav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  flex: 1; min-height: 56px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 10px;
  padding: 4px 2px;
  border-radius: 12px;
}
#mobile-bottomnav .bnav-btn .bico { font-size: 21px; line-height: 1; }
#mobile-bottomnav .bnav-btn.active { color: #ffd700; background: rgba(255, 215, 0, .08); }
#mobile-bottomnav .bnav-btn.active .bico { transform: translateY(-1px); }
body.mobile #mobile-bottomnav { display: flex; }

/* ============================================================================
   5) JS ENHANCEMENT — when mobile.js ran and set body.mobile: hide the top
      nav-strip fallback, restore the hamburger + drawer + bottom tabs.
   ========================================================================== */
body.mobile .sidebar { display: none; }
body.mobile .topbar { top: 0; padding: 8px 14px; }
body.mobile #view-container { padding: 66px 14px 90px; }
body.mobile .rolebar { display: none; }