/*
 * Work item queue — screen 00 (contract §2, approved template
 * docs/design/screens/step-00-work-item-queue.html).
 *
 * board.css carries the shared chrome (topbar, wrap, lede, card, spinner,
 * banner, sign-out) and is READ-ONLY from here; this file adds ONLY what the
 * queue itself needs, scoped under #s-work-items so it cannot leak into the
 * other screens and so the whole block lifts into the quotebench shell as an
 * `s-` section later without a restyle (ui-engineer charter).
 *
 * Every colour, radius and shadow is a theme.css token. The single exception is
 * the --drop pair below, which the approved template introduced for a state no
 * existing token covers: "this is a live drop target". It is declared here, once,
 * rather than inlined at each use — a screen-scoped token, not a hard-coded
 * colour. Deliberately single-theme (light) until theme.css grows a dark palette.
 */

#s-work-items {
  --drop: #0f6fbf;
  --drop-bg: #e7f1fb;
}

/* ── the nav's unallocated badge ──────────────────────────────────────── */
/* Carries the count into every screen's chrome, so the queue announces itself
 * from the board and the workbench too. Hidden at zero rather than showing a
 * "0" — a badge that never goes away stops being a signal. */
.topnav .navcount {
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  background: var(--gap-bg);
  color: var(--gap-ink);
  border-radius: 20px;
  padding: 0 6px;
  font-weight: 600;
  margin-left: 7px;
}

/* ── 70 / 30 ──────────────────────────────────────────────────────────── */
#s-work-items .split {
  display: grid;
  grid-template-columns: minmax(0, 70fr) minmax(0, 30fr);
  align-items: start;
}
#s-work-items .col-left {
  padding-right: 26px;
}
#s-work-items .col-right {
  border-left: 1px solid var(--line);
  padding-left: 26px;
  position: sticky;
  top: 18px;
}
/* Below 900px the sticky right column would eat the viewport, so the split
 * unstacks and the tender list follows the queue it serves. */
@media (max-width: 900px) {
  #s-work-items .split {
    grid-template-columns: minmax(0, 1fr);
  }
  #s-work-items .col-left {
    padding-right: 0;
  }
  #s-work-items .col-right {
    border-left: none;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 24px;
    margin-top: 26px;
    position: static;
  }
}

#s-work-items .col-hd {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 12px;
}
#s-work-items .col-hd h2 {
  font-family: var(--display);
  font-size: 15px;
  margin: 0;
  letter-spacing: -0.01em;
}
#s-work-items .col-hd .n {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--paper-2);
  color: var(--ink-2);
  border-radius: 20px;
  padding: 1px 8px;
}
#s-work-items .col-hd .hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ── the queue filters ────────────────────────────────────────────────── */
/* Sits under the column heading and above the cards, because it governs the list
 * below it and nothing else on the screen. Quiet by default: this is a control
 * an estimator reaches for occasionally, not the subject of the page. */
#s-work-items .col-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
}
#s-work-items .col-filters .filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
}
#s-work-items .col-filters select {
  font: inherit;
  font-size: 12px;
  color: var(--ink-1);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px 8px;
}
#s-work-items .col-filters select:focus-visible {
  outline: 2px solid var(--gap-ink);
  outline-offset: 1px;
}

/* ── work item cards ──────────────────────────────────────────────────── */
/* The red left edge is the unallocated state itself — every card in this column
 * is by definition missing its tender, so the edge reads as "this is the thing
 * to clear" rather than as an error on one row. */
#s-work-items .wi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gap-ink);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: grab;
  transition:
    box-shadow 0.12s,
    border-color 0.12s;
}
#s-work-items .wi:hover {
  box-shadow:
    0 2px 4px rgba(16, 24, 40, 0.08),
    0 6px 14px rgba(16, 24, 40, 0.1);
}
#s-work-items .wi:focus-visible {
  outline: 2px solid var(--drop);
  outline-offset: 2px;
}
#s-work-items .wi.dragging {
  opacity: 0.45;
  cursor: grabbing;
}
/* "Armed": this card is waiting for a tender to be clicked. The whole right
 * column changes with it, which is what makes the no-drag path discoverable. */
