/* The backend: navigation, wide tables, filter panel, detail view. */

.admin {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The bar is light, not dark: the logo is a trimmed PNG with a transparent
   background and dark blue lettering, so it needs a light surface to be
   readable at all. The blue band on top keeps the bar separated from the page
   and carries the brand colour that the dark bar used to. */
.admin__bar {
  background: var(--surface);
  border-top: 3px solid var(--blue);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.admin__bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  max-width: 82rem;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
}

.admin__brand {
  display: flex;
  align-items: center;
  flex: none;
  text-decoration: none;
}

.admin__logo {
  display: block;
  width: 150px;
  height: auto;
}

.admin__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-right: auto;
}

.admin__link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.925rem;
  font-weight: 600;
  text-decoration: none;
}

.admin__link:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.admin__link--active {
  background: var(--blue);
  color: #fff;
}

.admin__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
}

.admin__main {
  flex: 1;
  width: 100%;
  max-width: 82rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.admin__main--wide { max-width: 110rem; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-head__title { margin: 0; font-family: var(--serif); }
.page-head__sub { margin: var(--space-1) 0 0; color: var(--muted); font-size: 0.925rem; }

.breadcrumb {
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ----------------------------------------------------------------- Sections */

.panel {
  margin-bottom: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel__title { margin: 0; font-size: 1.05rem; font-weight: 650; }
.panel__body { padding: var(--space-5); }
.panel__body--flush { padding: 0; }

.stat-row {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin-bottom: var(--space-5);
}

.stat {
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat__value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat__label { color: var(--muted); font-size: 0.85rem; }

/* ------------------------------------------------------------------- Tables */

.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

table.data tbody tr:hover { background: color-mix(in srgb, var(--blue-light) 45%, var(--surface)); }
table.data tbody tr:last-child td { border-bottom: 0; }

table.data tfoot th {
  padding: var(--space-3) var(--space-4);
  border-top: 2px solid var(--line-strong);
  background: var(--paper);
  text-align: left;
  vertical-align: top;
}

table.data td.cell--clip {
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort { color: inherit; text-decoration: none; white-space: nowrap; }
.sort:hover { color: var(--blue); }
.sort--active { color: var(--blue); }
.sort__arrow { font-size: 0.7rem; }

/* ------------------------------------------------------------------ Filters */

.filters {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  align-items: end;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.filters__field { margin: 0; }

.filters__label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.filters__actions {
  display: flex;
  gap: var(--space-2);
  align-items: end;
}

.filters__toggle {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.filters input,
.filters select { padding: 0.45rem 0.6rem; font-size: 0.9rem; }

.filters select { padding-right: 2rem; }

.slot-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

/* ------------------------------------------------------------ Detail layout */

.detail {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
  align-items: start;
}

@media (max-width: 62rem) {
  .detail { grid-template-columns: minmax(0, 1fr); }
}

dl.answers { margin: 0; }

dl.answers > div {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}

dl.answers > div:last-child { border-bottom: 0; }

dl.answers dt {
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

dl.answers dd {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.slot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 15rem;
}

.chip {
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chip--muted { background: var(--paper-deep); color: var(--muted); }

/* ---------------------------------------------------------------- Day editor */

.days { display: grid; gap: var(--space-3); }

.day-row {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 4.5rem 7rem 7rem 5.5rem minmax(9rem, 1fr) auto;
  gap: var(--space-2);
  align-items: end;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.team-row { grid-template-columns: 9rem minmax(0, 1fr) auto; }

.day-row input { padding: 0.4rem 0.55rem; font-size: 0.9rem; }

.day-row__label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.day-row__teams {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.day-row__teams .checkbox { font-size: 0.85rem; }

@media (max-width: 52rem) {
  .day-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------- Pagination */

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
}

.pagination a,
.pagination em,
.pagination .current {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-style: normal;
  text-decoration: none;
}

.pagination .current {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.pagination a:hover { background: var(--paper-deep); }

/* --------------------------------------------------------------- Form pages */

.stack { display: grid; gap: var(--space-5); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: end;
}

.help-block {
  padding: var(--space-4);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--gold-light);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------- Placeholders */

.placeholders {
  margin-top: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.placeholders__summary {
  cursor: pointer;
  font-weight: 650;
}

.placeholders__table {
  margin-top: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Trix draws its own toolbar; only the surface needs to match the other
   controls. */
trix-editor {
  min-height: 16rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

trix-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
  outline: none;
}

trix-toolbar .trix-button-group { border-color: var(--line-strong); }

/* The Merkblatt takes no images or files, so the button that would offer them
   is not shown -- see app/javascript/info_sheet_editor.js. */
trix-toolbar .trix-button-group--file-tools { display: none; }

.help-block code {
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-size: 0.85em;
}

/* -------------------------------------------------------------- Shift cards */

/* A reminder line carries far fewer fields than a day of a slot matrix. */
.reminder-row { grid-template-columns: 9rem 9rem auto; }

.shift-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4);
}

.shift-facts__label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.roster-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-5);
  border-top: 1px solid var(--line);
}

.roster-actions__form {
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

/* The recipient list of a circular: one row per person, scrollable, so that
   180 people do not push the send button off the screen. */
.recipient-list {
  display: grid;
  gap: 2px;
  max-height: 28rem;
  overflow-y: auto;
  padding-right: var(--space-2);
}

.recipient {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.recipient:hover { background: var(--blue-light); }
.recipient__name { flex: 1 1 auto; }

.progress {
  height: 8px;
  margin: var(--space-3) 0;
  overflow: hidden;
  background: var(--line);
  border-radius: 4px;
}

.progress__bar {
  height: 100%;
  background: var(--ok);
}

.service-status {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* "View as": deliberately loud and directly under the bar, because every page
   below it lies about who is looking at it. */
.impersonation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: 82rem;
  margin: var(--space-4) auto 0;
  padding: var(--space-3) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: var(--radius);
  background: var(--warn-light);
  color: var(--warn);
}

/* A panel that swaps itself for the window its switch names: dimmed while the
   fragment is on its way, and left dimmed behind a notice when it never
   arrives, so that yesterday's numbers never pass for today's. */
.panel[aria-busy="true"] { opacity: 0.55; }

.panel--stale .table-wrap,
.panel--stale .panel__head,
.panel--stale .panel__body { opacity: 0.5; }

.panel__stale {
  margin: 0;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--err-light);
  color: var(--err);
  font-size: 0.9rem;
}

/* ------------------------------------------------- Shift table and multi-add */

/* The tick column of the shift table: as narrow as its box. */
.select-cell {
  width: 1%;
  text-align: center;
}

/* The batch action below the shift table, next to what it will act on. */
.selection-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  border-top: 1px solid var(--line);
}

/* The editable table of the multi-add screen. The inputs fill their cell, so
   that a line reads as a line rather than as eleven boxes with gaps. */
.multi-shift__table input[type="text"],
.multi-shift__table input[type="date"],
.multi-shift__table input[type="number"] {
  width: 100%;
  min-width: 6rem;
  padding: 0.3rem 0.45rem;
}

.multi-shift__table .input--time { min-width: 5rem; }
.multi-shift__table .input--count { min-width: 4.5rem; }
.multi-shift__table td { vertical-align: middle; }

/* The messages of a line, directly below it: a message three screens up says
   nothing about which of eight shifts it means. */
.row-errors td {
  padding-top: 0;
  color: var(--err);
  font-size: 0.85rem;
}

/* ------------------------------------------------- The assignment screen */

/* The plan on the left, the families waiting for a field on the right. The
   sidebar stays in view while the planner scrolls through four days. */
.plan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: var(--space-5);
  align-items: start;
}

.plan-layout__grid { display: grid; gap: var(--space-5); min-width: 0; }

.plan-layout__side {
  position: sticky;
  top: var(--space-5);
  display: grid;
  gap: var(--space-5);
}

@media (max-width: 60rem) {
  .plan-layout { grid-template-columns: minmax(0, 1fr); }
  .plan-layout__side { position: static; }
}

table.assign {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.assign th,
table.assign td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

table.assign th:last-child,
table.assign td:last-child { border-right: 0; }
table.assign tbody tr:last-child th,
table.assign tbody tr:last-child td { border-bottom: 0; }

table.assign thead th {
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line-strong);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

table.assign tbody th[scope="row"] {
  background: var(--paper);
  font-weight: 650;
  white-space: nowrap;
  vertical-align: middle;
}

.cell {
  position: relative;
  min-width: 10rem;
  height: 3.25rem;
  vertical-align: top;
}

.cell--taken { background: var(--surface); }

/* Colour never carries the meaning alone -- the field also shows a «gegen
   Wunsch» pill. This is the mark, not a refusal: assigning anywhere stays
   allowed. */
.cell--conflict {
  background: var(--err-light);
  border-left: 3px solid var(--err);
}

.cell__head {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  padding-right: 1.25rem;
}

.cell__name { font-weight: 600; }
.cell__meta { display: block; font-size: 0.8rem; }

/* The free field is the whole cell, so that the click target is what the eye
   reads as one box -- and a plain submit button, so that Tab reaches it and
   Enter or Space fills it. */
.cell__free {
  display: block;
  width: 100%;
  min-height: 2.25rem;
  padding: var(--space-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.cell__free:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.cell__free:focus-visible { background: var(--blue-light); color: var(--blue); }

.cell__clear {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  padding: 0 0.3rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
}

.cell__clear:hover { background: var(--err-light); color: var(--err); }

/* The chooser, mirroring the recipient list of a circular: one row per
   family, scrollable, so that forty of them do not push the grid away. */
.family-choice {
  margin: 0;
  padding: 0;
  border: 0;
}

.family-list {
  display: grid;
  gap: 2px;
  max-height: 32rem;
  overflow-y: auto;
}

.family-choice legend {
  padding: 0 0 var(--space-2);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.family {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.family:hover { background: var(--paper-deep); }
.family:focus-within { background: var(--blue-light); }
.family__body { flex: 1 1 auto; min-width: 0; }
.family__name { display: block; font-weight: 600; }
.family__wish { display: block; font-size: 0.8rem; }

.count-warn { color: var(--err); }
