/*
 * OfficePress request queues: the queue column beside the detail surface for My requests, Assigned and Watching
 * (stylesheet slot 10, after r005/app.css). Only --op-* and the remapped --wf-* tokens appear here.
 * The look comes from design-drafts/r001-officepress-workspace (DESIGN.md "Layout" and "Components -> Queue").
 * The detail surface's own content belongs to record.css; this sheet only frames and places it.
 *
 *   side by side  queue column (minimum 280px, about 36%) and detail, each scrolling on its own while the viewport has room
 *   stacked       one column: the queue, then the detail once a request is opened, with a Back to requests control.
 *                 Used below 768px, and while the page body is narrower than 660px (an expanded sidebar through 950px)
 *
 * Selected, status and focus never rely on colour alone: a selected row has a 4px bar and a heavier title, status keeps its
 * text and glyph (components.css), the sign-here flag is a ring with a glyph, and focus is the shared 2px outline.
 * r005 rules this sheet must beat are matched with `.page--queues` for specificity; r005 files stay as they are.
 */

/* ---------- Page frame ---------- */

.page--queues {
  --queue-pad: var(--op-space-5);
  container: queues / inline-size;
  padding: var(--queue-pad);
}

/* The document owns scrolling: queue and selected-record panels grow with their actual content. */
.page--queues .queue-frame {
  display: block;
}

.page--queues .page-header { flex: none; gap: var(--op-space-4); margin-bottom: var(--op-space-4); }
.page--queues .page-title { margin: 0 0 var(--op-space-1); font: var(--op-text-heading); color: var(--op-text); }
.page--queues .page-subtitle { max-width: 80ch; color: var(--op-text-2); font: var(--op-text-small); }
.page--queues .page-actions { flex: none; }

/* ---------- Queue and detail columns ---------- */

.page--queues .queue-layout {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
  gap: var(--op-space-5);
  margin: 0;
  min-height: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.page--queues .queue-list,
.page--queues .queue-layout .queue-preview {
  align-self: start;
  min-width: 0;
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-12);
  background: var(--op-surface);
}

.page--queues .queue-list { container: queue-column / inline-size; overflow: visible; }

/* r005 hides the detail below 1180px unless a request was opened; here it stays beside the queue until the layout stacks. */
.page--queues .queue-layout .queue-preview { display: block; overflow: visible; }

/* The "Select a request" placeholder and an unavailable or failed selection sit mid-panel. */
.page--queues .queue-layout .queue-preview:has(> .empty-state.is-visible) { display: flex; flex-direction: column; }
.page--queues .queue-preview > .empty-state.is-visible { margin-block: auto; padding: var(--op-space-10) var(--op-space-6); }
.page--queues .queue-preview .empty-state .icon { color: var(--op-text-2); }
.page--queues .queue-preview .empty-state p { margin-inline: auto; }

/* The detail's own return control is only for the stacked layout. */
.page--queues .preview-return { display: none; }

/* ---------- Shared status/search toolbar and queue head ---------- */

/* The desktop task begins with filtering: statuses stay together at the leading edge, while search sits at the far edge. */
.page--queues .queue-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--op-space-6);
  min-width: 0;
  margin-bottom: var(--op-space-4);
}

.page--queues .queue-toolbar .segmented {
  display: inline-flex;
  flex: none;
  width: auto;
  overflow: visible;
}

.page--queues .queue-toolbar .segment {
  min-width: 0;
  padding-inline: var(--op-space-3);
  white-space: nowrap;
}

.page--queues .queue-search {
  display: flex;
  align-items: center;
  gap: var(--op-space-2);
  flex: 0 1 520px;
  min-width: min(100%, 320px);
  margin-left: auto;
}

.page--queues .queue-search .search { flex: 1 1 0; min-width: 0; }
.page--queues .queue-search .search-action { flex: none; }

.queue-head {
  flex: none;
  display: grid;
  gap: var(--op-space-2);
  padding: var(--op-space-4);
  border-bottom: 1px solid var(--op-border);
  background: var(--op-toolbar);
}