#s-work-items .wi.picked {
  border-color: var(--drop);
  border-left-color: var(--drop);
  background: var(--drop-bg);
}
#s-work-items .wi-t {
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 5px;
  letter-spacing: -0.005em;
}
#s-work-items .wi-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-3);
}

#s-work-items .pill {
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
#s-work-items .p-email {
  background: var(--look-bg);
  color: var(--look);
}
#s-work-items .p-mcp {
  background: var(--ready-bg);
  color: var(--ready);
}
#s-work-items .p-none {
  background: var(--gap-bg);
  color: var(--gap-ink);
}
/* A delivery that IS on a tender. Reads as settled rather than outstanding — the
 * opposite of .p-none, which is the whole point of the distinction. */
#s-work-items .p-tender {
  background: var(--ready-bg);
  color: var(--ready);
  text-transform: none;
  letter-spacing: 0.01em;
}

#s-work-items .wi-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  align-items: center;
}
/* 44px minimum touch target (ui-engineer charter) without inflating the visual
 * button: the padding is small, the tap area is not. */
#s-work-items .btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  border-radius: 7px;
  padding: 4px 11px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}
#s-work-items .btn:hover {
  background: var(--paper);
  color: var(--ink);
}
#s-work-items .btn.primary {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
  font-weight: 600;
}
#s-work-items .btn.primary:hover {
  filter: brightness(1.05);
}
#s-work-items .btn:focus-visible {
  outline: 2px solid var(--drop);
  outline-offset: 2px;
}
#s-work-items .btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

/* ── tender search + list ─────────────────────────────────────────────── */
#s-work-items .search {
  position: relative;
  margin-bottom: 6px;
}
#s-work-items .search input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 9px 12px 9px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 44px;
}
#s-work-items .search input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
#s-work-items .search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
}
#s-work-items .search-note {
  font-size: 11px;
  color: var(--ink-3);
  margin: 0 0 12px;
}

#s-work-items .tender {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  margin-bottom: 8px;
  transition:
    border-color 0.12s,
    background 0.12s;
}
#s-work-items .tender.over {
  border-color: var(--drop);
  background: var(--drop-bg);
  border-style: dashed;
}
#s-work-items .tender.armed {
  border-color: var(--drop);
}
#s-work-items .tender-t {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 3px;
  letter-spacing: -0.005em;
}
/* Inherits the title's weight and colour rather than looking like body-copy link
 * text: the card is the object, and the underline on hover is enough to say it
 * opens. Focus is visible because this is the keyboard route to a tender. */
#s-work-items .tender-link {
  color: inherit;
  text-decoration: none;
}
#s-work-items .tender-link:hover {
  text-decoration: underline;
}
#s-work-items .tender-link:focus-visible {
  outline: 2px solid var(--gap-ink);
  outline-offset: 2px;
  border-radius: 3px;
}
#s-work-items .tender-m {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
#s-work-items .tid {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
#s-work-items .tender-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
}
/* The attach button appears only while something is armed: an idle list of
 * tenders should not offer an action that has no subject. */
#s-work-items .tender-assign {
  display: none;
  margin-top: 8px;
}
#s-work-items .tender.armed .tender-assign {
  display: block;
}
#s-work-items .tender-assign .btn {
  width: 100%;
}

#s-work-items .newtender {
  border: 1px dashed var(--line);
  background: var(--paper);
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
  margin-bottom: 8px;
  transition:
    border-color 0.12s,
    background 0.12s;
}
#s-work-items .newtender.over,
#s-work-items .newtender.armed {
  border-color: var(--brand);
  background: var(--brand-soft);
}
#s-work-items .newtender-t {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
#s-work-items .newtender-s {
  font-size: 11px;
  color: var(--ink-3);
}

/* ── the new-tender form (contract §2.2b) ─────────────────────────────── */
/* A drop here cannot mint a tender on its own — project_name is required — so
 * the gesture opens this, and the attach happens after the create returns. */
