/*
 * The staff console (plan 04-20, 04-UI-SPEC "Moderation Console"). A working page for two people, so it is
 * quiet: the app's own role values (src/ui/tokens.ts, light and dark by prefers-color-scheme), the system
 * font, four sizes (18, 16, 24 and the unused 32) and two weights (400, 600). The one thing that stands out
 * is the reported message inside its conversation, outlined in the accent colour.
 *
 * Every pointer target is at least 48 px high, every control has a text label, and keyboard focus is a
 * 3 px accent ring. Below 1024 px wide only "Open this page on a computer." is shown.
 *
 * No inline styles anywhere (the CSP allows style-src self only), and no resource references: nothing is loaded from
 * outside this folder except the images signed for a case, which are set from script.
 */

:root {
  color-scheme: light dark;

  --dominant: #FAF7F4;
  --secondary: #F0EAE3;
  --accent: #1F5A9E;
  --accent-pressed: #174580;
  --accent-tint: #E3ECF7;
  --destructive: #B3261E;
  --on-accent: #FFFFFF;
  --on-destructive: #FFFFFF;
  --text: #1B1B1F;
  --text-secondary: #5C5C66;
  --field: #FFFFFF;
  --border-strong: #8A8178;
  --divider: #E2DAD0;
  --disabled-fill: #E4DED6;
  --disabled-text: #5F5A54;

  --size-body: 18px;
  --size-label: 16px;
  --size-heading: 24px;
  --weight-regular: 400;
  --weight-semibold: 600;

  --xs: 4px;
  --sm: 8px;
  --md: 16px;
  --lg: 24px;
  --xl: 32px;
  --xxl: 48px;

  --target: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --dominant: #1A1816;
    --secondary: #27231F;
    --accent: #8DB4F0;
    --accent-pressed: #6F9FE6;
    --accent-tint: #1F2E45;
    --destructive: #F2877F;
    --on-accent: #10203A;
    --on-destructive: #2B0B08;
    --text: #F3EFEA;
    --text-secondary: #BDB6AD;
    --field: #211E1B;
    --border-strong: #8F867C;
    --divider: #3A352F;
    --disabled-fill: #2E2A26;
    --disabled-text: #A09A92;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--size-body);
  line-height: 1.5;
  background: var(--dominant);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
}

h1,
h2,
h3 {
  margin: 0;
  font-size: var(--size-heading);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
}

h3 {
  font-size: var(--size-label);
  line-height: 1.5;
}

p {
  margin: 0;
  max-width: 68ch;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

/* Keyboard focus: a 3 px accent ring on everything that takes it. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

h1:focus-visible,
h2:focus-visible,
main:focus-visible {
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: var(--md);
  top: -80px;
  min-height: var(--target);
  padding: var(--sm) var(--md);
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: var(--weight-semibold);
  z-index: 10;
}

.skip:focus {
  top: var(--sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.narrow-notice {
  display: none;
  padding: var(--xl) var(--lg);
  font-size: var(--size-heading);
  font-weight: var(--weight-semibold);
}

@media (max-width: 1023.98px) {
  .app-root {
    display: none;
  }

  .narrow-notice {
    display: block;
  }
}

/* ---- shell ---------------------------------------------------------------------------------- */

.app-root {
  min-width: 1024px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md);
  min-height: 64px;
  padding: 0 var(--lg);
  background: var(--secondary);
  border-bottom: 1px solid var(--divider);
}

.who {
  display: flex;
  align-items: center;
  gap: var(--md);
}

