/* The Users page (js/users.js): one card with the search and filters, the table, and the footer; a side panel for
   Add a user, a new password and a user's activity. On a phone each row is a card with the same menu. */

.users-page { display: block; }
.up-panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 16px 16px 12px; border-radius: var(--radius-lg); background: var(--card); }

.up-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.up-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.up-count { font-size: 13px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.up-grow { flex: 1 1 auto; }
.up-head .pill:not(.primary), .up-bulk .pill, .up-empty .pill:not(.primary) { background: var(--tile); }
.up-head .pill:not(.primary):hover, .up-empty .pill:not(.primary):hover { background: var(--tile-hover); }
.up-bulk .pill { background: var(--card); }

/* search and filters */
.up-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.up-search { position: relative; flex: 1 1 260px; max-width: 420px; display: flex; }
.up-search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.up-search input { width: 100%; padding: 9px 12px 9px 34px; font: inherit; font-size: 14px; border: 0; border-radius: var(--radius-sm); background: var(--tile); color: var(--ink); }
.up-search input::-webkit-search-cancel-button { cursor: pointer; }
.up-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.up-filters select.searchbox { padding: 9px 10px; font-size: 13px; max-width: 220px; background: var(--tile); }
.up-sortsel { display: none; }

.up-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.up-chips:empty { display: none; }
.up-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--tile); box-shadow: inset 0 0 0 1px var(--chip-line); font-size: 12px; font-weight: 600; }
.up-chip button { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--ink-3); font-size: 15px; line-height: 1; }
.up-chip button:hover { background: var(--soft); color: var(--ink); }
.up-link { padding: 4px 6px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.up-link:hover { color: var(--ink); }

/* selected rows: what can be done to all of them */
.up-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--lime) 28%, var(--card)); font-size: 13px; }
.up-bulk[hidden] { display: none; }
.up-bulk b { margin-right: 4px; font-variant-numeric: tabular-nums; }
.up-bulk .pill { padding: 6px 12px; }

/* the table, scrolling inside its card with the header held at the top */
.up-wrap { position: relative; overflow: auto; max-height: max(260px, calc(100dvh - 300px)); margin: 0 -16px; border-block: 1px solid var(--line); background: var(--card); overscroll-behavior: contain; }
.up-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.up-table th { position: sticky; top: 0; z-index: 2; padding: 0; background: var(--card); box-shadow: inset 0 -1px 0 var(--line); text-align: left; white-space: nowrap; }
.up-table th button { display: inline-flex; align-items: center; gap: 4px; width: 100%; padding: 10px 8px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-align: left; }
.up-table th button:hover { color: var(--ink); }
.up-table th[aria-sort="ascending"] button, .up-table th[aria-sort="descending"] button { color: var(--ink); }
.up-table th i { width: 10px; font-size: 8px; font-style: normal; }
.up-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
.up-table tbody tr:last-child td { border-bottom: 0; }
.up-table tbody tr { transition: background 0.15s ease; }
.up-table tbody tr:hover { background: var(--hover); }
.up-table tr.is-picked, .up-table tr.is-picked:hover { background: color-mix(in srgb, var(--lime) 16%, var(--card)); }
.up-table tr.is-off td:not(.up-act):not(.up-pick) { color: var(--ink-3); }
.up-table.is-loading tbody { opacity: 0.55; transition: opacity 0.2s ease 0.15s; }
.up-pick { width: 44px; padding-left: 16px !important; }
.up-pick input { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.up-name b { font-weight: 600; overflow-wrap: anywhere; }
.up-name small, .up-num small { display: block; margin-top: 1px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); overflow-wrap: anywhere; }
.up-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.up-seat { min-width: 120px; font-size: 12.5px; }
.up-seat .muted { margin: 0; color: var(--ink-3); }
.up-col-name { min-width: 170px; }
.up-act { width: 52px; padding-right: 12px !important; text-align: right !important; position: relative; }

.up-badge { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple-ink); font-size: 10.5px; font-weight: 700; vertical-align: 1px; }
.up-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.up-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--draw); }
.up-status.is-active::before { background: var(--win); }
.up-status.is-temp::before { background: var(--tbp); }
.up-status.is-off { color: var(--ink-3); }

/* a row's menu */
.up-more { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--ink-2); font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.up-more:hover, .up-more[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.up-menu { position: fixed; z-index: 40; display: grid; min-width: 200px; padding: 6px; border-radius: 12px; background: var(--card); color: var(--ink); text-align: left; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--line); }
.up-menu button { padding: 8px 10px; border-radius: 7px; font-size: 13px; font-weight: 500; text-align: left; }
.up-menu button:hover:not([disabled]), .up-menu button:focus-visible { background: var(--soft); outline: none; }
.up-menu button[disabled] { color: var(--ink-3); cursor: default; }
.up-menu-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 2px 0; padding: 4px 0; border-block: 1px solid var(--line); }
.up-menu-group span { width: 100%; padding: 2px 10px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.up-menu-group button { flex: 1 1 auto; padding: 6px 8px; text-align: center; }
.up-menu-group button[aria-checked="true"] { background: var(--ink); color: var(--on-ink); }

/* loading, empty, errors */
.up-skel td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
.up-skel span { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--tile) 0%, var(--soft-2) 50%, var(--tile) 100%); background-size: 200% 100%; animation: up-shimmer 1.2s ease-in-out infinite; }
.up-skel:nth-child(3n + 2) span { width: 82%; }
.up-skel:nth-child(3n) span { width: 64%; }
@keyframes up-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .up-skel span { animation: none; } }
.up-empty { display: grid; justify-items: center; gap: 6px; padding: 44px 16px; text-align: center; }
.up-empty p { margin: 0; }
.up-empty .pill { margin-top: 8px; }
.up-error { margin: 0; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--red); }
.up-error:empty { display: none; }