#s-work-items .newform {
  border: 1px solid var(--brand);
  background: var(--panel);
  border-radius: var(--r);
  padding: 12px;
  margin-bottom: 8px;
  text-align: left;
}
#s-work-items .newform h3 {
  font-family: var(--display);
  font-size: 12.5px;
  margin: 0 0 2px;
}
#s-work-items .newform .for-item {
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0 0 10px;
}
#s-work-items .newform label {
  display: block;
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 600;
  margin-bottom: 3px;
}
#s-work-items .newform input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  margin-bottom: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  min-height: 44px;
}
#s-work-items .newform input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
  border-color: var(--brand);
}
#s-work-items .newform .row {
  display: flex;
  gap: 7px;
}
#s-work-items .newform .row .btn {
  flex: 1;
}

#s-work-items .noresults {
  font-size: 12px;
  color: var(--ink-3);
  padding: 14px 2px;
}

/* ── empty state ──────────────────────────────────────────────────────── */
/* The normal terminal state of this screen, not an error — so it is styled as
 * an achievement and points at the board, which is where the work continues. */
#s-work-items .empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 34px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
#s-work-items .empty h3 {
  font-family: var(--display);
  font-size: 17px;
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
#s-work-items .empty p {
  color: var(--ink-2);
  margin: 0 auto 16px;
  max-width: 46ch;
  font-size: 13px;
}
#s-work-items .empty .go {
  display: flex;
  gap: 9px;
  justify-content: center;
  flex-wrap: wrap;
}
#s-work-items .empty .go .btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
#s-work-items .tick {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ready-bg);
  color: var(--ready);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  font-size: 17px;
}

/* ── undo toast ───────────────────────────────────────────────────────── */
/* Lives outside #s-work-items because it is position: fixed to the viewport,
 * so scoping it to the section would buy nothing and cost a reader's time. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 90px);
  background: var(--ink);
  color: #fff;
  border-radius: 9px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 26px rgba(16, 24, 40, 0.28);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1),
    opacity 0.22s;
  z-index: 40;
  max-width: calc(100vw - 32px);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.toast button {
  background: none;
  border: 1px solid #4a525e;
  color: #fff;
  border-radius: 6px;
  padding: 3px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.toast button:hover {
  background: #2a313b;
}
.toast button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  #s-work-items .wi,
  #s-work-items .tender,
  #s-work-items .newtender {
    transition: none;
  }
}

/* ── utilities ────────────────────────────────────────────────────────── */
/* Same shape as #s-tender .sr-only (tender.css:402). Duplicated rather than
 * hoisted into board.css: that file is the shared chrome and is READ-ONLY from
 * this lane. Hoisting both copies into it is a tidy-up for whoever owns the
 * shell next, not a change to smuggle in under a screen. */
#s-work-items .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* ═══ the drawer (Bullet 3p-b, s137) ══════════════════════════════════════
 * What actually arrived, one delivery at a time. Fetched ON EXPAND — §2.2a
 * rules out a fetch per card, which is why the closed card still shows no file
 * count until the drawer has been opened once.
 * ════════════════════════════════════════════════════════════════════════ */

#s-work-items .wi-t {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
/* The twisty is inside the card's drag surface, so it stops propagation in JS.
 * It keeps the 44px tap target the charter asks for via padding, not size. */
#s-work-items .twist {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 9px;
  line-height: 1;
  padding: 6px;
  margin: -6px 0 -6px -6px;
  cursor: pointer;
  border-radius: 5px;
  flex: none;
  transition: transform 0.14s ease;
}
#s-work-items .twist:hover {
  background: var(--paper-2);
  color: var(--ink);
}
#s-work-items .twist[aria-expanded="true"] {
  transform: rotate(90deg);
  color: var(--ink-2);
}

#s-work-items .p-files {
  background: var(--paper-2);
  color: var(--ink-2);
}
/* A price book is the one thing on this screen that leads somewhere else, so it
 * is the one pill wearing the brand colour. */
#s-work-items .p-book {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
}

#s-work-items .drawer {
  margin: 10px -13px -11px;
  padding: 2px 0 0;
  border-top: 1px solid var(--line-2);
  background: var(--paper-2);
  border-radius: 0 0 var(--r) var(--r);
}
#s-work-items .drawer-hint,
#s-work-items .drawer-empty {
  margin: 0;
  padding: 8px 13px;
  font-size: 11.5px;
  color: var(--ink-3);
}
#s-work-items .drawer .banner,
#s-work-items .drawer .placeholder {
  margin: 8px 13px;
}

