/* Workspace composition only: where the panes sit and how wide they are.
   Components, colour and type come from dash-design. */

.dash-app--operational .dash-app__main:has(.workspace) {
  padding: 0;
}

/* Header: brand, sections, operator. */
.workspace-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dash-space-1);
}
.workspace-nav [aria-current="page"] {
  background: var(--dash-color-active);
  color: var(--dash-on-active);
}
.workspace-nav__count {
  font-family: var(--dash-font-mono);
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}
.workspace-operator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dash-space-2);
  margin-inline-start: auto;
}

/* Three panes: queue, conversation, what the agent reads. The page never
   scrolls as a whole: each pane is its own scroller, and the decision dock
   is a fixed row under the thread, so reading the history never moves the
   queue or the customer pane. */
.dash-app--operational .dash-app__main:has(.workspace) {
  overflow: hidden;
}
.workspace {
  display: grid;
  grid-template-columns:
    minmax(17rem, 23rem) minmax(0, 1fr)
    minmax(17rem, 22rem);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "queue head context"
    "queue main context";
  block-size: 100%;
  min-block-size: 0;
}
.workspace__queue {
  grid-area: queue;
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-2);
  padding-block: var(--dash-space-3);
  border-inline-end: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
  min-inline-size: 0;
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior-block: contain;
}
.workspace__header {
  grid-area: head;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--dash-space-2) var(--dash-space-3);
  padding: var(--dash-space-4) var(--dash-space-5);
  border-block-end: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
  background: var(--dash-ui-raised);
  min-inline-size: 0;
}
.workspace__identity {
  min-inline-size: 0;
}
.workspace__back,
.workspace__switch {
  display: none;
}
.workspace__switch {
  gap: var(--dash-space-1);
}
.workspace__main {
  grid-area: main;
  display: grid;
  /* The dock is as tall as its state needs, up to 60% of the pane. */
  grid-template-rows: minmax(0, 1fr) fit-content(60%);
  min-inline-size: 0;
  min-block-size: 0;
  background: var(--dash-ui-raised);
}
/* Before a conversation is open, or when it fails, the pane holds one
   message. */
.workspace__main > :only-child {
  grid-row: 1 / -1;
  align-self: start;
  margin: var(--dash-space-5);
}
.workspace__thread {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-3);
  padding: var(--dash-space-4) var(--dash-space-5);
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior-block: contain;
}
.workspace__context {
  grid-area: context;
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-4);
  padding: var(--dash-space-4);
  border-inline-start: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
  min-inline-size: 0;
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior-block: contain;
}
.workspace-page {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-4);
  padding: var(--dash-space-5);
  max-inline-size: 60rem;
}
.dash-app--operational .dash-app__main:has(.workspace-page) {
  overflow: auto;
}

/* Curation: the episode list and the episode scroll apart, and the footer
   that concludes an episode stays in view. */
.workspace--curation {
  grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "queue main";
}
.workspace__main--curation {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-4);
  padding: var(--dash-space-5) var(--dash-space-6) 0;
  overflow: auto;
  overscroll-behavior-block: contain;
}

/* Past its row's limit the dock scrolls itself, its actions pinned. */
.dock {
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior-block: contain;
}
/* Only engages when the dock overflows its row. */
.dock__actions {
  position: sticky;
  inset-block-end: 0;
  padding-block-start: var(--dash-space-2);
  background: var(--dash-ui-canvas);
}
/* A short desktop window: the thread and dock scroll as one, so neither is
   squeezed to nothing. */
@media (max-height: 40rem) {
  .workspace__main {
    display: block;
    overflow: auto;
  }
  .workspace__thread {
    overflow: visible;
  }
  .workspace__main .dock {
    overflow: visible;
  }
}

/* Tablet and small laptop: the reading pane takes the thread's place on
   request, from a switch in the conversation header. */
@media (max-width: 80rem) {
  .workspace {
    grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
    grid-template-areas:
      "queue head"
      "queue main";
  }
  .workspace__context {
    grid-area: main;
    border-inline-start: 0;
    display: none;
  }
  .workspace--context .workspace__context {
    display: flex;
  }
  .workspace--context .workspace__main {
    display: none;
  }
  .workspace__switch {
    display: flex;
  }
}

/* Phone: the queue and an open conversation are two pages. The conversation
   page drops the app header for its own, with the way back, and keeps the
   dock under the thread like a composer, its actions always reachable. */