/* the footer: the count, rows a page and the pages */
.up-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 0; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.up-foot:empty { display: none; }
.up-per { display: inline-flex; align-items: center; gap: 6px; }
.up-per select.searchbox { padding: 6px 8px; background: var(--tile); }
.up-pageno { font-weight: 600; }
.up-foot .pill { padding: 6px 12px; background: var(--tile); }
.up-foot .pill:hover:not([disabled]) { background: var(--tile-hover); }
.up-foot .pill[disabled] { opacity: 0.45; cursor: default; }

/* the side panel */
.up-side { position: fixed; z-index: 50; top: 12px; right: 12px; bottom: 12px; width: min(400px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow: auto; border-radius: var(--radius-lg); background: var(--card); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--line); }
.up-side[hidden] { display: none; }
.up-side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.up-side h2 { margin: 0; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.up-side .muted { margin: 0; }
.up-side .auth-temp { background: var(--tile); }
.up-side .pill:not(.primary) { background: var(--tile); }
.up-side .pill:not(.primary):hover { background: var(--tile-hover); }
.up-side .auth-temp .pill { background: var(--card); }
.up-form { display: grid; gap: 10px; }
.up-form label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.up-form .searchbox { width: 100%; max-width: none; padding: 9px 12px; font-size: 14px; background: var(--tile); }
.up-form .pill.primary { justify-self: start; padding: 9px 18px; }
.up-hint { margin: -4px 0 0; font-size: 12px; color: var(--ink-3); }
.up-hint.is-bad { color: var(--red); font-weight: 600; }
.up-fixed { margin: 0; font-size: 13px; color: var(--ink-2); }
.up-events { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.up-events li { display: grid; gap: 1px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.up-events li:last-child { border-bottom: 0; }
.up-events .up-when { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.up-events small { font-size: 12px; color: var(--ink-2); }

.up-pickall { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* a laptop-sized window: the quieter columns give room first */
@media screen and (max-width: 1180px) {
  .up-table td, .up-table th button { padding-inline: 6px; }
  .up-col-name { min-width: 150px; }
  .up-seat { min-width: 100px; }
}

/* a phone: every row a card, the sort as a choice in the filters */
@media screen and (max-width: 640px) {
  .up-panel { padding: 4px 0 0; background: none; }
  .up-title { font-size: 20px; }
  .up-search { flex-basis: 100%; max-width: none; }
  .up-filters { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .up-filters select.searchbox { width: 100%; max-width: none; }
  .up-sortsel { display: block; }
  .up-wrap { max-height: none; margin: 0; overflow: visible; border: 0; background: transparent; }
  .up-search input, .up-filters select.searchbox, .up-per select.searchbox, .up-chip, .up-foot .pill, .up-head .pill:not(.primary) { background: var(--card); }
  .up-pickall { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 2px 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
  .up-pickall input { width: 16px; height: 16px; accent-color: var(--ink); }
  .up-table, .up-table tbody { display: block; }
  .up-table thead { display: none; }
  .up-table tbody tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) 36px; gap: 4px 8px; margin-bottom: 8px; padding: 10px 10px 10px 8px; border-radius: var(--radius); background: var(--card); }
  .up-table tbody tr:hover { background: var(--card); }
  .up-table td { display: block; padding: 0; border: 0; }
  .up-table td.up-pick { grid-row: 1; grid-column: 1; width: auto; padding: 2px 0 0 !important; }
  .up-table td.up-name { grid-row: 1; grid-column: 2; }
  .up-table td.up-act { grid-row: 1; grid-column: 3; width: auto; }
  .up-table td[data-label]:not(.up-name) { grid-column: 2 / -1; display: flex; gap: 8px; font-size: 12.5px; }
  .up-table td[data-label]:not(.up-name)::before { content: attr(data-label); flex: 0 0 96px; color: var(--ink-3); font-weight: 500; }
  .up-num { white-space: normal; }
  .up-num small { display: inline; margin: 0 0 0 4px; }
  .up-skel { display: block !important; }
  .up-foot { justify-content: space-between; }
  .up-foot > span:first-child { width: 100%; }
  .up-foot .up-grow { display: none; }
  .up-side { inset: auto 0 0 0; width: 100%; max-height: 88dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

@media print {
  .up-tools, .up-chips, .up-bulk, .up-foot, .up-pick, .up-act, .up-side { display: none !important; }
  .up-wrap { max-height: none; overflow: visible; }
  .up-table th { position: static; }
}
.up-num .muted-ink { color: var(--ink-3); }