.staff-name {
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

main {
  min-height: calc(100vh - 64px);
}

/* ---- sign-in cards -------------------------------------------------------------------------- */

.card {
  max-width: 560px;
  margin: var(--xxl) auto;
  padding: 0 var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

.card form {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
  margin-top: var(--sm);
}

label,
legend {
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

input[type='email'],
input[type='text'],
select,
textarea {
  width: 100%;
  min-height: var(--target);
  padding: var(--sm) var(--md);
  font: inherit;
  font-size: var(--size-body);
  color: var(--text);
  background: var(--field);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

select {
  width: auto;
  min-width: 160px;
}

.qr {
  align-self: flex-start;
  background: #FFFFFF;
  padding: var(--sm);
  border-radius: 12px;
  border: 1px solid var(--divider);
}

.secret-line code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  word-break: break-all;
}

.error {
  color: var(--destructive);
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--md);
}

/* ---- buttons -------------------------------------------------------------------------------- */

.button {
  min-height: var(--target);
  min-width: var(--target);
  padding: var(--sm) var(--lg);
  font: inherit;
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  border-radius: 24px;
  border: 1.5px solid transparent;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button.primary:hover {
  background: var(--accent-pressed);
}

.button.secondary {
  background: var(--field);
  color: var(--accent);
  border-color: var(--accent);
}

.button.text {
  background: transparent;
  color: var(--accent);
  padding-left: var(--md);
  padding-right: var(--md);
}

.button.destructive {
  background: var(--destructive);
  color: var(--on-destructive);
}

.button:disabled {
  background: var(--disabled-fill);
  color: var(--disabled-text);
  border-color: transparent;
  cursor: not-allowed;
}

/* ---- console: three regions ----------------------------------------------------------------- */

.console {
  display: grid;
  grid-template-columns: 200px 360px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.nav {
  padding: var(--md);
  background: var(--secondary);
  border-right: 1px solid var(--divider);
}

.nav ul {
  display: flex;
  flex-direction: column;
  gap: var(--xs);
}

.nav-item {
  width: 100%;
  min-height: var(--target);
  padding: var(--sm) var(--md);
  text-align: left;
  font: inherit;
  font-size: var(--size-label);
  font-weight: var(--weight-regular);
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.nav-item[aria-current='page'] {
  font-weight: var(--weight-semibold);
  background: var(--accent-tint);
}

.queue-pane {
  padding: var(--md);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

.field-row {
  display: flex;
  align-items: center;
  gap: var(--sm);
}

.count {
  font-size: var(--size-label);
  color: var(--text-secondary);
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--xs);
}

.queue-row {
  width: 100%;
  min-height: 64px;
  padding: var(--sm) var(--md);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--divider);
  border-left: 4px solid var(--divider);
  border-radius: 12px;
  cursor: pointer;
}

.queue-row[aria-current='true'] {
  background: var(--accent-tint);
  border-left-color: var(--accent);
}

.queue-row .reason {
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

.queue-row .meta {
  font-size: var(--size-label);
  color: var(--text-secondary);
}

.badge {
  display: inline-block;
  margin-left: var(--sm);
  padding: 0 var(--sm);
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  color: var(--text);
  background: var(--accent-tint);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
}

.skeleton {
  min-height: 64px;
  background: var(--secondary);
  border-radius: 12px;
}

.empty h3 {
  font-size: var(--size-heading);
  line-height: 1.2;
}

.pager {
  display: flex;
  gap: var(--sm);
}

/* ---- case pane ------------------------------------------------------------------------------ */

.case-pane {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--lg);
  min-width: 0;
}

.placeholder {
  color: var(--text-secondary);
}

.notice {
  padding: var(--sm) var(--md);
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  background: var(--accent-tint);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
}

.notice-line {
  padding: var(--sm) var(--md);
  background: var(--secondary);
  border-radius: 12px;
  font-weight: var(--weight-semibold);
}

#case-body {
  display: flex;
  flex-direction: column;
  gap: var(--lg);
}

.case-section {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.meta {
  font-size: var(--size-label);
  color: var(--text-secondary);
}

.erased {
  padding: var(--md);
  background: var(--secondary);
  border-radius: 12px;
}

/* The conversation: the reported message is the one outlined thing on the page. */
.context {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
  max-width: 720px;
}

.msg {
  padding: var(--sm) var(--md);
  background: var(--secondary);
  border: 1px solid var(--divider);
  border-radius: 12px;
}

.msg.from-reported {
  background: var(--field);
}

.msg.reported {
  border: 2px solid var(--accent);
}

.msg-head {
  font-size: var(--size-label);
  color: var(--text-secondary);
}

.msg-head .who {
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.flag {
  display: inline-block;
  padding: 0 var(--sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  background: var(--accent-tint);
  border-radius: 12px;
}

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tile {
  display: inline-block;
  padding: var(--md);
  background: var(--secondary);
  border-radius: 12px;
  color: var(--text-secondary);
}

.prompts dt {
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

.prompts dd {
  margin: 0 0 var(--md);
  overflow-wrap: anywhere;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--md);
}

.photo-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sm);
  min-width: 200px;
}

.photo-label {
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}

.photo {
  display: block;
  max-width: 320px;
  max-height: 400px;
  border-radius: 12px;
}

.history {
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

.history li {
  padding-left: var(--md);
  border-left: 3px solid var(--divider);
}

.actions {
  position: sticky;
  bottom: 0;
  padding: var(--md) 0;
  background: var(--dominant);
}

/* ---- audit log ------------------------------------------------------------------------------ */

.console.audit-mode {
  grid-template-columns: 200px minmax(0, 1fr);
}

.audit-pane {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
  min-width: 0;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-label);
}

.audit-table th,
.audit-table td {
  padding: var(--sm) var(--md);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--divider);
}

.audit-table th {
  font-weight: var(--weight-semibold);
}

.note-cell {
  overflow-wrap: anywhere;
}

.pager {
  align-items: center;
  margin-top: var(--md);
}

/* ---- action dialog -------------------------------------------------------------------------- */

.dialog {
  width: min(560px, calc(100vw - 2 * var(--lg)));
  max-height: calc(100vh - 2 * var(--lg));
  padding: var(--lg);
  color: var(--text);
  background: var(--dominant);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialog form {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.dialog-description {
  min-height: 1.5em;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: var(--xs);
  margin: var(--sm) 0;
  padding: 0;
  border: 0;
}

.choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sm);
  min-height: var(--target);
  padding: var(--xs) var(--md);
  font-weight: var(--weight-regular);
  font-size: var(--size-body);
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--field);
}

.choice input {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}