/* Tablet and phone retain the same meaningful order, but give both control groups their own usable row. */
@container queues (max-width: 900px) {
  .page--queues .queue-toolbar { align-items: stretch; flex-direction: column; gap: var(--op-space-3); }
  .page--queues .queue-toolbar .segmented { align-self: flex-start; max-width: 100%; flex-wrap: wrap; }
  .page--queues .queue-search { flex: 0 0 auto; width: 100%; max-width: none; min-width: 0; margin-left: 0; }
}

@container queues (max-width: 460px) {
  .page--queues .queue-toolbar .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: stretch; }
  .page--queues .queue-search { flex-wrap: wrap; }
  .page--queues .queue-search .search { flex-basis: 100%; }
  .page--queues .queue-search .search-action { flex: 1 1 100%; }
}

.queue-count { align-items: baseline; gap: var(--op-space-2); color: var(--op-text); font-size: var(--wf-text-sm); }
.queue-count .result-count { color: var(--op-text-2); }

/* Loading: shown from a search, filter or paging navigation until the next page replaces this one. */
.queue-loading {
  position: relative;
  margin: 0;
  padding-top: var(--op-space-2);
  color: var(--op-text-2);
  font-size: var(--wf-text-sm);
}
.queue-loading::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  border-radius: var(--op-radius-full);
  background: linear-gradient(90deg, transparent, var(--op-accent-strong), transparent) 0 0 / 40% 100% no-repeat, var(--op-tint-2);
  animation: op-queue-loading 1200ms var(--op-ease) infinite;
}
@keyframes op-queue-loading { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

.queue-rows[aria-busy="true"] .request-list { opacity: 0.6; }

/* ---------- Rows ---------- */

.queue-rows { overflow: visible; }
.page--queues .request-list li + li { border-top: 1px solid var(--op-border); }

.page--queues .request-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-areas: "icon side" "icon body";
  column-gap: var(--op-space-3);
  row-gap: var(--op-space-2);
  align-items: start;
  min-height: 44px;
  padding: var(--op-space-4) var(--op-space-4) var(--op-space-4) calc(var(--op-space-4) - 4px);
  border: 0;
  border-left: 4px solid transparent;
  background: transparent;
  color: var(--op-text);
  text-align: left;
  cursor: pointer;
}
.page--queues .request-row:disabled { cursor: progress; opacity: 0.7; }
.page--queues .request-row:focus-visible { outline-offset: -3px; }
@media (hover: hover) {
  .page--queues .request-row:hover { background: var(--op-sunken); }
  .page--queues .request-row.is-selected:hover { background: var(--op-tint-2); }
}

/* Selected is a bar and a heavier title as well as a tint. */
.page--queues .request-row.is-selected { border-left-color: var(--op-accent-strong); background: var(--op-tint-2); }
.page--queues .request-row.is-selected .request-title { font-weight: 800; }
.page--queues .request-row.is-selected .request-meta,
.page--queues .request-row.is-selected .request-submeta,
.page--queues .request-row.is-selected .request-side,
.page--queues .request-row.is-selected .request-duty:not(.is-actionable) { color: var(--op-selection-meta); }

.page--queues .request-icon {
  grid-area: icon;
  width: 32px;
  height: 32px;
  padding: 7px;
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-8);
  background: var(--op-sunken);
  color: var(--op-text-2);
}
.page--queues .request-row.is-selected .request-icon { border-color: var(--op-accent-strong); background: var(--op-surface); color: var(--op-text); }

