/*
 * Admin view styles (U10). Layers on top of the shared base stylesheet
 * (web/shared/style.css), reusing its custom properties, card, pill, and search
 * primitives. Only the admin-specific chrome (top bar, forms, totals, jobs)
 * lives here. Australian spelling in any author-facing text. No framework.
 */

/* Top bar: brand, class picker, account actions. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--colour-surface);
  border-bottom: 1px solid var(--colour-border);
}

.topbar__brand {
  font-weight: 700;
  font-size: 1.05rem;
}

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

.topbar__account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.topbar__email {
  color: var(--colour-text-muted);
  font-size: 0.9rem;
}

.topbar__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.topbar__select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
  color: inherit;
}

/* Sticky section navigation: a slim jump-link bar under the top bar. WHY sticky:
   the sections stack tall on one page, so the bar stays reachable while scrolling.
   It sits below the top bar's stacking context via its own z-index. */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--colour-surface);
  border-bottom: 1px solid var(--colour-border);
}

.section-nav__link {
  color: var(--colour-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.section-nav__link:hover,
.section-nav__link:focus {
  color: var(--colour-accent);
  text-decoration: underline;
}

/* Section stack. */
.sections {
  display: grid;
  gap: var(--space-4);
}

/* Context banner: the active org and class, restated above the sections so the
   admin always knows the scope every control below acts on. */
.context-banner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--colour-border);
  border-left: 4px solid var(--colour-accent);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.context-banner__part {
  display: grid;
  gap: 2px;
}

.context-banner__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--colour-text-muted);
}

.context-banner__value {
  font-size: 1.05rem;
  font-weight: 600;
}

.context-banner__value--muted {
  color: var(--colour-text-muted);
  font-weight: 500;
}

/* Role pills in the context banner: the caller's active role hats, so it is
   always clear which roles are in effect (and thus which tools below belong to
   which role). */
.context-banner__roles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.role-pill {
  padding: 0 var(--space-2);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.7;
  background: var(--colour-bg);
  color: var(--colour-text-muted);
  border: 1px solid var(--colour-border);
}

.role-pill--superadmin {
  background: var(--colour-linked-bg);
  color: var(--colour-linked-fg);
  border-color: var(--colour-linked-fg);
}

.role-pill--org-admin {
  background: var(--colour-provisioned-bg);
  color: var(--colour-provisioned-fg);
  border-color: var(--colour-provisioned-fg);
}

.role-pill--staff {
  background: var(--colour-surface);
  color: var(--colour-text);
}

/* Setup checklist: the natural first-time order with done / next markers. */
.setup-checklist {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.setup-checklist__title {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}

.setup-checklist__list {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.setup-step {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: 0.95rem;
  color: var(--colour-text-muted);
}

.setup-step__mark {
  flex: none;
  width: 1.1em;
  text-align: center;
  font-weight: 700;
}

.setup-step--done {
  color: var(--colour-text);
}

.setup-step--done .setup-step__mark {
  color: var(--colour-provisioned-fg);
}

.setup-step--next {
  color: var(--colour-text);
  font-weight: 600;
}

.setup-step--next .setup-step__label {
  text-decoration: underline;
  text-decoration-color: var(--colour-accent);
  text-underline-offset: 3px;
}

/* Collapsible section areas: a small number of labelled workflow stages instead
   of one long flat stack of cards. */
.section-groups {
  display: grid;
  gap: var(--space-4);
}

.section-group {
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-bg);
  overflow: hidden;
}

.section-group__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 700;
  background: var(--colour-surface);
}

.section-group__summary:focus-visible {
  outline: 2px solid var(--colour-accent);
  outline-offset: -2px;
}

.section-group__title {
  font-size: 1.05rem;
}

.section-group__hint {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--colour-text-muted);
}

.section-group__body {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
}

/* The cards inside a group already carry their own margin from the shared sheet;
   neutralise it so the group body's gap is the single source of spacing. */
.section-group__body .admin-card {
  margin-bottom: 0;
}

/* Offset a card heading from the sticky nav when scrolled into view, so the
   heading is not hidden under the bar after a nav jump. */
.admin-card .card__title {
  scroll-margin-top: var(--space-5, 3rem);
}

/* Remove the focus ring's hard edge on a heading focused by a nav jump (the
   heading is programmatically focusable via tabindex=-1, not a control). */
.admin-card .card__title:focus {
  outline: 2px solid var(--colour-accent);
  outline-offset: 2px;
}

/* Required-field affordance: a red asterisk after the label text. */
.form-field__required {
  margin-left: 0.15rem;
  color: var(--colour-unlinked-fg);
}

