/* ============================================================
   RAGADO OS — mobile.css
   Pure mobile-responsive additions. Zero desktop-style changes.
   All rules are inside @media (max-width:...) blocks EXCEPT the
   two base classes (.mob-menu-btn, .mob-overlay) which are
   display:none on desktop and shown only on mobile.
   ============================================================ */

/* ── Hamburger button: always in DOM, hidden on desktop ───────────── */
.mob-menu-btn {
  display: none;
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--ease), color var(--ease);
}
.mob-menu-btn:hover { background: var(--surface-3); color: var(--text); }
.mob-menu-btn svg { width: 20px; height: 20px; display: block; }

/* ── Sidebar backdrop overlay ─────────────────────────────────────── */
.mob-overlay {
  display: none;
  position: fixed; inset: 0;
  z-index: 49;
  background: rgba(8,10,28,.55);
  animation: ovfade .16s ease;
}
.mob-overlay.active { display: block; }

/* ================================================================
   TABLET — ≤ 900px
   Collapse sidebar, keep two-column content where possible
   ================================================================ */
@media (max-width: 900px) {
  /* App shell: sidebar comes out of grid, content fills width */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }

  /* Sidebar: off-canvas slide-in */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.16,1,.3,1);
  }
  .sidebar.mob-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }

  /* Topbar + main: span full single column */
  .topbar { grid-column: 1; padding: 0 14px; gap: 8px; }
  /* DO NOT set overflow-x:hidden here — mixing overflow-x:hidden with
     overflow-y:auto on the same element blocks touch/swipe scroll on
     mobile Chrome/WebKit. Table overflow is handled by JS auto-wrapping
     tables in .tbl-scroll divs (boot.js MutationObserver). */
  .main   { grid-column: 1; padding: 16px; }

  /* Show hamburger */
  .mob-menu-btn { display: flex; }

  /* Hide breadcrumb search-text; keep icon + kbd */
  .gs-text { display: none; }
  .global-search {
    margin-left: 0;
    flex: 1;
    max-width: none;
    gap: 8px;
  }

  /* Top actions: tighten */
  .top-actions { gap: 4px; }

  /* Page head: wrap actions to new row */
  .page-head { flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
  .page-head .page-title { font-size: var(--text-xl); }
  .page-head-actions { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 6px; }

  /* Cards: slightly less padding */
  .card-pad  { padding: 14px 16px; }
  .card-head { padding: 12px 16px; }

  /* Tiles (complaints, overview stats) → 2 cols */
  .tiles { grid-template-columns: repeat(2,1fr) !important; }

  /* KPI grid (dashboard) → 2 cols */
  .kpi-grid { grid-template-columns: repeat(2,1fr) !important; }

  /* Two-column side-panel layouts → single column */
  .two, .two-wide { grid-template-columns: 1fr !important; }

  /* Split grid already uses auto-fit/minmax — force single col for narrow */
  .split { grid-template-columns: 1fr !important; }

  /* DISP stepper: horizontal scroll so steps don't collapse */
  .disp-stepper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    flex-wrap: nowrap;
  }
  .disp-step { min-width: 80px; }
  .ds-l { font-size: 10px; max-width: 80px; }

  /* Wizard stepper: scroll */
  .wizard {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px;
    flex-wrap: nowrap;
  }
  .wstep { min-width: 84px; }

  /* Modal: bottom-sheet on mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    justify-content: stretch;
  }
  .modal {
    max-width: 100% !important;
    width: 100%;
    margin: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
  }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    max-height: none;
  }

  /* frow: stack form columns */
  .frow { grid-template-columns: 1fr !important; }

  /* role-grid, up-grid: single col */
  .role-grid { grid-template-columns: 1fr !important; }
  .up-grid   { grid-template-columns: 1fr !important; }

  /* Toast: full width */
  .toast-wrap { left: 12px; right: 12px; max-width: none; }

  /* ── Table-level scroll ─────────────────────────────────────────────
     boot.js auto-wraps every table.tbl (that isn't already inside
     .tbl-scroll) in a <div class="tbl-scroll"> on mobile.
     These rules make those wrappers — and any hand-coded .tbl-scroll
     divs — scroll the table horizontally at table level, not page level. */
  .tbl-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;           /* ensure it's a block scroll container */
    width: 100%;
  }
  /* tables inside a scroll wrapper take natural content width */
  .tbl-scroll table.tbl {
    width: auto;
    min-width: 100%;          /* at least fill the wrapper */
  }
  /* Modal body: tables inside modals also need to scroll */
  .modal-body {
    overflow-x: auto;
  }
}

/* ================================================================
   PHONE — ≤ 480px
   Single column everything, minimal padding
   ================================================================ */
@media (max-width: 480px) {
  .main   { padding: 10px; }
  .topbar { padding: 0 10px; gap: 4px; }

  /* Cards */
  .card-pad  { padding: 12px 12px; }
  .card-head { padding: 10px 12px; }

  /* Tiles: single column */
  .tiles    { grid-template-columns: 1fr !important; }
  .kpi-grid { grid-template-columns: 1fr !important; }

  /* Hide breadcrumbs to recover width */
  .crumbs { display: none; }

  /* Search: icon only (text hidden via .gs-text above) */
  .global-search {
    flex: 0 0 36px;
    padding: 0;
    justify-content: center;
    min-width: 36px;
    overflow: hidden;
  }
  .global-search .kbd { display: none; }

  /* Buttons: smaller */
  .btn { padding: 7px 10px; font-size: var(--text-sm); }

  /* Modal: tighter */
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px 14px; }
  .modal-foot { padding: 12px 14px; }

  /* Tables: tighter cells */
  .tbl th, .tbl td { padding: 9px 10px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 12px; }

  /* Page title */
  .page-head .page-title { font-size: var(--text-lg); }

  /* DISP stepper: more compact */
  .disp-step { min-width: 64px; }
  .ds-l { font-size: 9px; }

  /* Toast */
  .toast-wrap { left: 8px; right: 8px; bottom: 12px; }
  .toast { padding: 11px 12px; gap: 9px; }

  /* fgrid in modals */
  .fgrid, .fgrid-3 { grid-template-columns: 1fr !important; }
}