/* Status line first, as the preview's row meta; the title and facts follow. */
.page--queues .request-side {
  grid-area: side;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--op-space-1) var(--op-space-2);
  color: var(--op-text-2);
  font-size: var(--wf-text-xs);
}
.page--queues .request-body { grid-area: body; min-width: 0; }
.page--queues .request-title {
  margin: 0 0 var(--op-space-1);
  color: var(--op-text);
  font-size: var(--wf-text-md);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.page--queues .request-meta,
.page--queues .request-submeta { color: var(--op-text-2); font-size: var(--wf-text-sm); overflow-wrap: anywhere; }
.page--queues .request-submeta { margin-top: 2px; }

.request-progress { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; white-space: nowrap; }
.request-progress .tick-strip { flex: none; }

.request-duty { display: block; margin: 0 0 var(--op-space-1); color: var(--op-text-2); font-size: var(--wf-text-sm); font-weight: 700; overflow-wrap: anywhere; }
.request-duty.is-actionable { color: var(--op-accent-ink); }

/* The sign-here flag: a ring with a dot, so it is a shape and not only an accent colour. The text is for assistive tech. */
.sign-flag {
  flex: none;
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--op-accent-strong);
  border-radius: var(--op-radius-full);
  background: radial-gradient(circle, var(--op-accent-strong) 0 2px, transparent 2.5px);
}

/* ---------- Empty and no-match ---------- */

.queue-rows .empty-state { padding: var(--op-space-10) var(--op-space-5); }
.queue-rows .empty-state .icon { color: var(--op-text-2); }
.queue-clear { margin: var(--op-space-4) 0 0; }

/* ---------- Paging ---------- */

.queue-foot {
  flex: none;
  gap: var(--op-space-3);
  padding: var(--op-space-3) var(--op-space-4);
  border-top: 1px solid var(--op-border);
  background: var(--op-toolbar);
  color: var(--op-text-2);
  font-size: var(--wf-text-sm);
}

/* ---------- Workspace failure ---------- */

.page--notice .queue-failure { max-width: 640px; margin: var(--op-space-8) auto; border-radius: var(--op-radius-12); }
.queue-failure .empty-state .icon { color: var(--op-text-2); }
.queue-failure-actions { justify-content: center; margin-top: var(--op-space-4); }

/* ---------- Tablet: tighter spacing ---------- */

@media (max-width: 1150px) {
  .page--queues { --queue-pad: var(--op-space-3); }
  .page--queues .queue-layout { gap: var(--op-space-3); grid-template-columns: minmax(250px, 36%) minmax(0, 1fr); }
}

/* ---------- Stacked: one column, the detail opens beneath the queue ---------- */

@media (max-width: 767px) {
  .page--queues .queue-layout { --queue-stacked: 1; display: flex; flex-direction: column; gap: var(--op-space-4); }
  .page--queues .queue-list,
  .page--queues .queue-layout .queue-preview { align-self: stretch; min-width: 0; }
  .page--queues .page-header { flex-direction: column; align-items: stretch; }
  .page--queues .page-actions { width: 100%; }
  .page--queues .queue-layout:not(.is-preview-open) .queue-preview,
  .page--queues .queue-layout:not(.is-preview-open) .queue-preview:has(> .empty-state.is-visible) { display: none; }
  .page--queues .preview-return { display: inline-flex; min-height: 44px; margin: var(--op-space-2) var(--op-space-2) 0; }
  .page--queues .request-row { min-height: 56px; }
  .page--queues .segment { min-height: 36px; }
}

@container queues (max-width: 660px) {
  .page--queues .queue-layout { --queue-stacked: 1; display: flex; flex-direction: column; gap: var(--op-space-4); }
  .page--queues .queue-list,
  .page--queues .queue-layout .queue-preview { align-self: stretch; min-width: 0; }
  .page--queues .queue-layout:not(.is-preview-open) .queue-preview,
  .page--queues .queue-layout:not(.is-preview-open) .queue-preview:has(> .empty-state.is-visible) { display: none; }
  .page--queues .preview-return { display: inline-flex; min-height: 44px; margin: var(--op-space-2) var(--op-space-2) 0; }
}

/* ---------- Forced colours ---------- */

@media (forced-colors: active) {
  .page--queues .request-row.is-selected { border-left-color: Highlight; outline: 2px solid Highlight; outline-offset: -2px; }
  .sign-flag { border-color: CanvasText; background: radial-gradient(circle, CanvasText 0 2px, transparent 2.5px); }
}
