/* The operator's area (js/admin.js, js/admin-users.js,
   js/admin-waitlist.js): the tab bar, the users table and the Waiting
   list. Loaded by index.html after access-tokens.css, ahead of the other
   admin-*.css files, which build on it. The table is app.css's shared one
   (.list, .list-head, .list-row, .cell-num, .tag[data-tone]); this file
   adds the column widths, the tab bar, the tables' panel frame and how a
   row folds into a card. Colours, spaces and type sizes are tokens from
   app.css's :root or from the block below.

   A user row, wide:
     [ email .............. ][ role ][ state ][    n ][ date ][ action ]
   and folded into a card, when the table gets less than about 840px:
     [ email                                                      ]
     [ role  state   3 deliveries  Created Today, 14:05           ]
     [ action                                                     ]

   The other tabs' tables have files of their own (admin-tickets.css,
   admin-abuse.css, admin-ops.css for Agents, Notifications and Audit log,
   admin-llm.css); admin-ops.css reuses the column tokens below. Each table
   folds into cards by rules of its own, all at 840px. */

:root {
  --admin-column-tag: 92px;     /* role and state */
  --admin-column-count: 76px;
  --admin-column-date: 124px;   /* "Yesterday, 14:05" is the widest date */
  --admin-column-action: 96px;
  --admin-column-invitation: 144px;
  --admin-column-waiting-state: 190px;
  --admin-tab-underline: 2px;
}

/* --- the tab bar -------------------------------------------------- */

.admin-tabs {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  /* The bar's line is a shadow, not a border, and the links sit inside
     the bar: overflow-x: auto also clips vertically, so an underline that
     hangs below the bar's padding box (a negative margin) is cut off and
     the current tab is marked by colour alone. */
  box-shadow: inset 0 -1px 0 var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tabs a {
  padding: var(--space-2) 0 var(--space-3);
  border-bottom: var(--admin-tab-underline) solid transparent;
  color: var(--mute);
  font: 500 var(--text-ui)/20px var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.admin-tabs a:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
/* Inside, for the same clipping reason as the underline. */
.admin-tabs a:focus-visible { outline-offset: calc(-1 * var(--admin-tab-underline)); }
.admin-tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

.admin-closed { max-width: 520px; }
.admin-closed .s { margin: var(--space-2) 0 var(--space-4); }

/* --- the users tab ------------------------------------------------ */

.users-toolbar .search,
.tickets-toolbar .search { margin-left: 0; flex: 1; max-width: 380px; }
.users-toolbar .btn { margin-left: auto; }

/* The table asks how wide it is, not how wide the window is: the sidebar
   takes 248px on a desktop and nothing on a phone, so only the table knows
   when it has run out of room. The table is a panel; its rows run to the
   panel's edges. */
.users-body { container: users / inline-size; }
.user-list,
.ticket-list,
.notification-list,
.audit-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.user-list .list-head,
.ticket-list .list-head,
.notification-list .list-head,
.audit-list .list-head { border-radius: var(--radius-l) var(--radius-l) 0 0; }

.user-list {
  --admin-column-action: var(--admin-column-invitation);
  margin: 0;
  padding: 0;
  list-style: none;
}
.user-list .list-head,
.user-list .list-row {
  --cols:
    minmax(0, 1fr)
    var(--admin-column-tag) var(--admin-column-tag)
    var(--admin-column-count) var(--admin-column-date) var(--admin-column-action);
}
.user-row:hover { background: var(--hover); }
.user-row .who .t { white-space: normal; overflow-wrap: anywhere; }
.c-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); justify-content: flex-end; }

.user-list .card-only { display: none; }

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

/* 840px: below it the six columns leave the email under about 200px.
   (A container query cannot read a custom property, so it is a literal.) */
@container users (max-width: 840px) {
  .user-list .list-head { display: none; }
  .user-list .list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }
  /* The row's first cell is .who-with-avatar (components.css gives it the
     full width); the name inside it only fills what the avatar leaves. If
     it claimed 100% itself, the avatar beside it would push the row over by
     the avatar's width at 390px. */
  .user-row .who { flex: 1 1 0; min-width: 0; }
  .user-row .cell-num { text-align: left; }
  .user-list .card-only { display: inline; }
  .c-actions { flex: 1 0 100%; justify-content: flex-start; }
  .c-actions:empty { display: none; }
  .c-actions .btn { min-height: var(--control); }
}

@media (max-width: 820px) {
  .users-toolbar .search,
  .tickets-toolbar .search { max-width: none; }
  .users-toolbar .btn { margin-left: 0; width: 100%; }
}

/* Waiting requests use the same table-to-card break as the Users list. */
.waiting-list { --admin-column-action: var(--admin-column-invitation); margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.waiting-list .list-head,
.waiting-list .list-row { --cols: minmax(0, 1fr) var(--admin-column-waiting-state) var(--admin-column-date) var(--admin-column-action); }
.waiting-row .who { min-width: 0; overflow-wrap: anywhere; }
.waiting-row .who .t { white-space: normal; }
@container users (max-width: 840px) {
  .waiting-list .list-head { display: none; }
  .waiting-list .list-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
  .waiting-row .who { flex: 1 0 100%; }
  .waiting-row .cell-num { text-align: left; }
}
