/* Admin layout on top of base.css: menu band, cards, lists, save bar. */
@import url('/assets/base.css');

/* Keep room for the scrollbar, so a filter that shortens the page does not shift it sideways. */
html { scrollbar-gutter: stable; }

/* ---------- Menu band ---------- */

.band { background: var(--green-900); position: sticky; top: 0; z-index: 20; }
.band-inner { max-width: 64rem; margin: 0 auto; display: flex; align-items: stretch; }
.band .menu { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; }
.band .menu a, .band .logout {
  color: #fff; text-decoration: none; text-transform: uppercase; font-weight: var(--strong);
  padding: 1rem 1.1rem; white-space: nowrap; background: none; border: 0; font: inherit; font-weight: var(--strong); cursor: pointer;
}
.band .menu a:hover, .band .logout:hover { background: var(--green-700); }
.band .menu a[aria-current='page'] { background: #fff; color: var(--green-900); }
.band .logout { text-transform: none; font-weight: 400; color: #cfe0d5; }
/* Narrower screens: first tighter items, then smaller text, so the menu stays
   on one row. Where it would need a second row, it folds away behind a menu
   button and opens as a list under the band. */
.band .menu-toggle { display: none; }
@media (max-width: 64rem) {
  .band .menu a, .band .logout { padding: 1rem .7rem; }
}
@media (max-width: 55rem) {
  .band .menu a, .band .logout { padding: 1rem .5rem; font-size: .875rem; }
}
@media (max-width: 48rem) {
  .band-inner { flex-wrap: wrap; }
  .band .menu-toggle {
    display: inline-flex; align-items: center; gap: .5rem; margin-right: auto;
    padding: 1rem; background: none; border: 0; color: #fff; cursor: pointer;
    font: inherit; font-weight: var(--strong); text-transform: uppercase;
  }
  .band .menu-toggle:hover { background: var(--green-700); }
  .band .menu-toggle:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
  .band .logout { padding: 1rem; font-size: 1rem; }
  .band .menu { display: none; order: 3; flex-basis: 100%; flex-direction: column; overflow: visible; }
  .band.open .menu { display: flex; }
  .band .menu a { padding: .9rem 1rem; font-size: 1rem; border-top: 1px solid var(--green-700); }
}

/* ---------- Page ---------- */

main { max-width: 64rem; margin: 0 auto; padding: 2rem 1rem 3rem; }
main.has-savebar { padding-bottom: 7rem; }
h1 { color: var(--green-900); font-size: 1.875rem; font-weight: var(--strong); line-height: 1.25; margin: 0 0 .25rem; }
h2 { color: var(--green-800); font-size: 1.25rem; font-weight: 400; margin: 1.5rem 0 .75rem; }
.lead { color: var(--muted); margin: 0 0 1.75rem; }
/* Breadcrumb as page title on detail screens: "CAMPAGNES / OPSTART", in the
   style of the panel titles, current page bold. Wraps between steps. */
nav.crumb {
  display: flex; flex-wrap: wrap; align-items: baseline; margin: 0 0 .5rem;
  font-size: 1.125rem; text-transform: uppercase; letter-spacing: .05em; line-height: 1.5;
}
nav.crumb a { color: var(--green-600); text-decoration: none; }
nav.crumb a:hover { text-decoration: underline; }
nav.crumb .sep { color: var(--green-100); margin: 0 .6rem; font-weight: 700; }
nav.crumb [aria-current] { color: var(--green-800); font-weight: 700; }

/* ---------- Cards ---------- */

.card { border: 1px solid var(--green-100); margin-bottom: 1.5rem; background: #fff; }
.card-head {
  background: var(--green-50); border-bottom: 1px solid var(--green-100); padding: .75rem 1.25rem;
  color: var(--green-800); text-transform: uppercase; letter-spacing: .04em; font-size: .9rem; margin: 0; font-weight: 700;
}
.card-body { padding: 1.25rem; }
.card-body > :last-child { margin-bottom: 0; }
/* Collapsible panel (admin-ui.js): .fold with a .fold-toggle button; the
   element right after the button is the body. */
.fold-toggle {
  width: 100%; display: flex; align-items: center; gap: .75rem; text-align: left; cursor: pointer;
  font: inherit; background: var(--green-50); color: var(--green-800); border: 0; border-radius: 0;
}
.card > .fold-toggle.card-head { padding: .75rem 1.25rem; font-weight: 700; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.fold-toggle::after {
  content: ''; flex: none; width: .5rem; height: .5rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-.15rem) rotate(45deg); transition: transform .15s;
}
.fold.is-open > .fold-toggle::after { transform: translateY(.1rem) rotate(-135deg); }
.fold:not(.is-open) > .card-head { border-bottom: 0; }
.fold-toggle:hover { background: var(--green-100); border-color: transparent; }
.fold-toggle:focus-visible { outline: 2px solid var(--green-900); outline-offset: -2px; }
/* Smaller variant inside a card, e.g. "Voorbij" under blocked dates. */
.sub-fold { border-top: 1px solid var(--green-100); }
.sub-toggle { background: #fff; color: var(--muted); padding: .9rem 1.25rem; text-transform: none; font-weight: 400; letter-spacing: 0; }
.sub-toggle::after { margin-left: auto; }
.sub-fold.is-open > .sub-toggle { border-bottom: 1px solid var(--green-100); }
.fold-title { margin-right: auto; }
.fold-count { color: var(--error); text-transform: none; letter-spacing: 0; font-weight: 400; }
.fold-count:empty { display: none; }
/* A count that is information, not a problem ("2 aangepast" in the screen Teksten). */
.fold-count.neutral { color: var(--muted); }

/* Messages that double as a card body take no room while empty. */
.card > p.card-body:empty { display: none; }
.card > .entries li, .card > .rows li { padding-left: 1.25rem; padding-right: 1.25rem; }

/* ---------- Form fields: label left, control right ---------- */

.field { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: .25rem 1.5rem; margin-bottom: 1.1rem; align-items: start; }
.field > label { padding-top: .7rem; margin: 0; }
.field > :not(label) { grid-column: 2; }
.field > .hint { margin: 0; }
/* A field row without its own control, e.g. a row of links. */
.field > span.label { grid-column: 1; padding-top: .2rem; }
.preview-links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0; }
.hint.intro { margin: 0 0 1.25rem; }
.hint.count { margin: 0 0 .5rem; }
/* Nothing to list: a framed box, so it does not read as one more line of hint text. */
.empty-state { margin: .5rem 0 0; padding: 1.5rem 1rem; text-align: center; border: 1px dashed var(--field); color: var(--green-900); background: var(--green-50); }
.empty-state[hidden] { display: none; }
.hint.source { margin-top: 1.25rem; font-size: .8rem; }
.field:last-child { margin-bottom: 0; }
input.short { max-width: 8rem; }
input.medium { max-width: 20rem; }
input.missing, textarea.missing { border-color: var(--error); background: var(--error-bg); }

@media (max-width: 40rem) {
  .field { grid-template-columns: minmax(0, 1fr); }
  .field > label { padding-top: 0; }
  .field > :not(label) { grid-column: 1; }
}

/* Inline groups: a row of fields next to each other. */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 1rem; }
.row input, .row .dropdown { margin-bottom: 1rem; }
.row.top { align-items: start; }
.align-end { display: flex; align-items: flex-start; padding-top: 1.85rem; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.group { border-top: 1px solid var(--green-100); padding-top: 1.1rem; margin-top: 1.1rem; }
fieldset.group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
/* A legend normally sits inside the top border, which breaks the line after
   the text. Floating it takes it out, so the line runs full width above it. */
fieldset.group legend { float: left; width: 100%; color: var(--green-800); padding: 0 0 .75rem; }
fieldset.group legend + * { clear: both; }
fieldset.group .to { margin: -.5rem 0 1rem; }

/* ---------- Lists ---------- */

.entries, .rows { list-style: none; margin: 0; padding: 0; }
.entries li, .rows li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 0; border-bottom: 1px solid var(--green-100);
}
.entries li:last-child, .rows li:last-child { border-bottom: 0; }
.entries .when { display: block; }
.entries .description { color: var(--muted); }
.entries button { flex: none; }
/* Date and description on one row; the date column is as wide as the form labels, so the descriptions line up with the fields. Stacked on a phone. */
.entries.dated li { padding-top: .5rem; padding-bottom: .5rem; }
.entries.dated .remove[hidden] { display: inline-flex !important; visibility: hidden; }
.entries.dated li.released .when, .entries.dated li.released .description { color: var(--muted); font-weight: 400; }
.entries.dated li > div { flex: 1; min-width: 0; display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: .1rem 1.5rem; align-items: baseline; }
@media (max-width: 40rem) { .entries.dated li > div { grid-template-columns: minmax(0, 1fr); } }

/* Campaign overview */
.choice { display: flex; gap: .75rem; align-items: flex-start; cursor: pointer; margin: 0; flex: 1; min-width: 12rem; }
.choice input { margin-top: .3rem; flex: none; }
.choice .name { font-size: 1.125rem; display: block; }
.choice .description { display: block; color: var(--muted); font-size: .9rem; }
.choice:has(input:disabled) { cursor: default; }
.rows li.is-active { background: var(--green-50); }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; flex: 0 1 auto; justify-content: flex-end; }
@media (max-width: 40rem) { .rows .actions { justify-content: flex-start; padding-left: 1.95rem; } }

/* Time slots and recipients */
.slot { justify-content: flex-start; }
.slot .remove { margin-left: auto; }
label.inline { display: flex; align-items: center; gap: .5rem; margin: 0; }
label.inline input { width: auto; }
.inline-label { color: var(--muted); }
.dropdown.time { width: 7rem; }
#earliest-state .notice { margin: 1.1rem 0 0; }
/* "Van … tot …" always on one line; "Verwijderen" wraps under it on a phone. */
.slot-times { display: flex; align-items: center; gap: .5rem; flex-wrap: nowrap; }
@media (max-width: 30rem) { .dropdown.time { width: 6rem; } }
.dropdown.time .dropdown-list { min-width: 7rem; }
.address .email { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* Keep the column width when the remove button is hidden. */
.address .remove[hidden] { display: inline-block !important; visibility: hidden; }
/* The active campaign cannot be removed: keep the space, so the buttons line up across rows. */
.actions .remove[hidden] { display: inline-flex !important; visibility: hidden; }

/* Change log */
.log li { align-items: flex-start; }
.log .meta { flex: none; text-align: right; white-space: pre-line; color: var(--muted); font-size: .85rem; }

/* ---------- Save bar ---------- */

.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 3px solid var(--green-900); z-index: 15; }
.savebar-inner { max-width: 64rem; margin: 0 auto; padding: .75rem 1rem; display: flex; align-items: center; gap: 1rem; }
.save-actions { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; flex-wrap: wrap; flex: 1; }
.savebar .error { margin: 0; min-height: 0; }
/* Page title (or breadcrumb) with "Help?" at the far right. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 .5rem; }
.page-head > h1, .page-head > .crumb { margin: 0; flex: 1; min-width: 0; }
/* Help: a quiet link with the circle-help icon, no border. */
.help-link {
  flex: none; display: inline-flex; align-items: center; gap: .4rem; padding: .25rem 0;
  background: none; border: 0; color: var(--green-900); font: inherit; font-weight: 400;
  text-transform: none; letter-spacing: 0; cursor: pointer;
}

.help-link:hover { background: none; color: var(--green-700); }
.help-link:hover span { text-decoration: underline; }
.help-link:focus-visible { outline: 2px solid var(--green-900); outline-offset: 3px; }

/* Placeholder chips in the campaign mails: click to copy. */
.ph-chip {
  font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; font-weight: 400;
  text-transform: none; letter-spacing: 0; padding: .1rem .4rem; margin: .1rem 0;
  background: var(--green-50); color: var(--green-900); border: 1px solid var(--green-100); cursor: copy;
}
.ph-chip:hover { background: var(--green-100); border-color: var(--green-600); }
.ph-chip.copied { animation: ph-copied 1.1s ease-out; }
/* Copied: a green flash with a ring that fades out; the text stays. */
@keyframes ph-copied {
  0% { background: var(--green-900); border-color: var(--green-900); color: #fff; box-shadow: 0 0 0 0 rgba(63, 118, 82, .55); }
  35% { background: var(--green-900); border-color: var(--green-900); color: #fff; box-shadow: 0 0 0 6px rgba(63, 118, 82, 0); }
  100% { background: var(--green-50); border-color: var(--green-100); color: var(--green-900); box-shadow: 0 0 0 0 rgba(63, 118, 82, 0); }
}
@media (prefers-reduced-motion: reduce) { .ph-chip.copied { animation-duration: .01s; } }
/* Back and cancel sit on the left as a text link, like in the modals. */
.back-link { flex: none; color: var(--green-900); text-decoration: underline; display: inline-flex; align-items: center; gap: .45rem; }
/* Arrow to the left, drawn in CSS, the same as in the visitor app. */
.back-link::before {
  content: ''; flex: none; width: .45rem; height: .45rem;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.back-link:hover { color: var(--green-700); }

.help-content h2 { margin-top: 1.5rem; }
/* "Terug" to the previous help page, above the content. */
.help-content .help-back { margin-bottom: 1rem; }
.help-content h2:first-child, .help-content p:first-child { margin-top: 0; }
.help-content li { line-height: 1.6; margin-bottom: .35rem; }
.help-content > :last-child { margin-bottom: 0; }

/* ---------- Regions and driving days ---------- */

/* A card head with actions on the right, e.g. "Postcode toevoegen". */
.card-head.with-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1.25rem; }
.card-head.with-actions h2 { margin: 0; font: inherit; color: inherit; letter-spacing: inherit; }
.head-actions { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.head-actions button.link { display: inline-flex; align-items: center; gap: .35rem; text-transform: none; letter-spacing: 0; font-weight: 400; }
.head-actions .icon { width: 1rem; height: 1rem; }

/* Form fields in a modal: two per row, texts across the full width; one column on a phone. */
.stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.stack > p { margin: 0; grid-column: 1 / -1; }
.stack > .full { grid-column: 1 / -1; }
.stack input, .stack .dropdown { margin-bottom: 0; }
@media (max-width: 40rem) {
  .stack { grid-template-columns: minmax(0, 1fr); }
}

/* Sortable column headers: the header text is a button, the arrow shows the order. */
th[data-sort] button.sort {
  display: inline-flex; align-items: center; gap: .3rem; padding: 0; background: none; border: 0;
  font: inherit; font-weight: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; cursor: pointer;
}
th[data-sort] button.sort .icon { width: .9rem; height: .9rem; opacity: .45; }
th[data-sort] button.sort:hover { color: var(--green-900); }
th[aria-sort] button.sort { color: var(--green-900); }
th[aria-sort] button.sort .icon { opacity: 1; }
th[data-sort] button.sort:focus-visible { outline: 2px solid var(--green-900); outline-offset: 2px; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0 1rem; }
.filters input, .filters .dropdown { margin-bottom: 1rem; }

.region-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.region-box { border: 1px solid var(--green-100); padding: .75rem 1rem; }
.region-box strong { display: block; color: var(--green-800); }
.region-box span { display: block; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.region-box .km:empty { display: none; }
/* Notice: one line with an icon and an optional action. Green says "all fine"
   or informs; .warn asks to take a look. Spans a whole grid row. */
.notice {
  grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border: 1px solid var(--green-100); border-left: 4px solid var(--green-600);
  background: var(--green-50); color: var(--green-900);
}
.notice p { margin: 0; flex: 1; }
.notice button { flex: none; }
.notice.warn { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn-ink); }
.notice.warn .icon { color: var(--warn); }
.notice.warn button.link { color: var(--warn-ink); }
/* Several lines, e.g. the preview links and what they do: icon at the top. */
.notice > div { flex: 1; min-width: 0; }
.notice > div > p + p { margin-top: .25rem; }
.notice.previews { align-items: flex-start; margin-top: 1.25rem; }
.notice.previews > .icon { margin-top: .1rem; }
.notice .preview-links { align-items: baseline; }
/* Opens a new tab: the external-link icon right after the text. */
.new-tab { display: inline-flex; align-items: center; gap: .3rem; }
.new-tab .icon { width: .9rem; height: .9rem; }
/* On its own between blocks: the same gap as a card; under a table in a card, a gap above. */
form > div > .notice, main > div > .notice, main > .notice { margin-bottom: 1.5rem; }
.card-body > table + .notice { margin-top: 1rem; }

table.regions, table.days-grid { width: 100%; border-collapse: collapse; }
table.regions th, table.regions td, table.days-grid th, table.days-grid td {
  text-align: left; padding: .6rem .4rem; border-bottom: 1px solid var(--green-100); vertical-align: middle;
}
table.regions thead th, table.days-grid thead th {
  font-weight: 400; color: var(--muted); text-transform: uppercase; font-size: .85rem; border-bottom: 2px solid var(--green-900);
}
/* Fixed layout: the columns keep their width whatever the filter shows. */
table.regions { table-layout: fixed; }
table.regions .col-code { width: 6.5rem; }
table.regions .col-km { width: 8.5rem; }
/* Region with five buttons, then the trash can. */
table.regions .col-region { width: 13rem; }
table.regions .col-action { width: 2.75rem; }
table.regions[hidden] { display: none; }
table.regions thead th { position: sticky; top: 3.5rem; background: #fff; z-index: 1; }
table.regions tbody th { font-weight: var(--strong); }
table.regions .place { overflow-wrap: anywhere; }
table.regions .place .description { display: block; color: var(--muted); font-size: .85rem; }
table.regions .km { white-space: nowrap; color: var(--muted); }
table.regions tr.changed { background: var(--green-50); }
table.regions tr.differs > * { background: var(--warn-fill); }
/* Their own distance: a small field in the table, saved on blur. */
table.regions .km-input { width: 4.5rem; padding: .4rem .5rem; text-align: right; }
table.regions .km-input.saved { border-color: var(--green-600); background: var(--green-50); }
table.regions .unit { margin-left: .35rem; }
/* A button that is only an icon, e.g. the trash can. */
.icon-button, button.icon-button.danger {
  display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  padding: 0; background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { border-color: var(--line); background: #fff; }
.icon-button.danger:hover, button.icon-button.danger:focus-visible { color: var(--error); border-color: var(--error); background: var(--error-bg); }
.icon-button:focus-visible { outline: 2px solid var(--green-900); outline-offset: 1px; }
.suggestion { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.suggestion:empty { display: none; }

/* Region choice: five joined buttons, the current one filled. */
.seg { display: inline-flex; }
.seg button {
  font: inherit; font-size: .85rem; font-weight: var(--strong); text-transform: none; letter-spacing: 0;
  min-width: 2.25rem; padding: .3rem .55rem; background: #fff; color: var(--green-900); border: 1px solid var(--field);
}
.seg button + button { margin-left: -1px; }
.seg button:hover { background: var(--green-50); border-color: var(--green-600); position: relative; }
.seg button[aria-checked='true'] { background: var(--green-900); border-color: var(--green-900); color: #fff; position: relative; }
.seg button.suggested:not([aria-checked='true']) { text-decoration: underline dotted; text-underline-offset: 3px; }
.seg button:focus-visible { outline: 2px solid var(--green-600); outline-offset: 1px; position: relative; z-index: 1; }

table.days-grid tbody th { font-weight: 400; }
table.days-grid tbody th strong { display: block; color: var(--green-800); }
table.days-grid tbody th .description { color: var(--muted); font-size: .85rem; }
table.days-grid .day { text-align: center; width: 3.25rem; }
table.days-grid .day input { margin: 0; width: 1.35rem; height: 1.35rem; }

@media (max-width: 40rem) {
  table.regions thead, table.regions colgroup { display: none; }
  table.regions, table.regions tbody, table.regions tr, table.regions th, table.regions td { display: block; width: auto; }
  table.regions tr { padding: .6rem 0; border-bottom: 1px solid var(--green-100); }
  table.regions th, table.regions td { border: 0; padding: .1rem 0; }
  table.regions tbody th { display: inline-block; margin-right: .5rem; }
  table.regions .place { display: inline; }
  table.regions .km { display: block; width: auto; font-size: .85rem; }
  table.regions td.km::before { content: attr(data-label) ': '; }
  table.regions td:last-child { padding-top: .4rem; }
  table.days-grid .day { width: 2.5rem; }
  table.days-grid th, table.days-grid td { padding: .5rem .15rem; }
}

/* ---------- Help pages ---------- */

.help h2 { margin-top: 1.75rem; }
.help li { line-height: 1.6; margin-bottom: .35rem; }
.help main { max-width: 48rem; }

/* ---------- Login ---------- */

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.login { width: 100%; max-width: 24rem; text-align: center; }
.login img { width: 14rem; max-width: 70%; height: auto; display: block; margin: 0 auto 2rem; }
.login h1 { text-transform: uppercase; font-size: 1.375rem; margin: 0 0 .5rem; }
.login p { color: var(--muted); }
.login form { text-align: left; }
.login form > button[type=submit] { width: 100%; margin-top: .5rem; }
.login .link { display: block; margin: 1rem auto 0; }
.login .help-link { margin: 1.5rem auto 0; display: flex; width: fit-content; color: var(--muted); }
