/* Portal composition for the authenticated interactive surface (MainLayout + pages).
   Mint-only classes layered on the design system's chrome/component vocabulary (README,
   "Design system") — ds/tokens/components.css owns .portal-*, .nav-item, .data-table,
   .status-pill, …; this sheet adds what the User & Role reference screens compose on top.
   Tokens only, no raw hex; the dark theme comes from the aliases remapping underneath. */

/* ── Chrome extras ───────────────────────────────────────────────────────── */
.nav-rail {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.nav-rail .nav-item {
    text-decoration: none;
}

.nav-item-btn {
    width: 100%;
    border: 0;
    background: none;
    font-family: inherit;
    text-align: left;
}

.nav-logout {
    margin-top: auto;
    padding-top: var(--space-5);
}

.portal-user {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.portal-user-name {
    font-size: var(--fs-label);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.nav-burger {
    display: none;
}

/* Theme toggle — one glyph per choice; the button carries data-choice (set by site.js). */
.theme-toggle .i-moon,
.theme-toggle .i-system {
    display: none;
}

.theme-toggle[data-choice="dark"] .i-sun,
.theme-toggle[data-choice="system"] .i-sun {
    display: none;
}

.theme-toggle[data-choice="dark"] .i-moon,
.theme-toggle[data-choice="system"] .i-system {
    display: inline-flex;
}

@media (max-width: 880px) {
    .nav-burger {
        display: inline-flex;
    }

    .portal-sidebar {
        position: fixed;
        top: var(--top-nav-height);
        bottom: 0;
        left: 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform var(--transition-fast);
        box-shadow: var(--shadow-drawer);
    }

    .portal-sidebar.is-open {
        transform: none;
    }
}

/* ── Page canvas: every screen lines up with every other ─────────────────────
   The centred column (.page-wrap, max-width 1180px, margin: 0 auto) is the design
   system's own layout and is kept as-is. What made screens disagree was the SCROLLBAR:
   .portal-main scrolls, so a long page lost ~15px of width to the scrollbar and its
   centred content sat left of a short page's. Reserving the gutter permanently makes
   a scrolling page and a short one start at the identical x-position.

   Any new screen inherits this by rendering inside MainLayout — pages must not set
   their own outer padding, margin, or max-width. */
.portal-main {
    scrollbar-gutter: stable;
}

/* ── Page header (reference: .page-title / .page-sub) ────────────────────── */
.page-title {
    font-family: var(--font-display);
    font-weight: var(--fw-medium);
    font-size: var(--fs-page-title);
    letter-spacing: var(--ls-display);
    color: var(--text-primary);
}

.page-sub {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 3px;
    max-width: 62ch;
}

/* Sub-heading inside a page body (below .page-title). */
.section-title {
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-card-title);
    color: var(--text-primary);
    margin: var(--space-11) 0 var(--space-4);
}

/* ── List toolbar (search + count) ───────────────────────────────────────── */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.list-toolbar .input-search {
    width: 300px;
}

.count-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: var(--ls-chip);
    color: var(--text-label);
}

.list-toolbar.wrap {
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-field {
    display: flex;
    flex-direction: column;
}

.filter-field .form-select,
.filter-field .form-input {
    min-width: 170px;
}

/* ── Utilities the reference leans on ────────────────────────────────────── */
/* .row / .row-between / .stack are the design system's own flex utilities
   (ds/tokens/components.css). Only the wrap modifier is added here.
   Historical note: these were temporarily renamed .zrow while Bootstrap was still
   loaded — its grid owned .row, and its `.row > *` rule (width: 100%) outranked a bare
   .row, stretching every chip, tag and icon button to full cell width. Bootstrap is
   gone, so the DS-native names are back. */
.row.wrap {
    flex-wrap: wrap;
}

/* Modal helpers */
.modal-title {
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-drawer-title);
    color: var(--text-primary);
}

.delete-head {
    align-items: flex-start;
    gap: var(--space-6);
}

.delete-head .empty-icon {
    margin-bottom: 0;
}

.empty-icon.is-danger {
    background: var(--status-danger-soft);
    color: var(--status-danger-text);
}

.blocked-note {
    margin-top: var(--space-6);
}

/* Danger-toned ghost icon button (row delete actions). */
.btn.is-danger-tone {
    color: var(--text-danger);
}

.btn.is-danger-tone:hover:not(:disabled) {
    background: var(--status-danger-soft);
    color: var(--status-danger-text);
}

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--text-label);
}

.eyebrow {
    font: var(--type-label);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    color: var(--text-label);
}

/* Card wrapper for a .data-table. A wide table (the audit log's seven columns) scrolls
   HORIZONTALLY INSIDE its own card — the page itself must never scroll sideways, which
   would drag the header and rail out of view. overflow-x on the card both enables that
   scroll and clips the table's corners to the radius. */
