/* ============================================================
   User Management module
   ============================================================ */

.ua-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}

.ua-table-wrap {
  border: 1px solid var(--border, #d6dadf);
  border-radius: 10px;
  overflow: auto;
  background: var(--surface, #fff);
}
.ua-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ua-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #1e293b;
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 11px;
  white-space: nowrap;
}
.ua-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: top;
}
.ua-table tbody tr:hover { background: #fafbfc; }
.ua-empty { text-align: center; padding: 24px; color: #6b7280; }
.ua-muted { color: #94a3b8; }

.ua-email { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #1e40af; font-weight: 600; }
.ua-name  { font-weight: 500; color: #1e293b; }
.ua-role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.ua-role-admin { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.ua-role-user  { background: #eef2fb; color: #1e40af; border: 1px solid #c7d2fe; }

.ua-modules, .ua-orgs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 340px;
}
.ua-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2fb;
  color: #1e40af;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.ua-chip-more { background: #e2e8f0; color: #475569; }
.ua-chip-all {
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
}
.ua-actions { white-space: nowrap; }
.ua-actions .btn + .btn { margin-left: 4px; }
.ua-date { font-size: 12px; color: #64748b; white-space: nowrap; }

/* --- Add form -------------------------------------------------------- */
.ua-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 960px;
}
@media (max-width: 800px) { .ua-form { grid-template-columns: 1fr; } }
.ua-form .full { grid-column: 1 / -1; }
.ua-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.ua-form input[type="text"],
.ua-form input[type="email"],
.ua-form input[type="password"],
.ua-form select {
  padding: 8px 10px;
  border: 1px solid var(--border, #d6dadf);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
}
.ua-form input:focus,
.ua-form select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* "All …" master toggle — pinned above the choice grid. When checked,
   the grid collapses out of view and the backend stores an "all_*" flag
   so newly-added items automatically fall under the grant. */
.ua-all-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #eef2fb;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: #1e293b;
  margin-bottom: 6px;
}
.ua-all-toggle input { transform: scale(1.15); accent-color: #4f46e5; }
.ua-all-toggle-label {
  font-weight: 700;
  color: #1e293b;
}
.ua-all-toggle-hint {
  color: #64748b;
  font-size: 11px;
  margin-left: auto;
}

/* Bulk-toggle bar rendered above every choice grid. */
.ua-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid var(--border-soft, #eef0f3);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  font-size: 11.5px;
}
.ua-select-all-count {
  color: #64748b;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.ua-select-all-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1e293b;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.ua-select-all-btn:hover {
  background: #eef2fb;
  border-color: #2563eb;
  color: #1d4ed8;
}

/* --- Access section: two side-by-side cards ------------------------- */
.ua-section-heading {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: #64748b; margin-bottom: 8px;
}
.ua-access {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) { .ua-access { grid-template-columns: 1fr; } }
.ua-access-col {
  border: 1px solid var(--border, #e2e6ee);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ua-access-head { display: flex; flex-direction: column; gap: 1px; }
.ua-access-title { font-size: 13px; font-weight: 700; color: #1e293b; }
.ua-access-sub { font-size: 11px; color: #94a3b8; font-weight: 500; }

/* Choices as selectable pills that highlight when checked. */
.ua-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border-soft, #eef0f3);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fafbfc;
  max-height: 240px;
  overflow-y: auto;
}
.ua-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid #d8dee8;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
  color: #334155;
  font-weight: 600;
  transition: background .12s, border-color .12s, color .12s;
}
.ua-choice:hover { border-color: #93a4c8; background: #f5f8ff; }
.ua-choice input { accent-color: #4f46e5; }
/* Checked pill turns solid indigo — instantly readable at a glance. */
.ua-choice:has(input:checked) {
  background: #eef2ff;
  border-color: #6366f1;
  color: #3730a3;
}
.ua-choice-label { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; }
.ua-choice-hint { font-size: 10px; color: #7c88a1; font-weight: 500; }

.ua-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* --- Edit modal ------------------------------------------------------ */
.ua-edit-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 220;
  padding: 30px;
}
.ua-edit-backdrop.active { display: flex; }
.ua-edit-frame {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.ua-edit-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ua-edit-header h3 { margin: 0; font-size: 15px; }
.ua-edit-header .meta { font-size: 12px; color: #64748b; }
.ua-edit-body { padding: 16px; overflow-y: auto; }
