/* Estilos para admin/roles - replicando protótipo plat-papeis.html */

:root {
  --fg: #0f1720;
  --fg-2: #515b67;
  --fg-tertiary: #7b8491;
  --muted: #93999f;
  --surface: #ffffff;
  --surface-soft: #f5f5f7;
  --border-soft: #e0e0e3;
  --border: #d0d0d5;
  --accent: #00af55;
  --accent-soft: #e6f6ed;
  --danger: #d62c34;
  --success: #00a84f;
  --focus-ring: 0 0 0 3px rgba(0, 175, 85, 0.16);
  --elev-soft: 0 1px 2px rgba(8, 12, 20, 0.08);
  --elev-raised: 0 4px 12px rgba(8, 12, 20, 0.12);
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "Monaco", "Menlo", "Ubuntu Mono", monospace;
}

[data-theme="dark"] {
  --fg: #eff0f1;
  --fg-2: #aaafb9;
  --fg-tertiary: #858d99;
  --muted: #70777f;
  --surface: #1a1f28;
  --surface-soft: #242a34;
  --border-soft: #3a404a;
  --border: #4a505a;
  --accent: #2fd67c;
  --accent-soft: #0f2a1c;
  --focus-ring: 0 0 0 3px rgba(47, 214, 124, 0.18);
  --elev-soft: 0 1px 2px rgba(0, 0, 0, 0.2);
  --elev-raised: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ad-head {
  margin-bottom: 20px;
}

.ad-head h1 {
  font-size: 26px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.ad-head .eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.ad-head .desc {
  margin-top: 6px;
  color: var(--fg-2);
  font-size: 14px;
  max-width: 76ch;
  line-height: 1.5;
}

/* ──────── lista de papéis (cards) ──────── */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.role-card {
  position: relative;
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--elev-soft);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.14s, transform 0.12s, box-shadow 0.2s;
}

.role-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--elev-raised);
}

.role-card .top {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
}

.role-card .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: none;
}

.role-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

.role-card .sys {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: auto;
}

.role-card .rd {
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.5;
  min-height: 38px;
  margin: 0;
}

.role-card .foot {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border-soft);
}

.role-card .stat {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--fg-2);
}

.role-card .stat b {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--fg);
}

.role-card .stat svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.role-card .go {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.new-card {
  border: 1px dashed var(--border);
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--fg-2);
  font-weight: 700;
  min-height: 150px;
}

.new-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

.new-card svg {
  width: 20px;
  height: 20px;
}

/* ──────── editor ──────── */
.view {
  display: none;
}

.view.on {
  display: block;
  animation: vfade 0.22s ease;
}

@keyframes vfade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 0;
  color: var(--fg-2);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 14px;
}

.back:hover {
  color: var(--accent);
}

.back svg {
  width: 16px;
  height: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--elev-soft);
  padding: 22px 24px;
}

.card + .card {
  margin-top: 16px;
}

/* cabeçalho: título/descrição editáveis inline + escopo */
.pv5-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.pv5-titles {
  flex: 1;
  min-width: 240px;
}

.pv5-name {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--fg);
  padding: 3px 6px;
  margin-left: -6px;
}

.pv5-name::placeholder {
  color: var(--muted);
  opacity: 1;
}

.pv5-name:hover {
  border-color: var(--border-soft);
}

.pv5-name:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.pv5-name.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(214, 44, 52, 0.18);
}

.pv5-desc {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font-size: 14px;
  color: var(--fg-2);
  padding: 4px 6px;
  margin-left: -6px;
  margin-top: 4px;
  font-family: inherit;
}

.pv5-desc::placeholder {
  color: var(--muted);
  opacity: 1;
}

.pv5-desc:hover {
  border-color: var(--border-soft);
}

.pv5-desc:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.pv5-scope {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fg-2);
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 13px;
  flex: none;
}

.pv5-scope svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.sys-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 13px;
  color: #005aa3;
  font-weight: 600;
  margin-bottom: 16px;
}

.sys-banner svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* barra de ferramentas das permissões */
.mtx-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.mtx-bar .t {
  font-size: 15px;
  font-weight: 800;
}

.mtx-bar .c {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 11px;
}

.mtx-bar .sp {
  flex: 1;
}

.mini-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fg-2);
  cursor: pointer;
}

