/* ── Phone / tablet layout ───────────────────────────────────────────────
   Every rule is scoped under html.is-mobile, which the inline device check
   at the top of index.html adds ONLY on phones/tablets -- desktop browsers
   never get the class, so this file changes nothing on desktop (even in a
   narrow window). Many page layouts are inline styles written from JS,
   hence the !important overrides. */

/* New mobile-only controls: hidden unless on a mobile device */
.mobile-nav-btn,
.mobile-nav-backdrop { display: none; }

/* ── Shell ── */
html.is-mobile body { height: 100vh; height: 100dvh; } /* dvh: excludes the browser's address bar */

/* Header: one compact row -- menu button, small logo, then the topbar */
html.is-mobile .mobile-nav-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin: auto 0 auto 8px; flex-shrink: 0;
  border: none; border-radius: 12px; background: #f4f5fa; color: #0f172a;
  font-size: 22px; cursor: pointer;
}
html.is-mobile .app-header-logo { padding: 6px 8px; border-right: none; }
html.is-mobile .app-header-logo img { height: 30px; }
html.is-mobile .topbar { padding: 8px 10px 8px 4px; min-height: 0; gap: 6px; }
html.is-mobile .tb-pills { display: none !important; } /* the menu drawer covers these */
html.is-mobile .tb-uname,
html.is-mobile .tb-chevron { display: none !important; }
html.is-mobile .tb-avatar-stack { display: none !important; }
html.is-mobile .topbar-right { gap: 6px; }
html.is-mobile .tb-add-btn-label { display: none; }
html.is-mobile .tb-add-btn { padding: 9px; border-radius: 50%; }
html.is-mobile .tb-dropdown { position: fixed; left: 8px !important; right: 8px !important; top: 58px; width: auto !important; max-width: none; }

/* Sidebar becomes a slide-in drawer (☰), always showing labels */
html.is-mobile .sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 250px; z-index: 1200;
  transform: translateX(-105%); transition: transform .22s ease;
}
html.is-mobile.nav-open .sidebar { transform: none; }
html.is-mobile .sidebar-inner { width: 250px !important; box-shadow: 10px 0 30px rgba(15,23,42,.18); overflow-y: auto; }
html.is-mobile .sidebar nav { align-items: stretch !important; padding: 16px 12px 16px !important; }
html.is-mobile .sidebar .nav-link {
  flex-direction: row !important; justify-content: flex-start !important;
  width: 100% !important; height: 46px !important; gap: 14px !important; padding: 0 14px !important;
}
html.is-mobile .sidebar .nav-link .nav-label { display: inline-block !important; }
html.is-mobile .sidebar .nav-link.nav-sub { height: 40px !important; padding-left: 38px !important; }
html.is-mobile .sidebar .rail-divider { width: 100% !important; }
html.is-mobile .sidebar-footer { display: none !important; } /* same menu as the topbar profile button */
html.is-mobile.nav-open .mobile-nav-backdrop {
  display: block; position: fixed; inset: 0; z-index: 1100; background: rgba(15,23,42,.45);
}

/* ── Pages ── */
html.is-mobile .page-body { padding: 14px 12px 24px; }
html.is-mobile .page-header {
  flex-wrap: wrap !important; gap: 10px !important; align-items: flex-start !important;
  margin-bottom: 14px !important; padding-bottom: 12px;
}
html.is-mobile .page-header h1 { font-size: 19px; line-height: 1.25; }
html.is-mobile .page-header > div,
html.is-mobile .page-header > button { flex-wrap: wrap; }
html.is-mobile .page-sub { font-size: 13px; }

/* Live Dashboard / Profile two-column panels: full width, stacked, and the
   team list scrolls with the page instead of in its own inner box */
html.is-mobile .dash-columns { flex-direction: column; align-items: stretch !important; gap: 14px; }
html.is-mobile .dash-main-col { width: 100%; }
html.is-mobile .dash-main-col > div { max-height: none !important; overflow-y: visible !important; padding-right: 0 !important; }
html.is-mobile .dash-side-col { flex: 1 1 auto; flex-direction: column; width: 100%; }
html.is-mobile .live-grid { grid-template-columns: 1fr; gap: 14px; }

/* Summary cards: two per row instead of one */
html.is-mobile #dr-summary > div,
html.is-mobile #pr-summary > div {
  display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important;
}
html.is-mobile #dr-summary > div > div,
html.is-mobile #pr-summary > div > div { min-width: 0 !important; padding: 10px 8px !important; }
html.is-mobile .proj-stat-card { min-width: 0; flex: 1 1 calc(50% - 7px); padding: 12px 12px; }

/* Tables: scroll sideways inside their box, first (name) column pinned */
html.is-mobile .users-table-wrap,
html.is-mobile #dr-table-wrap,
html.is-mobile #pr-table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
html.is-mobile table th { white-space: nowrap; }
html.is-mobile #dr-table-wrap tbody td:first-child,
html.is-mobile #pr-table-wrap tbody td:first-child,
html.is-mobile .users-table-wrap tbody td:first-child,
html.is-mobile #dr-table-wrap thead tr:first-child th:first-child,
html.is-mobile #pr-table-wrap thead tr:first-child th:first-child,
html.is-mobile .users-table-wrap thead tr:first-child th:first-child {
  position: sticky; left: 0; z-index: 1; background: #fff;
  box-shadow: 1px 0 0 #e2e8f0;
}

/* Dialogs: full screen */
html.is-mobile .modal-overlay { align-items: stretch !important; }
html.is-mobile .modal {
  width: 100vw !important; max-width: 100vw !important; min-width: 0 !important;
  height: 100dvh; max-height: 100dvh !important; border-radius: 0 !important; overflow-y: auto !important;
}
html.is-mobile .modal .modal-body { max-height: none !important; }
