/* Admin shell and public portal chrome - geometry taken from the wireframe. */

.app-shell { height: 100vh; display: flex; flex-direction: column; }
.app-body { flex: 1; display: flex; min-height: 0; }

/* sidebar */
.sidebar {
  width: 238px; flex: none;
  border-right: 2px solid var(--color-divider);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { padding: var(--space-4) var(--space-4) var(--space-3); border-bottom: 2px solid var(--color-divider); }
.sidebar-brand { font-family: var(--font-heading); font-weight: 800; font-size: 15px; line-height: 1.15; letter-spacing: -0.01em; }
.sidebar-sub { font-size: 10px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--color-accent); margin-top: 5px; }
.sidebar-nav { flex: 1; overflow: auto; padding: var(--space-3) 0; }
.nav-head { font-size: 10px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--color-neutral-600); padding: var(--space-4) var(--space-4) var(--space-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  text-align: left; font: inherit; font-size: 13px;
  padding: 7px var(--space-4) 7px 13px;
  border: 0; border-left: 3px solid transparent;
  background: transparent; color: var(--color-text); cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: color-mix(in srgb, var(--color-text) 5%, transparent); color: var(--color-text); }
.nav-item.is-active { border-left-color: var(--color-accent); background: var(--color-surface); }
.nav-item .label { flex: 1; }
.nav-badge { font-size: 10px; font-family: var(--font-heading); font-weight: 800; background: var(--color-neutral-300); color: var(--color-text); padding: 1px 6px; }
.nav-item.is-active .nav-badge { background: var(--color-accent); color: var(--color-bg); }
.sidebar-foot { border-top: 2px solid var(--color-divider); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.avatar {
  width: 28px; height: 28px; flex: none; background: var(--color-neutral-900); color: var(--color-bg);
  font-family: var(--font-heading); font-weight: 800; font-size: 11px; display: grid; place-items: center;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

/* main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.page-head {
  border-bottom: 2px solid var(--color-divider);
  padding: var(--space-4) var(--space-6);
  display: flex; align-items: flex-end; gap: var(--space-6);
}
.page-head h2 { margin: 0; font-size: 27px; }
.page-actions { display: flex; gap: var(--space-2); }
.page-scroll { flex: 1; overflow: auto; min-height: 0; }

/* shared section rhythm */
.section { padding: var(--space-6); }
.section-b { border-bottom: 2px solid var(--color-divider); }
.toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6); border-bottom: 2px solid var(--color-divider);
  flex-wrap: wrap;
}
.spacer { flex: 1; }

/* stat strip */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 2px solid var(--color-divider); }
.stat { padding: var(--space-4) var(--space-6); border-right: 1px solid var(--color-divider); }
.stat-value { font-family: var(--font-heading); font-weight: 800; font-size: 38px; line-height: 1.05; margin-top: 6px; }
.stat-note { font-size: 11px; color: var(--color-neutral-700); }

/* toggle switch */
.switch {
  width: 44px; height: 22px; border: 1px solid var(--color-neutral-900);
  background: var(--color-bg); padding: 0; cursor: pointer; position: relative; flex: none;
}
.switch .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--color-neutral-900); transition: left .12s ease-out; }
.switch.is-on { background: var(--color-accent); }
.switch.is-on .knob { left: 24px; background: var(--color-bg); }

/* toast */
.toast {
  position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 60;
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--color-neutral-900); color: var(--color-bg);
  padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toastin .16s ease-out;
}
.toast .bar { width: 8px; align-self: stretch; flex: none; background: var(--color-accent); }
.toast-title { font-family: var(--font-heading); font-weight: 800; font-size: 13px; }
.toast-body { font-size: 12px; opacity: .8; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* drawer */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end;
  background: color-mix(in srgb, var(--color-neutral-900) 40%, transparent);
}
.drawer {
  width: 520px; max-width: 92vw; height: 100%; background: var(--color-bg);
  border-left: 2px solid var(--color-divider); box-shadow: var(--shadow-lg);
  overflow: auto; animation: drawerin .18s ease-out;
}
@keyframes drawerin { from { transform: translateX(24px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }

/* public portal */
.public-bar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-6); border-bottom: 2px solid var(--color-divider);
}
.public-brand { font-family: var(--font-heading); font-weight: 800; font-size: 16px; margin-right: auto; }
.public-wrap { max-width: 1080px; }
.step-no {
  font-family: var(--font-heading); font-weight: 800; font-size: 12px;
  background: var(--color-neutral-900); color: var(--color-bg); padding: 2px 8px;
}