.mini-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ──────── master-detail ──────── */
.pv5-md {
  display: grid;
  grid-template-columns: 296px 1fr;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  overflow: hidden;
}

@media (max-width: 760px) {
  .pv5-md {
    grid-template-columns: 1fr;
  }
}

.pv5-cats {
  border-right: 1px solid var(--border-soft);
  background: var(--surface-soft);
  padding: 8px;
  max-height: 560px;
  overflow: auto;
}

@media (max-width: 760px) {
  .pv5-cats {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    max-height: none;
  }
}

.pv5-sec {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 13px 12px 6px;
}

.pv5-sec:first-child {
  padding-top: 6px;
}

.pv5-cat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fg-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.pv5-cat:hover {
  background: var(--surface);
}

.pv5-cat.on {
  background: var(--surface);
  color: var(--fg);
  box-shadow: inset 3px 0 0 var(--accent);
}

.pv5-cat .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pv5-cat .cnt {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  flex: none;
}

.pv5-cat.full .cnt {
  color: var(--success);
}

.pv5-cat.empty .cnt {
  color: var(--muted);
  opacity: 0.6;
}

.pv5-panel {
  padding: 22px 24px;
  min-height: 340px;
}

.pv5-panel h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 8px 0;
}

.pv5-panel .pd {
  font-size: 12.5px;
  color: var(--fg-2);
  margin-top: 4px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.pv5-act {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--border-soft);
}

.pv5-act:last-child {
  border-bottom: 0;
}

.pv5-act .al {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}

.pv5-act .ah {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* toggle switch */
.sw {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  display: inline-block;
}

.sw input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.sw .tr {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.16s;
}

.sw .kn {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(8, 12, 20, 0.28);
  transition: transform 0.16s;
}

.sw input:checked ~ .tr {
  background: var(--accent);
}

.sw input:checked ~ .kn {
  transform: translateX(18px);
}

.sw input:disabled {
  cursor: not-allowed;
}

.sw input:disabled ~ .tr {
  opacity: 0.5;
}

/* A save bar (.savebar / .savebar-in / .savebar.is-open) é o componente
   canônico do app, definido em app/assets/tailwind/components.css. No Tailwind v4
   a visibilidade usa a propriedade `translate` (--tw-translate-y) alternada pela
   classe `.is-open` — não redefinir aqui com `transform`, pois as duas
   propriedades se somam e a barra ficaria presa fora da tela. */

.danger-zone {
  border: 1px solid rgba(214, 44, 52, 0.3);
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 16px;
}

.danger-zone h3 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--danger);
  margin: 0 0 6px 0;
}

.danger-zone p {
  font-size: 12.5px;
  color: var(--fg-2);
  margin: 0 0 12px 0;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: rgba(214, 44, 52, 0.88);
  border-color: rgba(214, 44, 52, 0.88);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(214, 44, 52, 0.4);
}

.btn-outline-danger:hover {
  background: rgba(214, 44, 52, 0.08);
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.5);
  backdrop-filter: blur(2px);
  z-index: 80;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.dialog {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 64px -20px rgba(8, 12, 20, 0.5);
  overflow: hidden;
}

.dialog .d-body {
  padding: 24px 24px 8px;
}

.dialog h3 {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 8px 0;
}

.dialog p {
  font-size: 13.5px;
  color: var(--fg-2);
  line-height: 1.55;
  margin: 0;
}

.dialog .d-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px 20px;
}

/* O toast (.toast / .toast.is-show) é o componente canônico do app, definido em
   app/assets/tailwind/components.css. No Tailwind v4 ele usa `visibility` +
   `translate` alternados pela classe `.is-show` — não redefinir aqui com
   `transform`/`show`, senão o `visibility: hidden` do Tailwind vence e o toast
   nunca aparece. O ícone é dimensionado pela própria classe utilitária. */

.row {
  display: flex;
  gap: 10px;
}

/* NÃO redefinir .btn/.btn-primary/.btn-secondary/.btn-ghost/.btn-sm aqui:
   os botões canônicos (pill, verdes) vêm de app/assets/tailwind/components.css.
   Como o Turbo mantém os <link> de stylesheet entre navegações, redefinir
   essas classes globais aqui vazava para outras telas (botão azul, radius 8px).
   Apenas .btn-danger/.btn-outline-danger (acima) permanecem como aditivos. */
