/* ═════════════════════════════════════════════════════════════════════════════
 * rolepicker.css — v3 (2026-05)
 *
 * UX compacta: módulos colapsados por padrão, roles como pills (32px),
 * "marcar todos" por grupo, 3–4 pills por linha.
 * ═════════════════════════════════════════════════════════════════════════════ */

#mU-roles, [data-rolepicker-root] {
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  text-align: left !important;
  font-family: 'DM Sans', system-ui, sans-serif !important;
}
.rp-toolbar, .rp-templates, .rp-groups, .rp-preview, .rp-save-tpl {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ── Toolbar ── */
.rp-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
}
.rp-search {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}
.rp-search:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.1); }
.rp-counter { font-size: 12px; color: #6b7280; white-space: nowrap; }
.rp-counter b { color: #7c3aed; font-size: 14px; }

/* Botão expandir/retrair todos */
.rp-btn-toggle-all {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff; color: #374151;
  cursor: pointer; transition: all .12s;
  white-space: nowrap; flex-shrink: 0;
}
.rp-btn-toggle-all:hover { background: #f3f4f6; border-color: #9ca3af; }

/* ── Templates retráteis ── */
.rp-templates {
  background: #fefce8;
  border: 1px dashed #facc15;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.rp-tpl-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; user-select: none;
  transition: background .12s;
}
.rp-tpl-header:hover { background: #fef9c3; }
.rp-tpl-arrow { display: inline-block; width: 14px; font-size: 10px; color: #854d0e; }
.rp-tpl-label { font-size: 13px; font-weight: 700; color: #854d0e; }
.rp-tpl-counter { font-size: 11px; color: #a16207; font-style: italic; margin-left: auto; }
.rp-tpl-body { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.rp-templates.collapsed .rp-tpl-body { display: none !important; }

.rp-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; background: #fff;
  border: 1px solid #facc15; border-radius: 999px;
  font-size: 12px; cursor: pointer; transition: all .15s; color: #854d0e;
}
.rp-chip:hover { background: #fef9c3; border-color: #ca8a04; transform: translateY(-1px); }
.rp-chip.rp-chip-locked { opacity: .55; background: #f3f4f6; border-color: #d1d5db; border-style: dashed; color: #6b7280; cursor: not-allowed; }
.rp-chip-name { font-weight: 600; }
.rp-chip-count { background: #fde68a; color: #854d0e; padding: 1px 5px; border-radius: 10px; font-size: 11px; font-weight: 700; }

/* ── Grupos (módulos) ── */
.rp-groups { display: flex; flex-direction: column; gap: 4px; }

.rp-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.rp-group-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  background: #f8fafc;
  transition: background .12s;
}
.rp-group-header:hover { background: #f0f4ff; }
.rp-arrow { width: 12px; font-size: 9px; color: #94a3b8; flex-shrink: 0; }
.rp-mod-icon { font-size: 16px; flex-shrink: 0; }
.rp-mod-name {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
  letter-spacing: .01em;
}

/* Badge com contagem */
.rp-sel-badge {
  font-size: 11px; font-weight: 700;
  background: #7c3aed; color: #fff;
  padding: 2px 7px; border-radius: 12px;
  flex-shrink: 0;
}
.rp-total-badge {
  font-size: 11px; color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 7px; border-radius: 12px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

/* Botão "marcar todos" */
.rp-btn-all {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  background: #faf5ff; color: #7c3aed;
  cursor: pointer; transition: all .12s;
  flex-shrink: 0;
  white-space: nowrap;
}
.rp-btn-all:hover { background: #ede9fe; border-color: #7c3aed; }
.rp-btn-all.active { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.rp-btn-all.active:hover { background: #6d28d9; }

/* Corpo colapsado — oculto por padrão */
.rp-group-body {
  display: none;
  padding: 8px 10px;
  flex-wrap: wrap;
  gap: 5px;
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
}
/* Expandido */
.rp-group.expanded .rp-group-body { display: flex; }
.rp-group.expanded .rp-group-header { background: #f0f4ff; }

/* ── Role pill (compacto, linha única) ── */
.rp-role-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  padding: 4px 10px !important;
  cursor: pointer;
  border-radius: 999px !important;
  border: 1px solid #e2e8f0 !important;
  background: #fff !important;
  transition: all .12s;
  font-size: 12.5px !important;
  font-weight: 500;
  color: #374151;
  user-select: none;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 !important;
  min-height: 0 !important;
  height: auto !important;
}
.rp-role-pill:hover { background: #f1f5f9 !important; border-color: #94a3b8 !important; }
.rp-role-pill.on {
  background: #ede9fe !important;
  border-color: #a78bfa !important;
  color: #5b21b6;
  font-weight: 600;
}
.rp-role-pill.on:hover { background: #ddd6fe !important; border-color: #7c3aed !important; }

/* Checkbox oculto (visual é feito pelo pill) */
.rp-cb {
  width: 14px !important; height: 14px !important;
  margin: 0 !important; padding: 0 !important;
  cursor: pointer; accent-color: #7c3aed;
  flex-shrink: 0 !important;
}

/* Ponto colorido indicando nível */
.rp-nivel-dot {
  width: 7px !important; height: 7px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
}

.rp-role-name {
  font-size: 12.5px !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: capitalize;
}

/* Empty state */
.rp-empty {
  padding: 24px; text-align: center;
  color: #9ca3af; background: #fff;
  border: 2px dashed #e5e7eb; border-radius: 8px;
  font-size: 13px;
}

/* Preview */
.rp-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 12px;
  color: #166534;
}
.rp-preview-label { font-weight: 600; margin-right: 4px; }
.rp-warn { color: #b45309; background: #fef3c7; padding: 2px 7px; border-radius: 4px; }

/* Salvar template */
.rp-save-tpl { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e5e7eb; }
.rp-btn-tpl {
  width: 100%; padding: 8px;
  background: #fff; border: 1px dashed #7c3aed;
  border-radius: 6px; color: #7c3aed;
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.rp-btn-tpl:hover { background: #ede9fe; border-style: solid; }

/* Responsivo */
@media (max-width: 600px) {
  .rp-toolbar { flex-direction: column; align-items: stretch; }
  .rp-counter { text-align: center; }
  .rp-btn-all { font-size: 10px; padding: 2px 7px; }
}

/* ═══ Modal próprio ══════════════════════════════════════════════════════════ */
.rp-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17,24,39,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; animation: rp-fade-in .15s ease-out;
}
@keyframes rp-fade-in { from { opacity: 0; } to { opacity: 1; } }
.rp-modal {
  background: #fff; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  max-width: 480px; width: 90%;
  padding: 22px 24px 18px;
  animation: rp-slide-up .2s ease-out;
}
@keyframes rp-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.rp-modal-title { font-size: 17px; font-weight: 700; color: #111827; margin-bottom: 12px; }
.rp-modal-body { font-size: 14px; color: #374151; line-height: 1.55; margin-bottom: 20px; }
.rp-modal-body p { margin: 6px 0; }
.rp-modal-body b { color: #111827; }
.rp-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.rp-modal-btn {
  padding: 9px 16px; border-radius: 7px;
  border: 1px solid #d1d5db; background: #fff;
  color: #374151; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s; min-width: 100px;
}
.rp-modal-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.rp-modal-btn.primary { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.rp-modal-btn.primary:hover { background: #6d28d9; border-color: #6d28d9; }
.rp-modal-btn.danger { background: #fff; border-color: #dc2626; color: #dc2626; }
.rp-modal-btn.danger:hover { background: #fee2e2; }
.rp-modal-btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(124,58,237,.25); }

@media (max-width: 480px) {
  .rp-modal { padding: 18px; }
  .rp-modal-actions { flex-direction: column-reverse; }
  .rp-modal-btn { width: 100%; }
}