/* auth screen */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brandside {
  background: var(--color-neutral-900); color: var(--color-bg);
  padding: var(--space-8) var(--space-8);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-formside { display: flex; align-items: center; justify-content: center; padding: var(--space-8); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brandside { display: none; }
}

/* modal - centred dialog, same ink backdrop as the drawer */
.modal-backdrop-x {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: var(--space-6);
  background: color-mix(in srgb, var(--color-neutral-900) 45%, transparent);
  animation: modalfade .12s ease-out;
}
.modal-panel {
  width: min(720px, 100%); max-height: 88vh; overflow: auto;
  background: var(--color-bg);
  border: 2px solid var(--color-neutral-900);
  box-shadow: var(--shadow-lg);
  animation: modalin .16s ease-out;
}
.modal-head {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 2px solid var(--color-divider);
}
.modal-body { padding: var(--space-6); }
.modal-foot {
  display: flex; gap: var(--space-2); align-items: center;
  padding: var(--space-4) var(--space-6);
  border-top: 2px solid var(--color-divider); background: var(--color-surface);
}
@keyframes modalfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalin { from { transform: translateY(-8px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

/* Long content scrolls inside the page rather than stretching the whole shell,
   which is what a training with a dozen batches used to do. */
.page-scroll { overflow-x: auto; }
.toolbar { flex-wrap: wrap; }
.seg { flex-wrap: wrap; max-width: 100%; }
.main { overflow: hidden; }
.table-wrap { overflow-x: auto; max-width: 100%; }

/* Dashboard panels sit side by side when there is room, and stack when there
   is not, so the batch list keeps a usable bar width on a laptop screen. */
.dash-split { display: grid; grid-template-columns: 1.15fr 1fr; }
.dash-split-left { border-right: 2px solid var(--color-divider); }

@media (max-width: 1200px) {
  .dash-split { grid-template-columns: 1fr; }
  .dash-split-left { border-right: 0; border-bottom: 2px solid var(--color-divider); }
}

/* The menu button and the sidebar's own close button only exist on a phone. */
.nav-open, .nav-close { display: none; }

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 39;
  background: color-mix(in srgb, var(--color-neutral-900) 45%, transparent);
}

/* Phone. The sidebar took 238px of a 360px screen, so it slides over the page
   instead of sitting beside it, and everything laid out in columns stacks. */
@media (max-width: 820px) {
  .nav-open {
    display: inline-flex; align-items: center; justify-content: center;
    flex: none; font-size: 17px; line-height: 1;
    padding: 6px 11px; align-self: center;
  }

  .nav-close { display: inline-flex; flex: none; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    width: min(280px, 84vw);
    background: var(--color-bg);
    transform: translateX(-100%);
    transition: transform .18s ease-out;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open { transform: translateX(0); }

  .page-head {
    align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
  }
  .page-head h2 { font-size: 20px; }
  .page-actions { width: 100%; flex-wrap: wrap; }

  .section { padding: var(--space-4); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* A table cannot be made narrow, so it scrolls inside its own box rather
     than pushing the page sideways. */
  .table { display: block; overflow-x: auto; white-space: nowrap; }

  .toolbar { padding: var(--space-3) var(--space-4); }
  .toolbar .field, .toolbar .input, .toolbar select { width: 100% !important; }

  .drawer { width: 100vw; }
  .modal-backdrop-x { padding: var(--space-3); }

  /* The public form is where registrants actually are on a phone: two columns
     of inputs at 360px leaves neither readable. */
  .two-col { grid-template-columns: 1fr !important; }
  .public-bar { flex-wrap: wrap; gap: 4px; padding: var(--space-3) var(--space-4); }
  .public-bar span { word-break: break-all; font-size: 10px; }
  .public-wrap .section { padding: var(--space-4); }
  .public-wrap h1 { font-size: 28px !important; max-width: none !important; }
  .step-bar { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
  .table-pad th:first-child, .table-pad td:first-child { padding-left: var(--space-4); }
  .table-pad th:last-child, .table-pad td:last-child { padding-right: var(--space-4); }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 18px; }
}

/* ---------------------------------------------------------------------------
   Participant portal

   Mostly read on a phone, so these are written narrow first and widened at
   820px rather than the other way round. The admin screens are used at a desk;
   this one is used standing up, on the day, one-handed.
   --------------------------------------------------------------------------- */

/* A labelled pair - "Session / Morning". Wraps to as many columns as fit,
   never fewer than one, so nothing is squeezed to an unreadable width. */
.facts {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.facts .kicker { margin-bottom: 2px; }
.facts-value { font-size: 13px; word-break: break-word; }

/* A list of rows, each a line of its own on a phone. Separated by a rule
   rather than a box, since twenty boxed rows on a small screen is a wall. */
.plist { display: grid; gap: var(--space-2); }
.prow {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  border-top: 1px solid var(--color-divider); padding-top: var(--space-2);
}
.prow-main { flex: 1; min-width: 0; font-size: 13px; }
.prow-side { font-size: 12px; color: var(--color-neutral-700); }

/* The joining link and the download buttons: full width on a phone, where a
   button the width of its text is a small target held one-handed. */
.p-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr 1fr; }

  /* A row's label and its value stop sharing a line: at 360px the value had
     about eight characters before it wrapped mid-word. */
  .prow { align-items: flex-start; }
  .prow-side { flex-basis: 100%; }

  .p-actions { flex-direction: column; align-items: stretch; }
  .p-actions .btn { width: 100%; justify-content: center; }
}

/* A very narrow phone. One column, or the labels wrap before the values do. */
@media (max-width: 400px) {
  .facts { grid-template-columns: 1fr; }
}

/* The attendance QR, with its number and caption beside it. Centred on its
   own the code sat alone in the middle of a wide row with its caption a long
   way off, which read as the whole page rather than one panel of it. */
.qr-block {
  display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap;
}
.qr-detail { flex: 1; min-width: 200px; }

/* Always on white with a quiet margin around it, whatever the page is doing:
   a scanner reads the contrast between the code and its surround, and the
   surround is not negotiable. Fixed width, so the code never stretches with
   the column and loses its squareness. */
.qr-frame {
  flex: none;
  background: #ffffff;
  border: 1px solid var(--color-neutral-900);
  padding: var(--space-3);
  line-height: 0;
}
.qr-frame svg { display: block; width: 148px; height: 148px; }

/* On a phone it goes back to its own line and grows: the code is held up to a
   scanner at arm's length, and there is no second column to share with. */
@media (max-width: 560px) {
  .qr-block { flex-direction: column; align-items: center; text-align: center; gap: var(--space-4); }
  .qr-detail { min-width: 0; }
  .qr-detail p { margin-left: auto; margin-right: auto; }
  .qr-frame svg { width: min(62vw, 210px); height: min(62vw, 210px); }
}

/* ---------------------------------------------------------------------------
   Dashboard charts

   Two scales, one hue each, because the dashboard says two different things.
   How full a block is runs in blue; how far along something is runs in green
   (the dots and the attendance bars - see TrainingSession::PROGRESS_MARK).
   Every value was checked with the palette validator against the track colour
   below, not chosen by eye: blue 3.64:1, dark blue 8.18:1.

   The track has no border. A dark outline on every bar was most of why the
   panel read as black.
   --------------------------------------------------------------------------- */
:root {
  --chart-track: #eae9e9;
  --chart-fill: #2a78d6;
  --chart-fill-full: #104281;
}

.chart-track {
  flex: 1; min-width: 0; height: 12px;
  background: var(--chart-track);
  border-radius: 3px; overflow: hidden;
  display: flex;
}
.chart-fill { height: 100%; background: var(--chart-fill); border-radius: 0 3px 3px 0; }
.chart-fill.is-full { background: var(--chart-fill-full); border-radius: 0; }

/* Stacked segments keep a 2px gap of track between them, so two steps of one
   hue never merge into a single bar. */
.chart-track.is-stacked { gap: 2px; }
.chart-track.is-stacked > div { height: 100%; }

/* "Full" in words beside the dark bar: the state never rests on colour alone. */
.chart-full-tag {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--chart-fill-full);
}

.chart-swatch {
  display: inline-block; width: 12px; height: 8px; flex: none;
  border-radius: 2px; background: var(--chart-fill);
}
.chart-swatch.is-full { background: var(--chart-fill-full); }