#s-work-items .files {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
}
#s-work-items .file {
  display: grid;
  /* tick · format · name · tender · role · import-or-imported */
  grid-template-columns: auto 34px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 9px;
  padding: 5px 13px;
}
#s-work-items .file[draggable="true"] {
  cursor: grab;
}
#s-work-items .file.dragging {
  opacity: 0.45;
}
#s-work-items .file.ticked {
  background: color-mix(in srgb, var(--brand) 9%, transparent);
}
/* 44px of hit area without a 44px-tall row: the box stays small, the padding
 * around it does the touch work. */
#s-work-items .fpick {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 14px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* Which tender the FILE is on. "no tender" is written in words rather than left
 * blank: an empty cell reads as "not loaded", and that is a different fact. */
#s-work-items .ftender {
  font-size: 11px;
  color: var(--ink-2);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#s-work-items .ftender.none {
  color: var(--ink-3);
  font-style: italic;
}

/* Stands where the button was, and deliberately does not look like one — there
 * is nothing left to press. */
#s-work-items .imported {
  font-size: 11px;
  font-weight: 600;
  color: var(--ready);
  background: var(--ready-bg);
  border: 1px solid color-mix(in srgb, var(--ready) 30%, transparent);
  border-radius: 7px;
  padding: 5px 8px;
  white-space: nowrap;
}
#s-work-items .file + .file {
  border-top: 1px solid var(--line-2);
}
#s-work-items .file:hover {
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}
/* The status line spans the full width beneath the row it belongs to, so a long
 * refusal wraps under the file instead of squeezing the name to nothing. */
#s-work-items .frow-status {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--ink-3);
}
#s-work-items .frow-status:empty {
  display: none;
}
#s-work-items .frow-status.bad {
  color: var(--gap-ink);
}
#s-work-items .frow-status.good {
  color: var(--ready);
}

#s-work-items .ftype {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 3px 0;
  border-radius: 4px;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line);
}
#s-work-items .ftype.t-csv {
  color: var(--ready);
  background: var(--ready-bg);
  border-color: color-mix(in srgb, var(--ready) 30%, transparent);
}

#s-work-items .fname {
  min-width: 0;
}
/* Third-party filenames are long and the interesting part is usually the end,
 * but truncating from the left reads as broken — so it ellipsises and the full
 * name is on the title attribute. */
#s-work-items .fname .n {
  display: block;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#s-work-items .fname .s {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--mono);
}

#s-work-items .role {
  font: inherit;
  font-size: 11.5px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 6px;
  cursor: pointer;
  min-height: 44px;
}
/* Unclassified reads as absent, not as a choice — because it is: nobody has
 * looked yet, which is a different fact from a person choosing "Other". */
#s-work-items .role[data-v=""] {
  color: var(--ink-3);
  font-style: italic;
}
#s-work-items .role[data-v="price_book"] {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  font-weight: 600;
}

#s-work-items .btn.import {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
  font-weight: 600;
}
#s-work-items .btn.import:hover {
  background: color-mix(in srgb, var(--brand) 88%, #000);
  color: var(--brand-ink);
}

/* ── the drawer's action bar (s142) ──────────────────────────────────────
 *
 * The keyboard route for the file gesture, and the only way to take a file back
 * off a tender. It sits at the FOOT of the file list because the unit it acts on
 * is the tick set: at the head it would read as a heading for the rows, which is
 * the wrong relationship — these buttons act on what is ticked below them.
 *
 * `.idle` keeps the bar present-but-quiet with nothing ticked, rather than
 * appearing on the first tick. A control that materialises under the cursor
 * moves the rows beneath it, and the row you just ticked jumps.
 */
.fileacts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.fileacts-idle,
.fileacts-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.fileacts-hint {
  color: var(--brand);
}

/* WHY these files are moving. Full width on its own row, because the bar wraps and a
   sentence squeezed beside two buttons reads as an afterthought — this is the one
   correction gesture whose reason the database actually keeps. */
.fileacts-note {
  flex: 1 0 100%;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
  min-height: 32px;
}

.fileacts-note:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
