/* Admin panel only. Loaded after /style.css, which brings the tokens, the base element styles,
   the focus ring, .btn / .btn--ghost and the .msg screen shown while logged out. */

/* .btn and the flex rows below set display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

/* A field that takes focus scrolls clear of the sticky save bar (there is no top bar here, unlike on the public
   page). ponytail: a fixed reserve instead of measuring the bar. It covers the bar at its tallest at the default
   text size (about 230px on a 320px phone, with an error message and two buttons); beyond that a focused field
   can end up partly under the bar. */
html { scroll-padding: var(--s-4) 0 min(17rem, 45vh); }

.adm {
  width: min(100% - 2 * var(--gutter), 52rem);
  margin-inline: auto;
  padding-top: var(--s-5);
}

/* Screen-reader announcements of list buttons ("Pozycja 2 z 7."). */
.adm-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- header ---------- */

.adm__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  margin-bottom: var(--s-5);
}
.adm__head h1 {
  display: flex;
  flex: 1 1 14rem;
  align-items: center;
  gap: var(--s-3);
  margin: 0;
  font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.75rem);
}
.adm__logo { flex: none; width: auto; height: 2.5rem; }
.adm__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: 0; }
/* compact, like the button in the public page's top bar: both fit on one line at 360 px */
.adm__actions .btn {
  min-height: 2.75rem;
  padding-inline: var(--s-4);
  font-size: calc(var(--fs-label) * var(--display-adjust));
}
.adm__lead { flex: 1 1 100%; margin: 0; color: var(--muted); }
.adm__lead strong { color: var(--text); }

/* ---------- sections and list rows (both are <details>) ---------- */

.sec {
  margin-bottom: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.sec summary { padding: var(--s-3) var(--s-4); cursor: pointer; }
.sec summary::marker { color: var(--cyan); }
.sec [open] > summary, .sec[open] > summary { border-bottom: 1px solid var(--line); }
.sec summary h2 { display: inline; margin: 0; font-size: var(--fs-h3); }   /* inline: stays on the marker's line */
.sec__body, .row__body { padding: var(--s-4); }

.list > h3 { margin: var(--s-5) 0 var(--s-2); font-size: 1.0625rem; }
.list__note { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--fs-small); }
.list__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin-block: var(--s-3);
}
.list__bar .list__note { margin: 0; }

.rows { margin: 0; padding: 0; list-style: none; }
.row {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.row + .row { margin-top: var(--s-2); }
.row summary { font-weight: 600; overflow-wrap: anywhere; }
.row__meta {
  margin-inline-start: var(--s-2);
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 400;
  white-space: nowrap;
}
.row__tools { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.tool {
  min-height: 2.75rem;
  padding: 0 var(--s-4);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.tool:hover { color: var(--cyan); border-color: var(--cyan); }
.tool--danger { margin-inline-start: auto; color: var(--danger); }
.tool--danger:hover { color: var(--danger); border-color: var(--danger); }
/* Nothing to move past: the button stays focusable and says so when pressed. */
.row:first-child .tool--up, .row:last-child .tool--down { opacity: .45; }

/* ---------- fields ---------- */

.field { margin-bottom: var(--s-4); }
.field label { display: block; margin-bottom: var(--s-1); font-weight: 600; }
.field input, .field textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: var(--s-2) var(--s-3);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.field textarea { min-height: 7.5rem; max-height: 70vh; resize: vertical; field-sizing: content; }
.field input[type="date"] { max-width: 14rem; }
.field input:focus, .field textarea:focus { border-color: var(--cyan); }
.field.is-over input, .field.is-over textarea, .field [aria-invalid="true"] { border-color: var(--danger); }

/* hint, "n / limit" counter and server error under the control */
.field__note {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-3);
  margin: var(--s-1) 0 0;
  color: var(--muted);
  font-size: var(--fs-small);
}
.field__note > :empty { display: none; }
.field__count { margin-inline-start: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.field.is-over .field__count { color: var(--danger); font-weight: 700; }
.field__error { flex-basis: 100%; color: var(--danger); }

/* ---------- save bar ---------- */

.savebar {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-6);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  box-shadow: 0 -.5rem 1.5rem rgb(var(--bg-rgb) / .7);
}
.savebar__status { flex: 1 1 14rem; margin: 0; }
/* With extra choices showing (session expired, version conflict) the message gets the whole first row. */
.savebar:has(.btn--ghost:not([hidden])) .savebar__status { flex-basis: 100%; }
.savebar__status.is-ok { color: var(--ok); }
.savebar__status.is-error { color: var(--danger); }

@media (max-width: 30rem) {
  .sec__body, .row__body { padding: var(--s-3); }
  .savebar { gap: var(--s-2); padding: var(--s-2) var(--s-3); }
  .savebar__status { font-size: var(--fs-small); line-height: 1.4; }
}
/* On a very low window (phone held sideways) a sticky bar would cover too much: it stays at the end of the form. */
@media (max-height: 26rem) {
  .savebar { position: static; }
}
