/* Admin app shell — a sidebar of grouped navigation, a slim topbar with
   the view title + league-level status/actions, and the content column.
   Only the signed-in workspace uses it; the public schedule, landing,
   coach and volunteer pages keep the plain .app-head header (views.css).
   The content column's .view stays the scroll container — the Table
   view's sticky headers depend on that. */

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

/* ---- sidebar ---- */
/* The sidebar doesn't scroll itself — that would clip the league menu at
   its edge. The nav list is the scroll region; the switcher and the foot
   stay put. */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sb-bg);
  color: var(--sb-text-strong);
  border-right: 1px solid var(--sb-border);
  padding: 10px 10px 12px;
}
.sidebar__league { padding: 0 0 4px; }

/* league switcher: the sidebar's title row; a menu when signed in */
.league-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 8px 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
  text-align: left;
}
.league-switch::-webkit-details-marker { display: none; }
.league-switch:hover { background: var(--sb-hover); }
.league-switch--static { cursor: default; }
.league-switch--static:hover { background: none; }
.league-switch__name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.league-switch .ico { flex: none; color: var(--sb-label); }
.sidebar .menu[open] .league-switch { background: var(--sb-active); }
/* The league list grows to its longest name and may overlap the content
   column; the cap keeps it on screen on phones. Long names ellipsize. */
/* the list floats over the content column, so it takes the page's
   colours, not the sidebar's — a dark sidebar on a light theme otherwise
   paints light text on a light popover */
.sidebar .menu__list {
  left: 0;
  right: auto;
  color: var(--text);
  width: max-content;
  min-width: 100%;
  max-width: min(460px, calc(100vw - 40px));
  z-index: 50;
}
.sidebar .menu__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar .menu__hint { flex: none; }

.sidenav { display: flex; flex-direction: column; gap: 0; padding-top: 10px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* room between the groups, with a hairline so each reads as its own block */
.sidenav__group { padding: 10px 0 16px; }
.sidenav__group + .sidenav__group { border-top: 1px solid var(--sb-border); padding-top: 18px; }
.sidenav__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sb-label);
  padding: 0 10px 4px;
}
.sidenav__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--sb-text);
  font-weight: 500;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.sidenav__item .ico { flex: none; color: var(--sb-label); }
.sidenav__item:hover { background: var(--sb-hover); color: var(--sb-text-strong); }
.sidenav__item[aria-current='page'] { background: var(--sb-active); color: var(--sb-text-strong); font-weight: 600; }
.sidenav__item[aria-current='page'] .ico { color: var(--sb-text-strong); }
.sidenav__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sidebar__foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.sidebar__sync { padding: 0 10px 2px; }
.sidebar__user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 0 10px;
  font-size: var(--fs-sm);
  color: var(--sb-label);
}
.sidebar__email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__signout { color: var(--sb-text); font-size: var(--fs-sm); white-space: nowrap; padding: 2px 6px; border-radius: var(--radius); }
.sidebar__signout:hover { background: var(--sb-hover); color: var(--sb-text-strong); }
/* the sync chip sits on the sidebar surface */
.sidebar .stat { background: transparent; border-color: var(--sb-border-2); color: var(--sb-text); }
.sidebar .stat b { color: var(--sb-text-strong); }

/* ---- content column ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px var(--gutter) 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar__menu { display: none; flex: none; }
/* a fixed basis keeps the title beside the menu button on phones; the
   actions wrap under it instead */
.topbar__title { min-width: 0; flex: 1 1 200px; }
.topbar h1 { font-size: var(--fs-xl); }
.topbar__meta { color: var(--text-2); font-size: var(--fs-md); margin-top: 2px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.topbar__actions .stats { margin-right: 6px; }

/* schedule-view filters: their own band under the topbar */
.filterband {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px var(--gutter);
  border-bottom: 1px solid var(--border);
  background: var(--bg-warm);
}
.filterband .seg-btn { background: var(--bg); }

/* the league name only prints — on screen it lives in the sidebar */
.print-head { display: none; }

/* no-op on screen; a drawer backdrop on phones */
.shell__backdrop { display: none; }

/* ---- phones & narrow windows: the sidebar becomes a drawer ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 272px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    z-index: 40;
    box-shadow: var(--shadow-drawer);
    transform: translateX(-100%);
    transition: transform 0.18s ease-out;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .shell--nav-open .sidebar { transform: none; }
  .shell--nav-open .shell__backdrop { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 39; }
  .topbar__menu { display: inline-flex; }
  .topbar, .filterband { padding-left: var(--gutter-sm); padding-right: var(--gutter-sm); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ---- print: the content only, under the league name ---- */
@media print {
  .sidebar, .topbar, .filterband, .shell__backdrop { display: none !important; }
  .shell, .main { display: block; }
  .print-head { display: block; border-bottom: 2px solid #000; padding: 0 0 8px; margin-bottom: 8px; }
  .print-head h1 { font-size: var(--fs-2xl); }
}

/* Dark sidebar: the league list is part of the sidebar, so it takes the
   sidebar's inks rather than the page's — dark in a light theme too. */
:root[data-sidebar='dark'] .sidebar .menu__list {
  background: var(--sb-bg);
  color: var(--sb-text-strong);
  border-color: var(--sb-border-2);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
:root[data-sidebar='dark'] .sidebar .menu__item:hover { background: var(--sb-hover); }
:root[data-sidebar='dark'] .sidebar .menu__item[aria-current='true'] { background: var(--sb-active); }
:root[data-sidebar='dark'] .sidebar .menu__hint,
:root[data-sidebar='dark'] .sidebar .menu__sep { color: var(--sb-text); }
:root[data-sidebar='dark'] .sidebar .menu__sep { border-top-color: var(--sb-border); }

/* the foot's publish line: does the public side match the draft? */
.sidebar__publish { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 4px; font-size: var(--fs-sm); color: var(--sb-text); min-height: 0; }
.sidebar__publish:empty { display: none; }
.sidebar__pub--dirty { color: var(--sb-text-strong); font-weight: 600; }
.sidebar__pubbtn { padding: 3px 10px; font-size: var(--fs-sm); white-space: nowrap; flex: none; }
.sidebar__sync:empty, .sidebar__sync:has(#sync-chip:empty) { display: none; }
