/* ── Roles Admin Page ── */

/* ── Table header layout ── */
:global(.admin-table-header) {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.create-role-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent-color, #0066cc);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s;
  flex-shrink: 0;
}

.create-role-btn:hover {
  filter: brightness(1.1);
}

/* ── Role-specific styles ── */
.role-row {
  cursor: pointer;
}

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

.role-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

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

.role-moniker {
  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;
}

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

.role-user-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

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

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

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

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

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

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

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

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

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

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

/* User list in role detail */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-color, #0066cc);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-login {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Three-dot menu ── */
.role-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;
}

.role-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;
}

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

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

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

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

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

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

/* ── System badge ── */
.system-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--bg-inset);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* ── Delete confirmation overlay ── */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.confirm-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: 380px;
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: modalIn 0.15s ease;
}

.confirm-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  margin-bottom: 14px;
}

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

.confirm-body {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: #dc2626;
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.confirm-actions form {
  display: contents;
}

.btn-cancel {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.btn-cancel:hover:not(:disabled) {
  background: var(--card-hover-bg);
  border-color: var(--border-default);
  color: var(--text-primary);
}

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

.btn-delete-confirm {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #dc2626;
  border: 1px solid transparent;
  color: #fff;
  transition: filter 0.15s;
}

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

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

/* ── Shared ── */
.detail-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 2px;
}

.row-end-cell {
  width: 1%;
  white-space: nowrap;
}

.row-end-content {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.row-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.row-chevron.open {
  transform: rotate(180deg);
}

.menu-wrap {
  position: relative;
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
}

.menu-btn:hover {
  background: var(--card-hover-bg);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

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

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