.table-card {
    background: var(--surface-primary);
    border: var(--rule);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: hidden;
}

/* The minimum is the table's own natural content width (the audit log's seven columns
   measure ~810px). Below that the columns would squeeze instead of scrolling; at or above
   it the card simply fits and shows no scrollbar. Never guess this number lower than the
   content — a too-small minimum silently disables the scroll it was meant to provide. */
.table-card .data-table {
    min-width: 810px;
}

.cell-title {
    font-size: 13.5px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.cell-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-label);
}

/* ── Role editor: grouped permission accordions ──────────────────────────── */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-7);
}

.perm-search {
    width: 260px;
}

.feat-title {
    flex: 1;
    min-width: 0;
    gap: 1px;
}

.summary-count {
    align-items: baseline;
    margin: var(--space-3) 0 var(--space-5);
}

/* Page-level notices between the header and the content (RoleEdit's cascade + system-role
   banners). Without this they sat flush against both, breaking the 22px page rhythm every
   other screen keeps. */
.banner {
    margin-bottom: var(--space-5);
}

.page-head + .banner {
    margin-top: calc(-1 * var(--space-2));
}

.role-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--space-10);
    align-items: start;
    margin-top: var(--space-10);
}

.role-summary {
    position: sticky;
    top: calc(var(--top-nav-height) + var(--space-7));
}

.feat-group {
    border: var(--rule);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.feat-group + .feat-group {
    margin-top: var(--space-4);
}

.feat-head {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-5) var(--space-6);
    border: 0;
    background: var(--surface-secondary);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.feat-head .caret {
    transition: transform var(--transition-fast);
    color: var(--text-label);
    flex: none;
}

.feat-group.is-open .feat-head .caret {
    transform: rotate(90deg);
}

.feat-name {
    font-size: 13.5px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.feat-desc {
    font-size: var(--text-xs);
    color: var(--text-label);
}

.feat-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    background: var(--surface-primary);
}

.perm-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border: var(--rule);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-control);
}

.perm-check:hover {
    border-color: var(--border-strong);
}

.perm-check.is-checked {
    border-color: var(--brand-primary);
    background: var(--brand-primary-soft);
}

.perm-key {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: .03em;
    color: var(--text-label);
}

.pill-count {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: var(--fw-semibold);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-tertiary);
    color: var(--text-secondary);
    white-space: nowrap;
}

.perm-summary-chip {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-top: var(--rule);
    font-size: var(--fs-body-sm);
}

.perm-summary-chip .acts {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-label);
    text-align: right;
}

/* ── User detail: layout + effective access + overrides ──────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--space-9);
    align-items: start;
}

.col-stack {
    gap: var(--space-9);
}

.card-pad {
    padding: var(--space-6) var(--space-8);
}

.card-pad > .page-sub {
    margin: 0 0 var(--space-5);
}

.overflow-visible {
    overflow: visible;
}

.click-catcher {
    position: fixed;
    inset: 0;
    z-index: 39;
}

.acc-text {
    font-size: var(--fs-body-sm);
    color: var(--text-secondary);
}

.acc-expiry {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-label);
}

.mode-chip {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    background: var(--brand-primary-soft);
    color: var(--brand-on-soft);
    white-space: nowrap;
}

.mode-chip.is-block {
    background: var(--status-danger-soft);
    color: var(--status-danger-text);
}


.acc-line {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-top: var(--rule);
    font-size: var(--fs-body-sm);
}

.acc-line:first-of-type {
    border-top: 0;
}

.acc-feature {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    min-width: 110px;
}

.acc-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.acc-badge.via-role {
    background: var(--brand-primary-soft);
    color: var(--brand-on-soft);
}

.acc-badge.via-override {
    background: var(--brand-accent-soft);
    color: var(--tint-violet-fg);
}

.acc-badge.via-none {
    background: var(--surface-tertiary);
    color: var(--text-label);
}

.res-card {
    border: var(--rule);
    border-radius: var(--radius-md);
    padding: var(--space-5) var(--space-6);
    background: var(--surface-primary);
}

.res-card + .res-card {
    margin-top: var(--space-4);
}

.res-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.res-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-7);
    margin-top: var(--space-4);
}

.act-cell {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-body-sm);
    color: var(--text-secondary);
}

.intent-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    border: var(--rule);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-control);
}

.intent-card:hover {
    border-color: var(--border-strong);
}

.intent-card.is-selected {
    border-color: var(--brand-primary);
    background: var(--brand-primary-soft);
}

.search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-4) var(--space-5);
    border: 0;
    border-radius: var(--radius-md);
    background: none;
    font-family: inherit;
    font-size: var(--fs-body-sm);
    text-align: left;
    cursor: pointer;
}

.search-result:hover {
    background: var(--surface-secondary);
}