/* File selection summary (filename + parsed row count) under a CSV file input. */
.file-info {
  margin: 0;
  font-size: 0.85rem;
  color: var(--colour-text-muted);
}

/* Empty-state next-step line shown when a section has no data yet. */
.empty-state {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-bg);
  color: var(--colour-text-muted);
  font-size: 0.9rem;
}

/* Visually-hidden text kept available to assistive tech (e.g. "(required)"). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* Forms. */
.form-field {
  display: grid;
  gap: var(--space-1);
}

.form-field__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.form-field__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: 0.95rem;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
  color: inherit;
}

.form-field__input:focus {
  outline: 2px solid var(--colour-accent);
  outline-offset: 1px;
  border-color: var(--colour-accent);
}

/* Prefixed input (the fixed https://github.com/ org-URL field). */
.prefixed-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--colour-surface);
}

.prefixed-input__prefix {
  padding: var(--space-2) var(--space-2);
  background: var(--colour-bg);
  color: var(--colour-text-muted);
  border-right: 1px solid var(--colour-border);
  font-size: 0.9rem;
  white-space: nowrap;
  align-self: center;
}

.prefixed-input .form-field__input {
  border: none;
  border-radius: 0;
}

.prefixed-input .form-field__input:focus {
  outline: none;
}

/* Autocomplete dropdown (the repo field in the register-template card). The
   anchor wraps the input so the suggestion list can be absolutely positioned
   directly beneath it; the list reuses the surface/border/accent custom
   properties so it matches the rest of the admin chrome. */
.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.autocomplete__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
}

.autocomplete__option--active,
.autocomplete__option:hover {
  background: var(--colour-accent);
  color: var(--colour-accent-contrast);
}

.autocomplete__label {
  font-size: 0.95rem;
}

.autocomplete__hint {
  flex: none;
  padding: 0 var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  background: var(--colour-provisioned-bg);
  color: var(--colour-provisioned-fg);
}

/* Keep the hint legible against the highlighted (accent) row. */
.autocomplete__option--active .autocomplete__hint,
.autocomplete__option:hover .autocomplete__hint {
  background: var(--colour-accent-contrast);
  color: var(--colour-accent);
}

/* Autocomplete status line (searching / no matches / error) under the box. */
.autocomplete__status {
  margin: var(--space-1) 0 0;
  font-size: 0.85rem;
  color: var(--colour-text-muted);
}

/* Buttons (the base .pill/.link-button live in the shared sheet). */
.button {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--colour-border);
  background: var(--colour-surface);
  color: var(--colour-text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  filter: brightness(0.97);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.button--primary {
  background: var(--colour-accent);
  color: var(--colour-accent-contrast);
  border-color: var(--colour-accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.divider {
  border: none;
  border-top: 1px solid var(--colour-border);
  margin: var(--space-2) 0;
}

/* Notices (success / warning / error / info). */
.notice {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.notice--success {
  background: var(--colour-provisioned-bg);
  color: var(--colour-provisioned-fg);
}

.notice--warning {
  background: var(--colour-linked-bg);
  color: var(--colour-linked-fg);
}

.notice--error {
  background: var(--colour-unlinked-bg);
  color: var(--colour-unlinked-fg);
}

.notice--info {
  background: var(--colour-bg);
  color: var(--colour-text-muted);
}

/* Overview totals tiles. */
.totals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.total-tile {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
  min-width: 96px;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
  text-align: center;
}

.total-tile__value {
  font-size: 1.4rem;
  font-weight: 700;
}

.total-tile__label {
  font-size: 0.8rem;
  color: var(--colour-text-muted);
}

/* Filter bar. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-bar select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
  color: inherit;
}

/* Overview rows and lookup cards. */
.overview-list,
.lookup-results {
  display: grid;
  gap: var(--space-2);
}

.overview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.overview-row__name {
  font-weight: 600;
}

.overview-row__email {
  color: var(--colour-text-muted);
  font-size: 0.9rem;
}

.lookup-card {
  margin: 0;
  padding: var(--space-3) var(--space-4);
}

/* Groups list. */
.groups-list {
  display: grid;
  gap: var(--space-2);
}

.group-item {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  background: var(--colour-surface);
}

.group-item__name {
  margin: 0 0 var(--space-1);
  font-size: 1rem;
}

.group-item__member {
  font-size: 0.85rem;
  color: var(--colour-text-muted);
}

/* Jobs panel. */
.jobs-panel {
  display: grid;
  gap: var(--space-2);
}

.job-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--colour-unlinked-fg);
  border-radius: var(--radius);
  background: var(--colour-unlinked-bg);
}

.job-row__label {
  font-weight: 600;
  color: var(--colour-unlinked-fg);
}
