/* ==========================================================================
   NovaPush — Responsive / UI polish layer
   Loaded AFTER app.css, so every rule here safely refines the base design.
   Desktop: balanced wide-screen layout + larger, more readable typography.
   Mobile:  slide-in sidebar drawer, bigger touch targets, no h-overflow.
   ========================================================================== */

/* ---------- global safety: never scroll sideways ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas, table { max-width: 100%; }

/* ---------- DESKTOP: wide-screen balance ---------- */
@media (min-width: 1101px) {
  .main-content {
    max-width: 1500px;
    padding-left: clamp(24px, 3vw, 52px);
    padding-right: clamp(24px, 3vw, 52px);
  }
  .topbar h1 { font-size: clamp(22px, 1.7vw, 30px); letter-spacing: -.02em; }
  .topbar { align-items: center; gap: 18px; }
  .card, .panel, .surface { border-radius: 16px; }
  table { font-size: 14.5px; }
  table th { white-space: nowrap; }
  .sidebar { width: 262px; }
  .sidebar .primary-nav a { padding: 10px 12px; border-radius: 11px; font-size: 14.5px; }
}
@media (min-width: 1700px) {
  .main-content { max-width: 1640px; margin-left: 262px; margin-right: 0; }
}
@media (min-width: 1902px) {
  /* Center the readable content in the space to the right of the fixed rail. */
  .main-content { width: 1640px; margin-left: calc(50vw - 689px); }
}

/* ---------- TABLET: keep grids from collapsing awkwardly ---------- */
@media (min-width: 761px) and (max-width: 1100px) {
  .main-content { padding-left: 20px; padding-right: 20px; }
  .stat-grid, .kpi-grid, .grid-3, .grid-4,
  [class*="cols-3"], [class*="cols-4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .topbar h1 { font-size: 21px; }
}

/* ---------- MOBILE ---------- */

/* hamburger button lives in the topbar, desktop-hidden */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line, rgba(255,255,255,.12));
  background: rgba(255,255,255,.04);
  color: #dce6f5;
  font-size: 19px;
  line-height: 1;
  flex: 0 0 auto;
}
.nav-toggle:active { transform: scale(.96); }

.nav-scrim {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, .62);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
  z-index: 40;
}
body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

@media (max-width: 760px) {
  #owner-user-access .table-responsive { overflow: visible; }
  #owner-user-access table,
  #owner-user-access tbody,
  #owner-user-access tr,
  #owner-user-access td { display: block; width: 100%; }
  #owner-user-access thead { display: none; }
  #owner-user-access tbody tr { padding: 14px 0; border-bottom: 1px solid var(--line, rgba(255,255,255,.1)); }
  #owner-user-access tbody td { padding: 6px 12px; border: 0; }
  #owner-user-access tbody td:first-child { padding-top: 10px; }
  #owner-user-access tbody td:not(:first-child) { display: inline-block; width: auto; padding: 4px 8px 4px 12px; font-size: 13px; }
  #owner-user-access .owner-user-access-actions .btn { min-height: 42px; padding: 9px 14px; }
  .page-intro > div:last-child > a[href="#owner-user-access"] { color: #07111d; font-weight: 700; }
  .nav-toggle { display: inline-flex; }

  /* sidebar becomes a slide-in drawer instead of being hidden */
  .sidebar {
    display: flex !important;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    max-width: 310px;
    padding: 20px 16px 22px;
    background: rgba(8, 13, 24, .98);
    border-right: 1px solid var(--line, rgba(255,255,255,.1));
    transform: translateX(-104%);
    transition: transform .26s cubic-bezier(.22,.7,.3,1);
    z-index: 50;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 24px 0 60px rgba(0,0,0,.5); }

  .sidebar .primary-nav a,
  .sidebar .profile-mini {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
  }

  /* topbar: compact, single tidy row */
  .main-content { padding: 16px 14px 96px; }
  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin-bottom: 14px;
  }
  .topbar > div:first-of-type { min-width: 0; flex: 1 1 auto; }
  .topbar .eyebrow { font-size: 9.5px; letter-spacing: .12em; }
  .topbar h1 {
    font-size: 18px;
    line-height: 1.25;
    margin: 2px 0 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar-actions { flex: 0 0 auto; gap: 8px; display: flex; align-items: center; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 12.5px; white-space: nowrap; }

  /* comfortable tap targets everywhere */
  .btn, .icon-button, button, select, input, textarea { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  input, select, textarea { font-size: 16px; } /* stops iOS zoom-on-focus */

  /* cards / stats stack cleanly */
  .stat-grid, .kpi-grid, .grid-2, .grid-3, .grid-4,
  [class*="cols-2"], [class*="cols-3"], [class*="cols-4"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  .card, .panel, .surface { border-radius: 14px; padding: 14px !important; }

  /* tables scroll instead of breaking the layout */
  .table-responsive, .table-wrap, .card > table, .panel > table { overflow-x: auto; }
  table { display: block; overflow-x: auto; white-space: nowrap; font-size: 13px; }

  /* calendar grid is wider than viewport — let it scroll horizontally inside its panel */
  .calendar-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .calendar-grid { min-width: 560px; }

  /* any panel/card that might contain wide content scrolls instead of breaking layout */
  .panel, .card, .surface { max-width: 100%; }
  .schedule-layout > *, .upload-layout > *, .setup-grid > *, .settings-layout > *, .lower-grid > * { min-width: 0; }

  /* long strings (emails, URLs, filenames) wrap */
  .muted, p, li, td, .card small { overflow-wrap: anywhere; }

  /* bottom nav: notch-safe + evenly spaced */
  .mobile-nav {
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a { flex: 1 1 0; font-size: 17px; }
  .mobile-nav a small { font-size: 9px; }
  .mobile-nav .mobile-create {
    flex: 0 0 auto;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
  }

  .site-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .site-footer-inner { flex-wrap: wrap; gap: 10px; justify-content: center; text-align: center; }
}

@media (max-width: 400px) {
  .topbar-actions .btn { font-size: 0; padding: 8px 11px; }
  .topbar-actions .btn::before { content: "+"; font-size: 16px; }
}

/* Per-account OAuth and publish readiness indicators. */
.account-health { display: block; margin-top: 4px; font-weight: 600; }
.account-health.health-ready { color: #86efac; }
.account-health.health-attention { color: #fbbf24; }
.account-health-message { display: block; max-width: 620px; margin-top: 3px; color: #fde68a; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .conn-actions form, .conn-actions > a { flex: 1 1 auto; }
  .conn-actions .btn { min-height: 42px; width: 100%; }
}
