/* NTP — user management page.
 * Design tokens, base rules, the sign-in / forbidden panes, the sidebar and
 * the drawer come from the shared shell (core/static/core/css/shell.css),
 * loaded before this file; only page-specific rules live here. */

/* Content + toolbar */
#content {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 28px max(clamp(16px, 4vw, 32px), calc((100% - 1180px) / 2));
}
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 12px; flex-wrap: wrap; }
.list-head h2 { margin: 0; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.count-pill { font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand-strong); padding: 2px 9px; border-radius: 999px; }
.list-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#search-input, #role-filter, #status-filter { padding: 7px 11px; font-size: 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
#search-input { min-width: 220px; }
#search-input:focus, #role-filter:focus, #status-filter:focus { border-color: var(--brand); outline: none; }
button.primary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  background: var(--brand); color: var(--brand-contrast); border: 0; border-radius: var(--radius-sm); cursor: pointer; }
button.primary:hover { background: var(--brand-strong); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }

.empty { padding: 40px; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
#user-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
#user-table th, #user-table td { padding: 11px 14px; text-align: start; border-block-end: 1px solid var(--border); white-space: nowrap; }
#user-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 600; background: var(--surface-2); }
#user-table th.sortable { cursor: pointer; user-select: none; }
#user-table th.sortable:hover { color: var(--text); }
#user-table th .sort-ind { margin-inline-start: 4px; color: var(--brand); }
#user-table th.sort-asc .sort-ind::after { content: "▲"; font-size: 9px; }
#user-table th.sort-desc .sort-ind::after { content: "▼"; font-size: 9px; }
#user-table tbody tr:last-child td { border-block-end: 0; }
#user-table tbody tr:hover { background: var(--surface-hover); }
#user-table .num { text-align: end; }
#user-table .u-email { font-weight: 600; }
#user-table .u-you { font-size: 10px; font-weight: 700; color: var(--brand-strong); background: var(--brand-soft); padding: 1px 6px; border-radius: 999px; margin-inline-start: 6px; }
.actions-col { text-align: end; }

.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.role-superuser { background: #fbe7c2; color: #92660a; }
:root[data-theme="dark"] .badge.role-superuser { background: #3a2e11; color: #fbbf24; }
.badge.role-staff { background: var(--green-soft); color: var(--green); }
.badge.role-user { background: var(--slate-soft); color: var(--slate); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--green-soft); color: var(--green); }
.badge.suspended { background: var(--amber-soft); color: var(--amber); }
.badge.blocked { background: var(--danger-soft); color: var(--danger); }
.badge.deleted, .badge.archived { background: var(--slate-soft); color: var(--slate); }
.verified-yes { color: var(--green); font-weight: 600; }
.verified-no { color: var(--text-faint); }

.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; line-height: 0;
  cursor: pointer; background: transparent; color: var(--text-muted); border: 1px solid transparent; border-radius: var(--radius-sm); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger-soft); }
.icon-btn[disabled] { opacity: .3; cursor: not-allowed; }

/* Modals */
#user-modal, #pw-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.45); }
.modal-card { width: min(560px,100%); max-height: 88vh; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-card header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-block-end: 1px solid var(--border); }
.modal-card h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-close { background: transparent; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.modal-body input[type="text"], .modal-body input[type="email"], .modal-body input[type="password"], .modal-body select {
  padding: 10px 12px; font-size: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
.modal-body input:focus, .modal-body select:focus { border-color: var(--brand); background: var(--surface); outline: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-help { margin: -4px 0 0; font-size: 12px; color: var(--text-faint); }

/* Field-level validation: the API's per-field messages land under their input. */
.field-error { display: block; color: var(--danger); font-size: 12px; font-weight: 500; line-height: 1.4; }
.modal-body input[aria-invalid="true"], .modal-body select[aria-invalid="true"] { border-color: var(--danger); background: var(--surface); }
.modal-body input[aria-invalid="true"]:focus, .modal-body select[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Toggle switch (a checkbox underneath, so forms and reset() keep working). */
.switch { position: relative; flex-direction: row !important; align-items: flex-start; gap: 10px !important; color: var(--text) !important; cursor: pointer; padding-block-start: 2px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-track { flex: none; position: relative; width: 38px; height: 22px; margin-block-start: 1px; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--brand-soft); }
.switch-text { display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.switch-text small { font-weight: 400; font-size: 12px; color: var(--text-faint); }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }
.modal-doc { margin: 0; font-weight: 600; }
.modal-msg { margin: 0; font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm); }
.modal-msg.ok { background: var(--green-soft); color: var(--green); }
.modal-msg.err { background: var(--danger-soft); color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-block-start: 4px; }
button.ghost { padding: 9px 14px; font-size: 13px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
button.ghost:hover { background: var(--surface-hover); }

@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
