/* ─── Users tab ───────────────────────────────────────────────────────────────────
   Sixth derivative of the workspace archetype. The .perm-* rules below now dress the
   permission editor inside the pane rather than inside a modal: its two nav layers are
   the rail's job (users_chrome.js), so the outer category strip and the inner 180px
   tab column are both gone from here.
   ─────────────────────────────────────────────────────────────────────────────── */

/* sections · the section's list · whatever is selected */
.users-workspace { --rail-w: 13rem; --panel-w: 21rem; grid-template-columns: var(--rail-col) minmax(0, 1fr) var(--panel-col); }

/* the pane is a column of chrome and one scrolling view, not a scroller itself */
.users-pane { display: flex; flex-direction: column; overflow: hidden; }
.users-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.users-section .table-scroll { flex: 1; min-height: 0; margin-bottom: 0; }

/* the editor's panels scroll as one, the way a table's shell does */
#perm-cat-panels { flex: 1; min-height: 0; overflow-y: auto; padding: 0.2rem 0.4rem 0.6rem; }

#users-tbody tr, #roles-tbody tr, #groups-tbody tr { cursor: pointer; }

/* what the drill changed but hasn't saved — the list a modal never had room for */
.perm-change-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.perm-change-table td { padding: 0.2rem 0.3rem; border-bottom: 1px solid var(--border-light); color: var(--text-sub); }
.perm-change-table td.col-action { text-align: right; white-space: nowrap; }
.perm-change-empty { font-size: 0.78rem; color: var(--text-faint); padding: 0.3rem; margin: 0; }


/* ─── Access editor ───────────────────────────────────────────────────────────── */

/* Areas / Workflows headings over their rows, reading as the rail's heads do */
.perm-group-head {
  margin: 0.9rem 0 0.1rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.perm-group-head:first-child { margin-top: 0.2rem; }

/* the inspector's "This role can" lines */
.perm-can-list { margin: 0.2rem 0 0; padding-left: 1rem; font-size: 0.78rem; color: var(--text-sub); display: flex; flex-direction: column; gap: 0.25rem; }

/* one access row per subsection, divided from the row above it */
.perm-subsection {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
}
.perm-subsection + .perm-subsection {
  border-top: 1px solid var(--border-light);
}
.perm-subsection-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sub);
}

.perm-tab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.2rem 1rem;
}

.perm-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0;
  font-size: 0.8rem;
  color: var(--text-sub);
  cursor: pointer;
  text-transform: capitalize;
}
.perm-row:hover { color: var(--text); }

/* ─── Access ladder ──────────────────────────────────────────────────────────── */

.perm-resource .perm-subsection-header {
  justify-content: flex-start;
}

/* a quiet side note — a switch's detail, a compare cell's switch count */
.perm-res-id {
  margin-left: auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-faint);
}

.perm-res-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.1rem 0 0.25rem;
}

/* Segmented control — the rungs read as one control rather than four buttons */
.perm-level {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.perm-level-btn {
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  padding: 0.22rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--text-sub);
  cursor: pointer;
}
.perm-level-btn:last-child { border-right: none; }
.perm-level-btn:hover { background: var(--row-hover); color: var(--text); }
.perm-level-btn[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
/* None is a real selection, not an accent-worthy one */
.perm-level-btn[data-level="none"][aria-pressed="true"] {
  background: var(--surface-deep);
  color: var(--text);
}

/* Spells out what the held rung grants on this row */
.perm-level-summary {
  font-size: 0.74rem;
  color: var(--text-faint);
}

/* A row's switches — each one is its own decision, not a rung */
.perm-res-extras {
  padding-left: 0.6rem;
}
.perm-res-extras .perm-row { text-transform: none; }

/* ─── Compare roles ──────────────────────────────────────────────────────────── */

.perm-compare-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.perm-compare-table th,
.perm-compare-table td { padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border-light); text-align: left; white-space: nowrap; }
.perm-compare-table th { position: sticky; top: 0; background: var(--table-surface); color: var(--text-muted); font-weight: 600; }
.perm-compare-group { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); background: var(--table-surface); }
.perm-compare-cell { border: none; cursor: pointer; font: inherit; }

/* The API grants grid · functional sizing only, its visual pass is still to come */
.perm-eye { display: inline-flex; width: 0.9rem; height: 0.9rem; margin-left: 0.3rem; vertical-align: middle; }
.perm-eye svg { width: 100%; height: 100%; }
.perm-eye--off { color: var(--text-faint); }
.workspace-row.is-hidden .workspace-row-label { color: var(--text-faint); }
.perm-api-table .icon-slot { display: inline-flex; width: 0.9rem; height: 0.9rem; margin-right: 0.35rem; vertical-align: middle; }
.perm-api-table .perm-eye { margin-left: 0; }
.perm-route { display: inline-flex; align-items: center; gap: 0.4rem; }
.perm-route code { font-size: 0.74rem; }

/* The pane head: presets, Select all, then the tab's visibility pushed right */
.perm-pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0.15rem 0 0.6rem; }
.perm-pane-head .perm-sel-all { margin: 0; text-transform: none; }
.perm-pane-vis { margin-left: auto; }
.perm-pane-hint { margin: 0 0 0.9rem; max-width: 72ch; font-size: 0.8rem; line-height: 1.45; color: var(--text-muted); }
