/* --- prompt editor -------------------------------------------------------- */

.prompt-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.prompt-panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

#prompt-dirty {
  font-size: 0.8rem;
  color: var(--error);
  align-self: center;
}

#prompt-opening {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: var(--surface-sunken);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
}

#prompt-content {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--surface-sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
}

#prompt-preview {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 0.9rem;
  line-height: 1.55;
  max-height: 24rem;
  overflow-y: auto;
}

/* The global margin reset strips the UA spacing the rendered markdown needs. */
#prompt-preview h1 { font-size: 1.15rem; }
#prompt-preview h2 { font-size: 1rem; }
#prompt-preview h3,
#prompt-preview h4 { font-size: 0.92rem; }
#prompt-preview h1,
#prompt-preview h2,
#prompt-preview h3,
#prompt-preview h4 { margin: 0.9em 0 0.35em; }
#prompt-preview h1:first-child { margin-top: 0; }
#prompt-preview p { margin: 0.4em 0; }
#prompt-preview ul { margin: 0.4em 0; padding-left: 1.4em; }
#prompt-preview code {
  padding: 0.05em 0.3em;
  border-radius: 4px;
  background: var(--accent-soft);
  font-size: 0.85em;
}


.view-admin {
  flex: 1;
  display: flex;
  min-height: 0;
}

.admin-nav {
  width: 14rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 0.6rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.admin-nav h1 {
  padding: 0.6rem 0.6rem 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

#admin-tabs {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#admin-tabs a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

#admin-tabs a:hover {
  background: var(--hover);
}

#admin-tabs a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.admin-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
}

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

/* Persona and transcript tabs: a picker column beside a detail column. */
.personas,
.transcripts,
.groups {
  flex: 1;
  display: flex;
  min-width: 0; /* a long user name in a select must not widen the panel */
  min-height: 0;
}