@media (max-width: 48rem) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "main";
  }
  .workspace:not(.workspace--detail, .workspace--curation) {
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "queue";
  }
  .workspace:not(.workspace--detail, .workspace--curation) .workspace__main,
  .workspace--detail .workspace__queue {
    display: none;
  }
  .workspace__queue {
    border-inline-end: 0;
  }
  .dash-app--operational:has(.workspace--detail) > .dash-app__header {
    display: none;
  }
  .workspace__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    padding: var(--dash-space-2) var(--dash-space-3) var(--dash-space-3);
    padding-block-start: max(var(--dash-space-2), env(safe-area-inset-top));
  }
  .workspace__back {
    display: block;
  }
  .workspace__identity .dash-heading {
    font-size: var(--dash-text-lg);
  }
  .workspace__switch {
    grid-column: 1 / -1;
  }
  .workspace__switch .dash-button {
    flex: 1;
  }
  .workspace__export {
    display: none;
  }
  .workspace__thread {
    padding: var(--dash-space-3);
  }
  /* The thread and the dock keep their own scroll on a phone even when the
     on-screen keyboard makes the window short. */
  .workspace__main {
    display: grid;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr) fit-content(55%);
  }
  .workspace__thread,
  .workspace__main .dock {
    overflow: auto;
  }
  /* Writing takes the whole page, as with a keyboard: in a review mode, or
     whenever the reply field has focus. */
  .workspace__main--composing,
  .workspace__main:has(.dock textarea:focus) {
    grid-template-rows: 0 minmax(0, 1fr);
  }
  .workspace__main--composing .workspace__thread,
  .workspace__main:has(.dock textarea:focus) .workspace__thread {
    visibility: hidden;
  }
  .workspace__main--composing .dock,
  .workspace__main:has(.dock textarea:focus) .dock {
    border-block-start: 0;
  }
  .workspace__main .dock {
    padding: var(--dash-space-3);
    padding-block-end: max(var(--dash-space-3), env(safe-area-inset-bottom));
  }
  /* Curation on a phone is two pages: the episode list, then one episode
     with the way back. */
  .workspace--curation {
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "queue";
  }
  .workspace--curation .workspace__main--curation {
    display: none;
  }
  .workspace--curation.workspace--episode {
    grid-template-areas: "main";
  }
  .workspace--episode .workspace__queue {
    display: none;
  }
  .workspace--curation.workspace--episode .workspace__main--curation {
    display: flex;
    padding: var(--dash-space-3) var(--dash-space-3) 0;
  }
  .workspace--episode .curation__back {
    display: block;
    margin-inline-start: calc(-1 * var(--dash-space-2));
  }
  /* The app header is one row: brand, sections, the way out. */
  .dash-app--operational > .dash-app__header {
    flex-wrap: nowrap;
    gap: var(--dash-space-1);
    padding-block: var(--dash-space-2);
    padding-inline: max(var(--dash-space-3), env(safe-area-inset-left))
      max(var(--dash-space-3), env(safe-area-inset-right));
  }
  .dash-app--operational > .dash-app__header > .dash-text,
  .workspace-operator > .dash-text,
  .workspace-nav__long {
    display: none;
  }
  .workspace-nav {
    flex-wrap: nowrap;
    min-inline-size: 0;
    overflow-x: auto;
  }
  .workspace-nav .dash-button,
  .workspace-operator .dash-button {
    padding-inline: var(--dash-space-2);
    white-space: nowrap;
  }
  /* The dock's actions take one row, so the draft keeps most of the dock. */
  .dock__actions > .dash-cluster {
    gap: var(--dash-space-2);
  }
  .dock__actions .dock__deadline {
    flex-basis: 100%;
    min-inline-size: 0;
  }
  .dock__actions .dock__deadline .dash-progress {
    display: none;
  }
  .dock__actions .dash-flow__actions {
    display: flex;
    flex-wrap: nowrap;
    flex-basis: 100%;
    gap: var(--dash-space-2);
  }
  .dock__actions .dash-flow__actions > .dash-button {
    flex: 1 1 0;
    min-inline-size: 0;
    padding-inline: var(--dash-space-2);
  }
  .dock__actions .dash-flow__actions > .dash-button:last-child {
    flex-grow: 2;
  }
  /* Single-key shortcuts need a keyboard. */
  .dash-key {
    display: none;
  }
}

/* Queue. */
.queue__heading {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-1);
  padding: var(--dash-space-3) var(--dash-space-3) var(--dash-space-2);
  border-block-end: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
}
.queue__group--closed .queue__heading h2,
.queue__state--closed,
.queue__clock--closed {
  color: var(--dash-ui-danger);
}
.queue__rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.queue__row {
  border-block-end: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
}
.queue__row > .dash-record {
  inline-size: 100%;
  border-radius: 0;
}
.queue__row--current > .dash-record {
  background: var(--dash-ui-raised);
  box-shadow: inset 3px 0 0 var(--dash-ui-focus);
}
.queue__clock {
  display: inline-block;
  min-inline-size: 4.5rem;
  font-family: var(--dash-font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--dash-weight-medium, 500);
}
.queue__clock--soon {
  color: var(--dash-ui-warning);
}
.queue__clock--settled {
  color: var(--dash-ui-muted);
}
.queue__state {
  display: block;
  font-size: var(--dash-text-sm);
}
.queue__notices {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-1);
  margin-block-start: auto;
  padding: var(--dash-space-3);
  border-block-start: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
}
/* The account's sending state: one line, or a notice when Meta limits it. */
.queue__account {
  padding-inline: var(--dash-space-3);
}
.queue__account-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--dash-space-1);
  margin: 0;
}
.notices {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-4);
}

