/* Styles for the administrator views (variants, variant editor, people, settings, activity log).
   Same rules as app.css: logical properties only, targets >= 44px, no inline styles. */

/* A focused control near the bottom must not hide behind the sticky action bar. */
html { scroll-padding-block-end: 110px; }

/* ---- page frame ---------------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.page-head h1 { margin: 0; }
.lead { max-inline-size: 72ch; margin-block-end: 0; }
.no-margin { margin: 0; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; }
.exam-text { unicode-bidi: isolate; overflow-wrap: anywhere; }

fieldset.q-options { margin: 0; padding: 0; border: 0; min-inline-size: 0; }

/* ---- forms --------------------------------------------------------- */

.form-grid {
  display: grid;
  gap: 12px 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  align-items: start;
}
.form-grid > .span-all { grid-column: 1 / -1; }

.check-field > .hint,
.check-field > .error { padding-inline-start: 32px; }

.inline-field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.inline-field > .label { margin: 0; }
.inline-field select { inline-size: auto; min-inline-size: 6rem; }
.inline-field > .hint,
.inline-field > .error { flex-basis: 100%; }

.pass-line { margin: 0; }
.hint-line { margin: 0; color: var(--muted); font-size: 0.875rem; }

.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* An icon-only button: the glyph is drawn here, the name comes from aria-label. */
.btn.icon { padding: 0; }
.btn.icon::before { content: "\00d7"; font-size: 1.6rem; line-height: 1; }

/* ---- on / off switch ------------------------------------------------ */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-block-size: var(--tap);
  cursor: pointer;
}
.switch input.switch-input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  inline-size: 48px;
  block-size: 28px;
  margin: 0;
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.switch input.switch-input::before {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 20px;
  block-size: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: inset-inline-start 0.15s, background 0.15s;
}
.switch input.switch-input:checked { background: var(--accent); border-color: var(--accent); }
.switch input.switch-input:checked::before { inset-inline-start: 22px; background: var(--accent-text); }
.switch input.switch-input:disabled { opacity: 0.55; cursor: not-allowed; }
.switch-text { min-inline-size: 6ch; font-weight: 600; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .switch input.switch-input,
  .switch input.switch-input::before { transition: none; }
}

/* ---- tables -------------------------------------------------------- */

.cell-title { min-inline-size: 12rem; max-inline-size: 22rem; font-weight: 600; }
.detail-cell { min-inline-size: 14rem; overflow-wrap: anywhere; }
.people-table select { inline-size: auto; min-inline-size: 9rem; }
.row-note { max-inline-size: 16rem; margin-block: 6px 0; white-space: normal; }
.table td.actions .row { flex-wrap: nowrap; }

/* ---- question editor ------------------------------------------------ */

.q-list { display: grid; gap: 16px; }
.q-list > * + * { margin-block-start: 0; }
.q-card { scroll-margin-block: 12px; }

.q-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.q-head h3 { margin: 0; }
.q-tools { gap: 6px; }

.q-options { display: grid; gap: 8px; }
.q-options > legend { padding: 0; margin-block-end: 8px; font-weight: 600; }

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 4px;
  padding-inline: 8px 4px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.opt-row[data-correct="true"] { border-color: var(--ok); background: var(--ok-bg); }
.opt-row > input[type="text"] { flex: 1 1 auto; min-inline-size: 0; }

.opt-correct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-block-size: var(--tap);
  min-inline-size: var(--tap);
  cursor: pointer;
}
.opt-letter {
  display: grid;
  place-items: center;
  inline-size: 28px;
  block-size: 28px;
  border: 2px solid var(--line);
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
}
.opt-row[data-correct="true"] .opt-letter { background: var(--ok); border-color: var(--ok); color: var(--bg); }

.q-picture { padding-block: 4px; }
.q-image {
  display: block;
  max-block-size: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.file-btn { position: relative; }
.file-btn:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- sticky action bar --------------------------------------------- */

.sticky-bar {
  position: sticky;
  inset-block-end: 8px;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow), 0 -6px 18px rgb(0 0 0 / 8%);
}
.sticky-bar .notice { margin: 0; }
.bar-info { gap: 10px; }
.bar-count { font-weight: 600; }

/* ---- settings ------------------------------------------------------- */

.setting-control { gap: 12px; }
.setting-control input[type="number"] { inline-size: 9rem; }
.setting-control select { inline-size: auto; min-inline-size: 12rem; }
.setting .unit { color: var(--muted); }
.setting .reading { font-weight: 600; }

/* ---- narrow screens ------------------------------------------------- */

@media (max-width: 480px) {
  .q-tools { inline-size: 100%; }
  .q-tools .btn { flex: 1 1 auto; }
  .sticky-bar .row.between { gap: 8px; }
  .sticky-bar .row.between > .row:last-child { flex: 1 1 auto; justify-content: flex-end; }
  .page-head .btn { flex: 1 1 auto; }
}
