/* ============================================================
   CapitalSync GodGem — Mobile Responsiveness Retrofit (shared)
   Applies to the .app > .sidebar + .main(.topbar + .pages) portal
   template used by client.html, investor.html, admin.html, crm.html,
   meeting.html, fundraising.html, settings.html.

   Breakpoints intentionally match the ones already established in
   cs-core.css so the whole site feels consistent:
     1024px — tablet: sidebar becomes an off-canvas drawer
      768px — phone/small-tablet: topbar wraps, spacing tightens
      480px — small phone: cards/buttons tighten further

   Load this AFTER cs-core.css (and after each page's own inline
   <style>, if any) so these rules win the cascade.
   ============================================================ */

/* Pin the sidebar to the very top of the viewport at every width.
   cs-core.css's original .sidebar rule is position:fixed;top:60px,
   which assumes a separate 60px-tall global .nav bar above it. These
   portal pages don't have one (they use an in-flow .topbar instead),
   so the sidebar previously started 60px down with nothing reserving
   its width in .main — visually overlapping the first 210-240px of
   every page's content at ALL viewport sizes, not just mobile. Fixing
   the offset is required to build a correct off-canvas drawer, and
   incidentally fixes that pre-existing overlap on desktop too. */
.app > .sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 5000;
  transition: transform .25s ease;
}

/* Hamburger toggle — injected into .topbar by cs-mobile.js.
   Hidden by default; only shown at/below the tablet breakpoint,
   where the sidebar becomes a drawer instead of always-visible. */
.mnav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 8px;
  border: 1px solid var(--bd, var(--bd1, #253550));
  background: var(--bg3, #0D1D35);
  color: var(--t1, #E8EEF8);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
  position: relative;
  z-index: 6000; /* stay above .mnav-backdrop while the drawer is open */
}
.mnav-toggle:hover { border-color: var(--gold, #F5A623); }
.mnav-toggle:focus-visible { outline: 2px solid var(--gold, #F5A623); outline-offset: 2px; }

.mnav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,7,9,.6);
  z-index: 4500;
}
.mnav-backdrop.open { display: block; }

@media (max-width: 1024px) {
  .mnav-toggle { display: inline-flex; }

  .app > .sidebar {
    width: min(300px, 84vw);
    min-width: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 32px rgba(0,0,0,.55);
  }
  .app > .sidebar.open { transform: translateX(0); }

  /* Content always spans full width on tablet/phone — the drawer
     floats above it instead of pushing it over. */
  .app > .main { margin-left: 0 !important; }
}

/* Topbar: wrap instead of overflowing off-screen, and let the
   button row wrap onto its own line(s) rather than clipping. */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto !important;
    min-height: 52px;
    row-gap: 8px;
    padding: 8px 10px !important;
  }
  .topbar > div[style*="margin-left:auto"],
  .topbar > div[style*="margin-left: auto"] {
    margin-left: 0 !important;
    width: 100%;
    flex-wrap: wrap;
  }
  .pages { padding: 0 !important; }
  .page { padding: 12px !important; }
  .sec-h { font-size: 1.15rem !important; }
}

/* Touch target sizing (~44px minimum) for nav items, buttons and
   form inputs while the drawer/touch layout is active. */
@media (max-width: 1024px) {
  .sidebar .nav-item {
    min-height: 44px;
    padding: 11px 16px;
    font-size: 13px;
  }
  .sidebar .nav-sec { padding: 12px 16px 4px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  input, select, textarea,
  .form-input, .form-select,
  .fr input, .fr select, .fr textarea {
    min-height: 44px;
    font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
  }
}

/* Any table not already given an explicit horizontal-scroll wrapper
   still gets one, so wide data tables scroll within themselves
   instead of blowing out the page width. */
table:not([data-cs-scroll-wrapped]) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 480px) {
  .card, .card-stat, .card-glass, .card-gold, .kpi { padding: 12px !important; }
  .btn-lg { padding: 12px 20px; font-size: 14px; }
  .g4, .g3, .g2, .grid-4, .grid-3, .grid-2 { gap: 8px !important; }
}
