/* Rôles, hiérarchie et surcharges de permissions. */

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.role-color-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.member-role-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.member-role-chips:empty::after {
  content: 'aucun rôle';
  color: var(--text-muted);
  font-size: 10px;
}

.member-role-chips .tag {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-more { color: var(--text-muted) !important; }

.role-picker {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 250px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.role-picker-item,
.inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--text-secondary);
  cursor: pointer;
}

.role-picker-item:hover,
.inline-check:hover { background: var(--surface); color: var(--text); }
.role-picker-item input,
.inline-check input { accent-color: var(--primary); flex: 0 0 auto; }

/* Éditeur des surcharges d'un salon. */

.permission-target-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.permission-target-field > label {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.permission-target-summary {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
}

.permission-target-summary > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permission-warning {
  margin: 10px 0 14px;
  padding: 9px 11px;
  border-left: 2px solid var(--gb-yellow);
  background: rgba(250, 189, 47, 0.08);
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.5;
}

.perm-group {
  margin: 20px 0 5px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.perm-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.perm-info { flex: 1; min-width: 0; }
.perm-label { color: var(--text); font-size: 12.5px; font-weight: 700; }
.perm-desc { color: var(--text-muted); font-size: 11px; line-height: 1.4; }

.tri-group {
  display: inline-grid;
  grid-template-columns: repeat(3, 30px);
  flex: 0 0 auto;
  border: 1px solid var(--border);
}

.tri {
  width: 30px;
  height: 28px;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
}

.tri:last-child { border-right: 0; }
.tri:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.tri.active.tri-deny { background: var(--gb-red); color: var(--bg); }
.tri.active.tri-inherit { background: var(--surface-hover); color: var(--text); }
.tri.active.tri-allow { background: var(--gb-green); color: var(--bg); }
.tri:disabled { cursor: not-allowed; opacity: 0.42; }

/* Éditeur de rôles du serveur. */

.role-editor-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.role-editor-toolbar .settings-section-title { margin-bottom: 3px; }
.role-editor-toolbar p { color: var(--text-muted); font-size: 11px; line-height: 1.45; }

.role-editor-layout {
  display: grid;
  grid-template-columns: minmax(185px, 0.8fr) minmax(290px, 1.6fr);
  gap: 14px;
  align-items: start;
}

.role-editor-list {
  border: 1px solid var(--border);
  background: var(--bg);
  max-height: 62vh;
  overflow-y: auto;
  padding: 5px;
}

.role-editor-list-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 40px;
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.role-editor-list-row + .role-editor-list-row { margin-top: 3px; }
.role-editor-list-row:hover { background: var(--surface); color: var(--text); }
.role-editor-list-row.selected { border-color: var(--primary); background: var(--surface); }
.role-editor-list-row.dragging { opacity: 0.45; }
.role-editor-list-row.drag-over { box-shadow: inset 0 2px 0 var(--primary); }

.role-drag-handle {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  cursor: grab;
}

.role-drag-handle.locked { cursor: default; opacity: 0.55; }

.role-editor-select {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 5px;
  text-align: left;
}

.role-editor-list-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.role-editor-count {
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.role-order-actions { display: flex; padding-right: 2px; }
.role-order-btn {
  width: 22px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.role-order-btn.up svg { transform: rotate(180deg); }
.role-order-btn:hover:not(:disabled) { color: var(--primary); background: var(--bg-elevated); }
.role-order-btn:disabled { opacity: 0.2; cursor: not-allowed; }

.role-editor-pane {
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 14px;
}

.role-editor-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.role-editor-title .settings-section-title { margin-bottom: 3px; }
.role-editor-title h3 { font-size: 17px; overflow-wrap: anywhere; }
.role-locked-tag { color: var(--gb-yellow); }

.role-color-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.role-color-input {
  width: 42px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.role-color-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.role-color-swatches .swatch { width: 24px; height: 24px; }

.role-toggle-list {
  display: grid;
  gap: 7px;
  margin: 16px 0 20px;
}

.role-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.role-toggle:hover { background: var(--surface); }
.role-toggle input { margin-top: 3px; accent-color: var(--primary); }
.role-toggle span { display: grid; gap: 2px; }
.role-toggle strong { font-size: 12px; }
.role-toggle small { color: var(--text-muted); font-size: 10.5px; line-height: 1.4; }

.role-permissions-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}
.role-permissions-head .settings-section-title { margin-bottom: 8px; }
.role-permissions-head > span { color: var(--text-muted); font-size: 10px; }

.role-permission-group {
  min-width: 0;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid var(--border);
}

.role-permission-group legend {
  margin-left: 8px;
  padding: 0 6px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.role-permission-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  cursor: pointer;
}

.role-permission-option + .role-permission-option { border-top: 1px solid var(--border); }
.role-permission-option:hover { background: var(--surface); }
.role-permission-option input { flex: 0 0 auto; margin-top: 3px; accent-color: var(--primary); }
.role-permission-option > span { display: grid; min-width: 0; }
.role-permission-label { color: var(--text); font-size: 12px; font-weight: 700; }
.role-permission-desc { color: var(--text-muted); font-size: 10.5px; line-height: 1.4; }
.role-permission-option:has(input:disabled) { cursor: not-allowed; opacity: 0.52; }

.role-editor-actions {
  position: sticky;
  bottom: -14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 16px -14px -14px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.server-role-editor[aria-busy='true'] { cursor: progress; }
.server-role-editor button:disabled,
.server-role-editor input:disabled { cursor: not-allowed; }

@media (max-width: 720px) {
  .role-editor-layout { grid-template-columns: 1fr; }
  .role-editor-list { max-height: 220px; }
  .permission-target-field { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .role-editor-list-row { scroll-behavior: auto; }
}

/* Bandeau de synchronisation entre un salon et sa categorie. */
.sync-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0 14px;
  padding: 9px 11px;
  border-left: 2px solid var(--gb-orange, var(--gb-yellow));
  background: rgba(254, 128, 25, 0.08);
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.5;
}
.sync-banner span { flex: 1; min-width: 0; }
.sync-banner svg { flex-shrink: 0; }
.sync-banner .btn { flex-shrink: 0; }

.sync-banner.sync-on {
  border-left-color: var(--gb-green);
  background: rgba(184, 187, 38, 0.08);
}
