/* The operator's Agents, Notifications and Audit log tabs
   (js/admin-agents.js, js/admin-notifications.js, js/admin-audit.js). Loaded
   by index.html after admin.css, whose column-width tokens it reuses.

   Only what those tabs need beyond app.css's shared parts: the --cols line of
   each table, how a row folds into a card, and the agent cards. Colours,
   spaces and type sizes are tokens from app.css or from the blocks below.

   A notification row, wide:
     [ kind and why ........ ][ channel ][ attempts ][ changed ][ created ]
   An audit row, wide:
     [ time ][ actor ...... ][ action ...... ][ target ...... ][ outcome ]
   and either one folded into a card, when its table gets less than about
   840px (the same limit as the users table, and for the same reason):
     [ kind, or action                                                   ]
     [ the rest, wrapping, each with its label                           ]

   Specificity: app.css sets `--cols` on any row with three or more cells
   (`.list-row:has(> :nth-child(3))`), which beats a value set on the list,
   so each table sets it on its own head and rows, one class deeper. */

:root {
  --admin-column-channel: 132px;   /* "Channel 2 of 3" */
  --admin-agent-card-min: 340px;   /* two cards side by side on a desktop, one on a phone */
  --admin-filter-width: 240px;     /* the Actor and Action selects, side by side */
  --admin-filter-min: 160px;       /* and the least a phone lets each shrink to */
  --admin-column-outcome: 116px;   /* "Answered 409", wider than the words the shared tag column was made for */
}

/* --- the agents --------------------------------------------------- */

.agent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--admin-agent-card-min)), 1fr));
  gap: var(--space-4);
}

.agent-card .panel-head { flex-wrap: wrap; row-gap: var(--space-2); }
.agent-lamps { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }

.agent-heard { margin: 0; color: var(--ink2); }
.agent-waiting { margin: var(--space-2) 0 0; color: var(--ink); }
/* The agent's own words: long ones wrap, and nothing in them can widen the
   card. */
.agent-detail {
  margin: var(--space-2) 0 0;
  color: var(--ink2);
  overflow-wrap: anywhere;
}
.agent-actions { margin-top: var(--space-4); }
.agent-why { display: block; }

/* A stale note above the cards. */
[data-part="agents"] > .callout { margin-bottom: var(--space-4); }

/* --- the two tables: notifications and the audit log -------------- */

/* The table asks how wide it is, not how wide the window is (admin.css). */
.ops-body { container: ops / inline-size; }

.ops-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ops-list .card-only { display: none; }

.list.notification-list .list-head,
.list.notification-list .list-row {
  --cols:
    minmax(0, 1fr)
    var(--admin-column-channel) var(--admin-column-count)
    var(--admin-column-date) var(--admin-column-date);
}
/* The reason is a sentence: let it wrap under the kind. */
.notification-row .who .s { white-space: normal; }

.list.audit-list .list-head,
.list.audit-list .list-row {
  --cols:
    var(--admin-column-date)
    minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.2fr)
    var(--admin-column-outcome);
}
/* Actions and targets are identifiers: one line each, the whole value on
   hover. */
.audit-row .c-actor,
.audit-row .c-action,
.audit-row .c-target {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audit-row .c-target { color: var(--ink2); }

/* "Answered 409": a call answered with a problem, such as an erase refused
   with 409 or 503. Amber like "Refused", but a solid fill with white words
   where Refused is a tint, so the two never read as one. The pair is the one
   the solid labels elsewhere use (--on-photo on --solid-warning). */
.audit-row .tag.answered { background: var(--solid-warning); color: var(--on-photo); }

.audit-toolbar select { flex: 0 1 var(--admin-filter-width); min-width: 0; }
@media (max-width: 820px) {
  .audit-toolbar select { flex: 1 1 var(--admin-filter-min); }
}

.ops-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

/* 840px: below it the columns leave the first cells under about 200px. */
@container ops (max-width: 840px) {
  .ops-list .list-head { display: none; }
  .ops-list .list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }
  .ops-list .cell-num { text-align: left; }
  .ops-list .card-only { display: inline; }

  .notification-row .who { flex: 1 0 100%; }

  /* The action is the title of an audit card; time and actor follow. */
  .audit-row .c-action { order: -1; flex: 1 0 100%; font-weight: 500; }
  .audit-row .c-target { flex: 1 0 100%; order: 2; }
  .audit-row .c-outcome { order: 1; }
  .audit-row .c-actor { flex: 1 1 0; }
}