.persona-picker,
.transcripts-picker,
.groups-picker {
  width: 17rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 0.6rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

/* The way back stays in view however far the picker scrolls; a long group name is
   cut short (its title holds the full text). */
#transcripts-back {
  position: sticky;
  top: -0.75rem; /* the picker's top padding: no list row shows above it */
  z-index: 1;
  flex-shrink: 0;
  margin-top: -0.75rem;
  padding-top: calc(0.35rem + 0.75rem);
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rows scrolled or focused into view stop below the pinned link, not under it. */
.transcripts-picker:has(#transcripts-back:not(.hidden)) {
  scroll-padding-top: 2.75rem;
}

#persona-list,
.admin-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#persona-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

/* Admin list rows are links (keyboard, open in new tab); the link fills the row. */
.admin-list li {
  border-radius: 6px;
}

.admin-list li > a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-wrap: anywhere;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

#persona-list li:hover,
.admin-list li:hover {
  background: var(--hover);
}

#persona-list li.active,
.admin-list li.active {
  background: var(--accent-soft);
}

#persona-list li.active .persona-name,
.admin-list li.active .conv-title {
  color: var(--accent);
  font-weight: 500;
}

.persona-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.badge {
  font-size: 0.68rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: var(--hover);
  color: var(--muted);
  white-space: nowrap;
}

.badge.status-password_pending {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.status-blocked {
  background: var(--error-soft);
  color: var(--error);
}

.persona-detail,
.transcripts-reader,
.group-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.25rem 1.75rem;
  overflow-y: auto;
}

.persona-detail h2,
.reader-head h2,
.group-pane h2 {
  font-size: 1.2rem;
  overflow-wrap: anywhere; /* group and conversation names can be one long word */
}

/* The persona name doubles as its rename button. */
.persona-title {
  font-size: inherit;
  font-weight: inherit;
  margin-left: -0.4rem;
  padding: 0.1rem 0.4rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.persona-title:not(:disabled):hover {
  background: var(--hover);
}

/* Same box as the name it replaces, so editing doesn't shift the page. */
.persona-title-input {
  width: min(100%, 32rem);
  margin-left: -0.4rem;
  padding: 0.1rem 0.4rem;
  font-size: 1.2rem;
  font-weight: bold;
}

.persona-title:disabled,
.persona-title:disabled:hover {
  opacity: 1;
  cursor: text;
}

.persona-sections:empty {
  display: none;
}

.persona-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.persona-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.reader-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.reader-body {
  display: flex;
  gap: 1rem;
  min-height: 0;
}

.reader-transcript {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.reader-side {
  width: 19rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.reader-side h3 {
  font-size: 0.95rem;
}

.reader-feedback {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.users {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 0.5rem;
  overflow: auto;
}

.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

.users-toolbar input[type="search"] {
  min-width: 12rem;
}

/* A long group name must not stretch the group filter past a phone screen, nor push
   the buttons onto a row of their own; the open list still shows full names. */
.users-toolbar label {
  max-width: 100%;
}

.users-toolbar select {
  max-width: 16rem;
}

.toolbar-spacer {
  flex: 1;
}

/* The table scrolls sideways on its own, never the page or the toolbar. */
.users-table-scroll {
  flex-shrink: 0;
  overflow-x: auto;
}

.users .admin-table {
  max-width: none;
}

/* Eleven columns (four of them action slots) must fit 1280px in both languages. */
.users .admin-table th,
.users .admin-table td {
  padding-left: 0.3rem;
  padding-right: 0.3rem;
}

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

.admin-table th,
.admin-table td {
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.admin-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.admin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table tbody tr {
  cursor: pointer;
}

.admin-table tbody tr:hover {
  background: var(--accent-soft);
}

.admin-table tr.removed td {
  color: var(--muted);
}

.admin-table td a {
  color: var(--accent);
  text-decoration: none;
}

.admin-table td a:hover {
  text-decoration: underline;
}

.admin-table tr.removed td a {
  color: inherit;
}

/* One line per row: names, statuses and dates never wrap; groups wrap only between names. */
.admin-table .user-name,
.admin-table .user-terms,
.admin-table .user-groups a {
  white-space: nowrap;
}

/* Capped so no name can push the table past 1280px in Danish; the title holds the
   full name. Danish leaves about 255px for both columns together. */
.admin-table .user-name a,
.admin-table .user-groups a {
  display: inline-block;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.admin-table .user-name:has(.user-you) a {
  max-width: 6.5rem;
}

.admin-table .user-groups a {
  max-width: 5rem;
}

.admin-table .user-group {
  white-space: nowrap;
}

.user-you {
  color: var(--muted);
}

.admin-table tbody.users-placeholder tr {
  cursor: default;
}

.admin-table tbody.users-placeholder tr:hover {
  background: none;
}

/* One cell per action slot, so each action lines up in its own column. */
.users .admin-table .row-actions {
  white-space: nowrap;
  cursor: default;
  padding-left: 0;
  padding-right: 0;
}

.users .admin-table .row-actions.slot-remove {
  padding-right: 0.3rem;
  text-align: right;
}

.row-actions button {
  padding: 0.2rem 0.25rem;
  font-size: 0.8rem;
}

/* Block/Unblock: the hidden other label holds the width, so toggling moves nothing. */
.row-actions button[data-alt] {
  display: inline-grid;
  justify-items: center;
}

.row-actions button[data-alt] > span,
.row-actions button[data-alt]::after {
  grid-area: 1 / 1;
}

.row-actions button[data-alt]::after {
  content: attr(data-alt);
  visibility: hidden;
}


/* The global label rule stacks vertically; checkboxes want their text beside them. */
label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

label.check input {
  padding: 0;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0;
  border: none;
}

.check-list legend {
  padding: 0;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Wider than the shared 24rem dialogs; the rest comes from the shared lists in style.css. */
.admin-dialog {
  width: 28rem;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Gap + margin add up to the 1.1rem the actions get outside a form. */
.dialog-form > .dialog-actions {
  margin-top: 0.2rem;
}

.dialog-form textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.dialog-error {
  color: var(--error);
  font-size: 0.85rem;
}

ul.dialog-error {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.result-body {
  max-height: 50vh;
  margin-top: 0.6rem;
  overflow-y: auto;
}

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

.result-table th,
.result-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.result-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.temp-password {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  user-select: all;
}

.settings {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1.75rem;
  overflow-y: auto;
  max-width: 44rem;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 1.25rem;
  border: none;
  border-bottom: 1px solid var(--border);
}

.setting legend {
  padding: 0;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.setting-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

/* The global label rule stacks vertically; radios want their text beside them. */
label.radio {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

label.radio input {
  padding: 0;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.saved {
  font-size: 0.8rem;
  color: var(--accent);
}

/* Delete sits apart from the editing controls, at the far end of the row. */
#coachee-delete {
  margin-left: auto;
}

/* --- groups --------------------------------------------------------------- */

.group-detail {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.group-form,
.group-members-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 30rem;
}

/* Each field is a unit (caption, control, hint), set apart from the next one. */
.group-form {
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.group-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.group-add {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Long enough to scan a cohort, short enough to keep the member list in view. */
.group-picker {
  max-height: 12rem;
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere; /* a 64-character username has no break opportunities */
}

/* Delete sits apart from Save, at the far end of the row. */
#group-delete {
  margin-left: auto;
}

/* Saving: looks disabled but keeps keyboard focus (a disabled button would drop it). */
#group-save[aria-disabled="true"] {
  cursor: default;
  opacity: 0.5;
}

.group-members-section h3 {
  font-size: 0.95rem;
}

.group-members {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.group-members li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2.3rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.member-who {
  display: flex;
  flex-wrap: wrap; /* on a phone the badge goes under the name, not beside it */
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The action keeps its one line; a long name wraps instead. */
.group-members li > button {
  flex-shrink: 0;
  white-space: nowrap;
}

.group-members a {
  color: var(--accent);
  text-decoration: none;
}

.group-members a:hover {
  text-decoration: underline;
}

/* Removed users keep their membership (the class still finds their
   transcripts) but are no longer editable here. */
.group-members li.removed {
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
}

.group-members li.removed a {
  color: inherit;
}

/* Beside the nav and the picker, a 19rem AI feedback panel squeezes the transcript
   below about 81rem: the panel narrows first, then goes under the transcript. */
@media (max-width: 81rem) {
  .reader-side {
    width: 15rem;
  }
}

@media (max-width: 75rem) {
  .reader-body {
    flex-direction: column;
  }

  .reader-side {
    width: auto;
  }
}

/* --- narrow screens (same breakpoint as chat.css) -------------------------- */

@media (max-width: 64rem) {
  .view-admin {
    flex-direction: column;
  }

  .admin-nav {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.4rem 0.6rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .admin-nav h1 {
    padding: 0 0.3rem;
  }

  #admin-tabs {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .admin-nav .sidebar-footer {
    margin-top: 0;
    margin-left: auto;
  }

  /* The settings menu opens upward from the sidebar's foot; here it hangs down. */
  .admin-nav .menu-popover {
    top: calc(100% + 0.4rem);
    bottom: auto;
    left: auto;
    min-width: 12rem;
  }

  .personas,
  .transcripts,
  .groups {
    flex-direction: column;
  }

  .persona-picker,
  .transcripts-picker,
  .groups-picker {
    width: auto;
    flex-shrink: 0;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .persona-detail,
  .transcripts-reader,
  .group-pane {
    padding: 1rem;
  }

  .reader-transcript .bubble {
    max-width: 90%;
  }

  /* Not .group-add: it is a column, and a wrapping column sizes to its widest item. */
  .reader-head,
  .group-actions {
    flex-wrap: wrap;
  }
}
