/* ── PickleHub responsive layout (docs/RESPONSIVE_DESIGN_PLAN.md) ── */

/* ── Mobile bottom navigation (< lg) ── */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-chrome);
  height: var(--bottom-nav-h, 56px);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--pn);
  border-top: 0.5px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.mobile-nav-item i { font-size: 20px; line-height: 1; }
.mobile-nav-item.on { color: var(--py); font-weight: 600; }
.mobile-nav-item:hover { color: rgba(255, 255, 255, 0.9); }

/* ── Phone ── */
@media (max-width: 767px) {
  body { padding: 0; align-items: stretch; }
  #app-shell { max-width: none; min-height: 100dvh; }
  .shell {
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .topbar { padding: 10px 12px; }
  .tb-title { font-size: 14px; }
  .tb-user-role { display: none; }
  .view {
    padding: 12px;
    padding-bottom: calc(var(--bottom-nav-h, 56px) + 12px + env(safe-area-inset-bottom, 0));
  }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .seg {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .seg-b { flex-shrink: 0; min-height: 44px; }
  .panel { width: 100%; max-width: 100%; }
  .pl-layout .sb-bar,
  .module-filters-group { width: 100%; }
  .overlay {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top, 0));
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    margin: 0;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }
  .modal .panel-body,
  .modal .m-body,
  #createOverlay .create-event-body,
  .event-results-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }
  .m-actions,
  #createOverlay .m-actions,
  .modal .panel-actions,
  .event-results-foot {
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 2;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
  }
  .auth-screen {
    padding: 0;
    align-items: stretch;
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
  }
  .auth-card {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
  }
  .auth-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: max(24px, env(safe-area-inset-bottom, 0) + 16px);
    padding-bottom: max(28px, env(safe-area-inset-bottom, 0) + 12px);
  }
  .ob-card {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: max(24px, env(safe-area-inset-bottom, 0) + 16px);
  }
}

@media (max-width: 767px) and (max-height: 740px) {
  .auth-hero { padding: 22px 20px 18px; }
  .auth-logo { width: 44px; height: 44px; margin-bottom: 10px; }
  .auth-app-name { font-size: 20px; }
  .auth-body { padding: 20px; }
  .auth-sub { margin-bottom: 18px; }
  .auth-verify-banner { margin-bottom: 10px; }
  .stay-row { margin-bottom: 14px; }
}

/* ── Compact nav (< lg) ── */
@media (max-width: 520px) {
  .tb-user-text { display: none; }
  .tb-user-chip { padding: 2px; max-width: none; }
  .tb-edit-profile-lbl { display: none; }
  .tb-edit-profile-btn { padding: 6px 10px; min-width: 36px; justify-content: center; }
}

@media (min-width: 1024px) {
  /* Desktop: dim/lock main content only — sidebar stays clickable (modularity / E2E) */
  #evPanelOverlay,
  #plPanelOverlay,
  #facPanelOverlay {
    left: var(--sidebar-w, 210px);
  }
}

@media (max-width: 1023px) {
  .sb { display: none; }
  .mobile-nav { display: flex; }
  .shell {
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100dvh;
  }
  .view {
    padding-bottom: calc(var(--bottom-nav-h, 56px) + 16px + env(safe-area-inset-bottom, 0));
  }
  #view-groups {
    overflow-x: hidden;
    max-width: 100%;
  }
  .panel { width: min(100%, 480px); }
  .fac-schedule,
  .fac-cal-scroll-wrap,
  #fac-schedule-week-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fac-week-hd,
  .fac-week-row { min-width: 640px; }
}

/* ── Tablet ── */
@media (min-width: 768px) and (max-width: 1023px) {
  body { padding: var(--app-gutter, 16px); }
  .shell { border-radius: 12px; }
}

/* ── Laptop+ — full-bleed shell (no floating card / side gutters) ── */
@media (min-width: 1024px) {
  body {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  #app-shell {
    max-width: 100%;
  }
  .shell {
    max-width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .view { padding: 16px 20px; }
}

/* ── Phase 3: split-pane (xl+) — disabled; panels share #app-shell with many overlays (see responsive.js) ── */
@media (min-width: 1280px) {
  #app-shell.ph-split-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 36%);
    align-items: stretch;
    gap: 0;
    min-height: min(880px, calc(100dvh - 40px));
  }
  #app-shell.ph-split-active .shell {
    grid-column: 1;
    min-height: 0;
    border-radius: 16px 0 0 16px;
    border-right: none;
  }
  #app-shell.ph-split-active .mobile-nav { display: none; }

  #app-shell.ph-split-ev #evPanel,
  #app-shell.ph-split-fac #facPanel,
  #app-shell.ph-split-pl #plPanel {
    grid-column: 2;
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    height: auto;
    min-height: min(760px, calc(100dvh - 40px));
    max-height: calc(100dvh - 40px);
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.06);
    border-radius: 0 16px 16px 0;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    border-left: none;
  }

  #app-shell.ph-split-ev #evPanelOverlay,
  #app-shell.ph-split-fac #facPanelOverlay,
  #app-shell.ph-split-pl #plPanelOverlay {
    display: none !important;
  }

  #app-shell.ph-split-active #evPanel:not(.open),
  #app-shell.ph-split-active #facPanel:not(.open),
  #app-shell.ph-split-active #plPanel:not(.open) {
    display: none;
  }
}

/* ── Touch targets ── */
@media (max-width: 1023px) {
  .btn,
  .filter-toggle-btn,
  .fc,
  .vc,
  .panel-tab,
  .panel-close {
    min-height: 44px;
    min-width: 44px;
  }
  .btn { min-width: auto; padding-top: 10px; padding-bottom: 10px; }
  .panel-close { width: 44px; height: 44px; }
}

/* ── Modals (all sizes) ── */
.modal,
.coach-edit-modal,
.pl-safety-modal,
.fac-picker-modal {
  max-height: min(90dvh, calc(100dvh - 32px));
}
.modal,
.pl-safety-modal,
.fac-picker-modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.coach-edit-modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal .m-body,
.ev-invite-status-modal-body,
#createOverlay .create-event-body,
.coach-edit-body,
.pl-safety-modal .pl-safety-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .mobile-nav-item,
  .btn,
  .ec,
  .fac-card,
  .pc {
    transition: none !important;
  }
}
