/* users.css — the Users room (js/rooms/users.js). Console tokens only
   (console.css :root). Laid out for 375 px first; the desk inherits it.
   Every hand is 44 px. */

.users-room .btn { min-height: 44px; }
.users-room .btn-sm { min-height: 44px; padding: 0 12px; font-size: 13px; }
.users-room input, .users-room select { min-height: 44px; }
.users-room .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.users-head { align-items: center; gap: 10px; }
.users-head h2 { margin: 0; }
.users-toolbar { display: flex; gap: 8px; flex: 1 1 100%; flex-wrap: wrap; }
.users-toolbar input[type="search"] { flex: 1 1 200px; min-width: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.users-table th, .invites-table th { white-space: nowrap; }
.users-table td, .invites-table td { vertical-align: middle; }
.users-table .row-actions, .invites-table .row-actions { flex-wrap: wrap; gap: 6px; min-width: 260px; }
.row-disabled td:not(.row-actions) { opacity: 0.62; }
.th-actions { min-width: 260px; }

.users-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

/* Invite form: one column on a phone, a row on a desk. */
.invite-form { display: grid; grid-template-columns: 1fr; gap: 6px 12px; align-items: end; margin-bottom: 10px; }
.invite-form .field-row { margin-bottom: 4px; }
.invite-form .invite-submit label { display: none; }

.invite-result { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 6px 0 14px; background: var(--bg-elevated); }
.invite-result.invite-sent { border-color: var(--border-strong); }
.invite-result.invite-unsent { border-color: var(--amber); background: var(--amber-soft); }
.invite-result-msg { margin: 0 0 8px; font-size: 13px; }

/* The one-time reveal: a label, the value in mono, Copy. */
.show-once { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: center; }
.show-once-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 700; }
.show-once-value { display: block; font-family: var(--font-mono); font-size: 12.5px; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-sunken); color: var(--text); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.show-once-secret .show-once-value { font-size: 15px; letter-spacing: 0.04em; }

