/* ── Users Admin Page ── */

/* ── Search bar ── */
.user-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.user-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.user-search-input {
  padding: 7px 12px 7px 30px;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-inset);
  font-size: 13px;
  color: var(--text-primary);
  width: 220px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.user-search-input::placeholder {
  color: var(--text-muted);
}

.user-search-input:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* ── User row ── */
.user-row {
  cursor: pointer;
}

.user-row.expanded {
  background: var(--card-hover-bg);
}

.user-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-table-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.user-table-avatar-initials {
  background: var(--accent-color, #0066cc);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.user-table-name {
  font-weight: 600;
  color: var(--text-primary);
}

.user-email {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.user-login-mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-inset);
  padding: 2px 8px;
  border-radius: 4px;
}

.user-role-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Expanded detail row ── */
.user-detail-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border-subtle);
}

.user-detail-content {
  padding: 16px 24px 20px;
  background: var(--bg-inset);
  animation: userDetailFadeIn 0.15s ease;
}

@keyframes userDetailFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.user-detail-section {
  margin-bottom: 0;
}

.user-detail-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-detail-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Detail fields */
.user-detail-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-detail-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 60px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}

.detail-mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 12px;
}

/* ── Role cards in expanded row ── */
.user-role-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-role-card {
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
}

.user-role-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.user-role-card-header svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.user-role-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role-moniker {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-inset);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}

/* Permission tags */
.permission-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.permission-tag {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--status-neutral-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.permission-tag-more {
  background: var(--bg-inset);
  color: var(--text-muted);
  font-style: italic;
  font-family: inherit;
}

/* ── Three-dot menu ── */
.user-menu {
  position: fixed;
  z-index: 200;
  min-width: 130px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 4px;
  animation: menuIn 0.1s ease;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.user-menu-item:hover {
  background: var(--card-hover-bg);
}

.user-menu-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.user-menu-item-danger {
  color: #dc2626;
}

.user-menu-item-danger svg {
  color: #dc2626;
}

.user-menu-item-danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.user-menu-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 3px 4px;
}

/* ── Edit dialog ── */
.edit-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 24px 22px;
  animation: modalIn 0.15s ease;
}

.edit-dialog-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.edit-dialog-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.edit-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.edit-field input {
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-inset);
  font-size: 13px;
  color: var(--text-primary);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.edit-field input:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.btn-save {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent-color, #0066cc);
  border: 1px solid transparent;
  color: #fff;
  transition: filter 0.15s;
}

.btn-save:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Edit modal sections (roles & permissions) ── */
.edit-section {
  margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.edit-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.edit-section-label svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.edit-section-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  margin-left: auto;
}

/* ── Role chips ── */
.edit-role-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 4px;
}

.edit-role-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  transition:
    background 0.12s,
    border-color 0.12s;
}

.edit-role-chip:hover {
  background: var(--card-hover-bg);
}

.edit-role-chip.selected {
  background: rgba(0, 102, 204, 0.08);
  border-color: var(--accent-color, #0066cc);
}

.edit-role-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-subtle);
  flex-shrink: 0;
  color: var(--accent-color, #0066cc);
  transition: border-color 0.12s;
}

.edit-role-chip.selected .edit-role-check {
  border-color: var(--accent-color, #0066cc);
  background: var(--accent-color, #0066cc);
  color: #fff;
}

.edit-role-chip-title {
  font-weight: 600;
  font-size: 13px;
}

.edit-role-chip-moniker {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Permission list ── */
.edit-perm-search-wrap {
  margin-bottom: 8px;
}

.edit-perm-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-inset);
  font-size: 12.5px;
  color: var(--text-primary);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.edit-perm-search::placeholder {
  color: var(--text-muted);
}

.edit-perm-search:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.edit-perm-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.edit-perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s;
}

.edit-perm-item:hover {
  background: var(--card-hover-bg);
}

.edit-perm-item input[type="checkbox"] {
  accent-color: var(--accent-color, #0066cc);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.edit-perm-node {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-primary);
}

.edit-perm-empty {
  margin: 0;
  padding: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* Scrollbars for edit lists */
.edit-role-list::-webkit-scrollbar,
.edit-perm-list::-webkit-scrollbar {
  width: 5px;
}

.edit-role-list::-webkit-scrollbar-track,
.edit-perm-list::-webkit-scrollbar-track {
  background: transparent;
}

.edit-role-list::-webkit-scrollbar-thumb,
.edit-perm-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