/* Decision dock. */
.dock {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-3);
  padding: var(--dash-space-4) var(--dash-space-5) var(--dash-space-5);
  border-block-start: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
  background: var(--dash-ui-canvas);
  /* Above the thread's positioned timeline markers and rail. */
  position: relative;
  z-index: 1;
}
.dock__draft {
  padding: var(--dash-space-3) var(--dash-space-4);
  border: var(--dash-border-hairline) dashed var(--dash-ui-muted);
  border-radius: var(--dash-radius-sm);
  background: var(--dash-ui-raised);
  white-space: pre-line;
}
.dock__draft--expired {
  color: var(--dash-ui-muted);
}
.dock__deadline {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-1);
  min-inline-size: 14rem;
  flex: 1;
}
.dock__deadline .dash-progress {
  max-inline-size: 18rem;
}
.dock__clock strong {
  font-family: var(--dash-font-mono);
  font-variant-numeric: tabular-nums;
}
.dock__clock--soon strong {
  color: var(--dash-ui-warning);
}
.dock__closed-since {
  color: var(--dash-ui-danger);
}
.dock__closed-since,
.dock .dash-panel h2 {
  color: var(--dash-ui-danger);
}
.dock__evidence-line {
  display: block;
}

/* The reading pane. */
.pane__numbered {
  margin: 0;
}
.pane__number {
  font-family: var(--dash-font-mono);
  font-size: var(--dash-text-xs);
  color: var(--dash-ui-muted);
  margin-inline-end: var(--dash-space-1);
}
.pane__outside {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--dash-space-1);
  padding-block-start: var(--dash-space-3);
  border-block-start: var(--dash-border-hairline) dashed
    var(--dash-ui-border-subtle);
}
.pane__note {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-2);
  margin-block-start: auto;
}

/* Closing a conversation without a reply sits apart from the send. */
.dock__resolve {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--dash-space-1) var(--dash-space-2);
  color: var(--dash-ui-muted);
}

/* Curation. */
.curation__back {
  display: none;
}
.curation__title {
  display: block;
  color: var(--dash-ui-ink);
}
.curation__episode-title {
  margin: 0;
  color: var(--dash-ui-ink);
  font-weight: 600;
}
.curation__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--dash-space-1);
  max-inline-size: 48rem;
}
.curation__section {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-2);
}
.curation__items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.curation__items > li {
  padding-block: var(--dash-space-3);
  border-block-end: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
}
.curation__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--dash-space-3);
  margin-block-start: auto;
  padding: var(--dash-space-4);
  border-block-start: var(--dash-border-hairline) solid
    var(--dash-ui-border-subtle);
  background: var(--dash-ui-canvas);
  position: sticky;
  inset-block-end: 0;
  /* Above the thread's positioned timeline markers and rail. */
  z-index: 1;
}

/* Message content. */
.inbox__placeholder {
  font-style: italic;
}
.inbox__image {
  display: block;
  max-inline-size: 100%;
  max-block-size: 22rem;
  border-radius: var(--dash-radius-md);
}

.workspace-page > .dash-button {
  align-self: flex-start;
}

/* An expired draft: never a message, so dashed and quiet. */
.thread__expired .dash-chat__message {
  border: var(--dash-border-hairline) dashed var(--dash-ui-muted);
  background: transparent;
  color: var(--dash-ui-muted);
}

/* A hint beside the dock's actions sits on their line. */
.dock__actions .dash-hint {
  align-self: center;
}

/* The internal thread: the operator's conversation with the internal agent
   about one customer. Its own tinted surface and banner keep it from ever
   being read as the customer's WhatsApp conversation. */
.internal-thread {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-3);
  padding: var(--dash-space-4);
  border: var(--dash-border-hairline) solid var(--dash-ui-category-plum);
  border-radius: var(--dash-radius-lg);
  background: var(--dash-ui-category-plum-surface);
  /* The pane or page around it scrolls; the thread never shrinks under
     its own content. */
  flex-shrink: 0;
}
.internal-thread__banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--dash-space-1) var(--dash-space-3);
  padding-block-end: var(--dash-space-3);
  border-block-end: var(--dash-border-hairline) dashed
    var(--dash-ui-category-plum);
}
.internal-thread__title {
  margin: 0;
  font-size: var(--dash-text-sm);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dash-ui-category-plum-ink);
}
.internal-thread__promise {
  margin: 0;
  color: var(--dash-ui-category-plum-ink);
}
.internal-thread__body {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-3);
}
.internal-thread__empty {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-1);
}
/* Messages sit on the canvas so they read clearly on the tinted surface. */
.internal-thread .dash-chat__message {
  background-color: var(--dash-ui-canvas);
}

/* A batch of the agent's proposals read from one source: one header with
   its size and approving those left. */
.internal-batch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--dash-space-2);
  padding-block-start: var(--dash-space-2);
  border-block-start: var(--dash-border-hairline) dashed
    var(--dash-ui-category-plum);
}
.internal-batch__title {
  margin: 0;
  font-weight: 650;
  color: var(--dash-ui-category-plum-ink);
}
.internal-source__title {
  margin: 0;
  font-weight: 650;
}
.internal-source__text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--dash-ui-ink);
}
.internal-source-form {
  display: flex;
  flex-direction: column;
  gap: var(--dash-space-3);
}