.users-modal { max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.users-modal .form-error:empty { display: none; }
.pw-field { display: grid; grid-template-columns: 1fr; gap: 6px; }
.pw-field input { min-width: 0; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 13px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; min-height: 0; }

/* ---- Front end / Back end: the access switches (glass, navy → claret
   when on, pearl on the dark ground). A real button with role="switch";
   the hand is 44 px whatever the track draws. ---- */
.acc-switch {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 8px 0 2px;
  border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 12.5px; cursor: pointer; border-radius: var(--radius-pill);
  -webkit-tap-highlight-color: transparent;
}
.acc-track {
  position: relative; flex: 0 0 auto; width: 46px; height: 26px; border-radius: var(--radius-pill);
  background: rgba(var(--glow-rgb), 0.10);
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 1px 2px rgba(var(--glow-rgb), 0.18), 0 1px 0 rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.acc-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, #f2f5f3, #ece8dc);
  box-shadow: 0 1px 3px rgba(var(--glow-rgb), 0.35);
  transition: transform .18s ease;
}
.acc-switch[aria-checked="true"] .acc-track {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(var(--glow-rgb), 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.acc-switch[aria-checked="true"] .acc-thumb { transform: translateX(20px); }
.acc-word { font-weight: 700; color: var(--text-muted); }
.acc-state { min-width: 2.2em; font-family: var(--font-mono); font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); }
.acc-switch[aria-checked="true"] .acc-state { color: var(--text); }
.acc-switch:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.acc-switch:disabled { cursor: not-allowed; opacity: .55; }
.acc-note { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.acc-note.acc-warn { color: var(--danger); font-weight: 700; }
.cell-switch .acc-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cell-switch { white-space: nowrap; }
.switch-pair { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }

/* Row actions: Edit and Sign-in links in view, the rest behind More, which
   opens in the flow of the row (never a floating menu a scrolling table
   could clip). */
.users-table .row-actions { min-width: 0; align-items: flex-start; }
.users-table .th-actions { min-width: 0; }
.row-more { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.row-more[open] { flex: 1 1 100%; }
.row-more > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; }
.row-more > summary::-webkit-details-marker { display: none; }
.row-more > summary::after { content: "▾"; margin-left: 6px; font-size: 10px; }
.row-more[open] > summary::after { content: "▴"; }
.row-more-menu { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
@media (min-width: 900px) { .users-table td.row-actions { min-width: 300px; } }
.field-label-like { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.invite-access-note:empty { display: none; }

/* The filter: All / Front end / Back end / Disabled. */
.users-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.filter-btn {
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--panel); color: var(--text-muted);
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.filter-btn.is-on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: var(--accent); color: var(--accent-contrast); }
.filter-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* The deployment's sign-in links, and the one-time credentials sheet. */
.links-list, .cred-stack { display: grid; gap: 10px; }
.cred-stack { margin: 8px 0 6px; }
.enrol { display: grid; grid-template-columns: 1fr; gap: 12px; justify-items: center; }
.enrol-qr { width: 220px; max-width: 100%; height: auto; image-rendering: pixelated; border-radius: var(--radius-sm); background: #f2f5f3; border: 1px solid var(--border); }
.enrol-side { display: grid; gap: 6px; }
.enrol-step { margin: 0; font-size: 12.5px; color: var(--text-muted); }

/* Phone first: below 640 px every account (and invitation) is a card —
   name on top, each field a labelled line, both switches in view, the
   actions wrapping as 44 px buttons. No sideways scroll. */
@media (max-width: 639px) {
  .users-room .table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  .users-table thead, .invites-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .users-table, .users-table tbody, .users-table tr,
  .invites-table, .invites-table tbody, .invites-table tr { display: block; width: 100%; }
  .users-table tr, .invites-table tr {
    border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 12px; margin: 0 0 10px;
    background: var(--panel); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: var(--shadow-sm);
  }
  .users-table td, .invites-table td {
    display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px;
    border: none; padding: 3px 0; min-width: 0; overflow-wrap: anywhere;
  }
  .users-table td::before, .invites-table td::before {
    content: attr(data-label); font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    font-family: var(--font-mono); color: var(--text-faint);
  }
  .users-table td.cell-name { display: block; font-size: 15px; font-weight: 700; padding: 4px 0 6px; }
  .users-table td.cell-name::before, .users-table td.row-actions::before, .invites-table td.row-actions::before,
  .users-table td[colspan]::before, .invites-table td[colspan]::before { content: none; }
  .users-table td[colspan], .invites-table td[colspan] { display: block; }
  .users-table td, .invites-table td { justify-items: start; }
  .users-table td.cell-switch .acc-note { grid-column: 2; margin: -6px 0 2px; }
  .users-table .row-actions, .invites-table .row-actions { display: flex; min-width: 0; padding-top: 8px; }
  .users-table .row-actions .btn { flex: 1 1 auto; }
  .row-disabled td:not(.row-actions) { opacity: 0.72; }
  .th-actions { min-width: 0; }
}

@media (min-width: 640px) {
  .users-toolbar { flex: 0 1 auto; margin-left: auto; }
  .invite-form { grid-template-columns: minmax(200px, 2fr) minmax(130px, 1fr) minmax(130px, 1fr) auto; }
  .invite-form .invite-access { grid-column: 1 / -2; }
  .enrol { grid-template-columns: auto 1fr; justify-items: start; align-items: center; }
  .cred-stack .show-once, .links-list .show-once { grid-template-columns: 200px minmax(0, 1fr) auto; }
  .invite-form .invite-submit label { display: block; }
  .show-once { grid-template-columns: auto 1fr auto; }
  .show-once-label { white-space: nowrap; }
  .pw-field { grid-template-columns: 1fr auto auto; }
}

/* Remembered devices (the Devices sheet, rooms/users.js openDevicesSheet):
   the same table, its Actions column no wider than its one button, and on a
   phone the same card per row as the accounts table. */
.devices-table th { white-space: nowrap; }
.devices-table td { vertical-align: middle; }
.devices-table .th-actions, .devices-table .row-actions { min-width: 0; }
.devices-list { margin: 0 0 10px; }
@media (max-width: 639px) {
  .devices-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .devices-table, .devices-table tbody, .devices-table tr { display: block; width: 100%; }
  .devices-table tr {
    border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 12px; margin: 0 0 10px;
    background: var(--panel);
  }
  .devices-table td {
    display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 8px;
    border: none; padding: 3px 0; min-width: 0; overflow-wrap: anywhere;
  }
  .devices-table td::before {
    content: attr(data-label); font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    font-family: var(--font-mono); color: var(--text-faint);
  }
}
