/* ===========================================
   Member access (projects/_member_access.html): Discord role chips, access levels,
   channel chips, the profile's Channel access card, the role picker and hover card,
   the Discord roles tab and a role's page.
   =========================================== */

/* A Discord role. Discord's own role colour is data (``--rc`` inline), shown as the dot. */
.dc-role { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-pill); background: var(--fill-1); box-shadow: inset 0 0 0 1px var(--hairline); color: var(--label-1); font-size: 12.5px; white-space: nowrap; text-decoration: none; }
.dc-role::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rc, var(--label-3)); flex-shrink: 0; }
a.dc-role:hover, .dc-role[aria-describedby] { color: var(--label-1); background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.dc-role .role-remove-btn { margin-left: 2px; }
.dc-role.is-pending { opacity: 0.65; box-shadow: inset 0 0 0 1px var(--line-strong); }
.dc-role.is-pending .dc-role-note { font-size: 11px; color: var(--label-3); }
.dc-role.is-plain { height: auto; padding: 0; background: none; box-shadow: none; font-size: 13.5px; font-weight: 500; }
.dc-role.is-plain:hover { background: none; box-shadow: none; }
.dc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rc, var(--label-3)); flex-shrink: 0; }
.dc-dot.lg { width: 14px; height: 14px; }

/* The profile card's platform rows (under the collony.ai roles) */
.dt-roles .plat-label { display: inline-flex; align-items: center; gap: 4px; min-width: 72px; }
.dt-roles .plat-label .platform-icon { width: 12px; height: 12px; }
.dt-roles .tg-status { font-size: 13px; color: var(--label-2); }
.dt-roles .tg-status b { color: var(--label-1); font-weight: 500; }

/* Access level: one per channel, coloured by its tone (Admin danger, Moderate info,
   Write success, Read only neutral, No access muted). */
.acc-lvl { display: inline-flex; align-items: center; justify-content: center; height: 20px; min-width: 84px; padding: 0 8px; border-radius: var(--r-pill); background: var(--tone-ghost); color: var(--tone-bold); font-size: 12px; font-weight: 600; white-space: nowrap; }
.acc-lvl.sm { min-width: 0; }

/* A channel or chat */
.acc-ch { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); background: var(--fill-1); color: var(--label-1); font-size: 12.5px; white-space: nowrap; }
.acc-ch > svg { width: 12px; height: 12px; flex-shrink: 0; color: var(--label-3); }
.acc-ch .platform-icon { width: 12px; height: 12px; }
.acc-ch .via { color: var(--label-3); font-size: 11.5px; }
.acc-chs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.acc-fx { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--label-2); }

/* Channel access card: By access / By role */
.access-card .dt-card-head .tabs { margin-left: 12px; }
.access-card[data-mode="level"] [data-mode-body="role"],
.access-card[data-mode="role"] [data-mode-body="level"] { display: none; }
.acc-groups { display: flex; flex-direction: column; }
.acc-group { display: grid; grid-template-columns: 110px 28px minmax(0, 1fr); align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--hairline); }
.acc-group:first-child { border-top: 0; }
.acc-group .n { font-variant-numeric: tabular-nums; color: var(--label-2); font-size: 13px; text-align: right; }
.role-fx { display: flex; flex-direction: column; }
.role-fx-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--hairline); }
.role-fx-row:first-child { border-top: 0; }
.role-fx-row > .dc-role { justify-self: start; }
.role-fx-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--hairline); font-size: 12.5px; color: var(--label-3); }
.role-fx .none { color: var(--label-3); }

/* Role picker (+ Discord role) */
.role-picker { width: 340px; max-height: 420px; overflow-y: auto; text-align: left; }
.role-picker .pop-item .sub { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-picker .pop-foot, .add-members-pop .pop-foot { padding: 8px 10px 4px; margin-top: 4px; border-top: 1px solid var(--hairline); font-size: 12px; line-height: 1.4; color: var(--label-3); }
.pop-search { display: flex; margin: 4px 4px 6px; }
.pop-search input { width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--input-bg); color: var(--label-1); font: 400 13px var(--font); }
.pop-search input:focus { outline: none; border-color: var(--accent); }

/* Role hover card (hovercard.js) */
.role-card { display: grid; gap: 10px; }
.role-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.role-card-head .user-card-name { min-width: 0; }
.role-card-sub { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.role-card-sec { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border-light); }

/* Discord roles tab */
.roles-list-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.roles-list-head .micro .platform-icon { width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; }
.roles-table td { vertical-align: middle; }
.roles-table tr[data-href] { cursor: pointer; }
.roles-table .badge.stat-chip { min-width: 0; font-size: 11.5px; }
.roles-table .who-can { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--label-2); }
.roles-table .who-can.is-locked { color: var(--label-3); }
.roles-table .go { width: 16px; height: 16px; color: var(--label-3); }
.lock-ico { width: 12px; height: 12px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.bot-line td { padding: 4px 10px; background: var(--ai-tint); }
.bot-line td > span { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--label-2); }
.bot-line b { color: var(--label-1); font-weight: 500; }
.bot-line .avatar-ai { width: 22px; height: 22px; }

/* A role's page */
.role-title { display: flex; align-items: center; gap: 10px; }
.page-subtitle .platform-icon { width: 13px; height: 13px; vertical-align: -2px; }
.diff-table td.arrow { width: 20px; padding: 0; color: var(--label-3); }
.diff-table th.lv { width: 120px; }
.right-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--label-3); }
.right-row b { font-weight: 500; }
.right-row.is-on { color: var(--label-1); }
.right-row .tick { width: 16px; height: 16px; display: grid; place-items: center; flex-shrink: 0; }
.right-row .tick svg { width: 14px; height: 14px; color: var(--c-success-bold); }
.role-members td { vertical-align: middle; }
.role-members .who { display: inline-flex; align-items: center; gap: 8px; color: var(--label-1); text-decoration: none; }
.role-members .who b { font-weight: 500; }
.role-members .avatar { width: 24px; height: 24px; font-size: 11px; }
.add-members-pop { width: 320px; }
.add-members-pop .pop-item .avatar { width: 20px; height: 20px; font-size: 10px; }
.head-anchor { position: relative; display: inline-flex; }
.head-anchor > .popover { top: calc(100% + 6px); right: 0; }
.head-anchor > .popover:not(.open) { display: none; }

@media (max-width: 640px) {
    .acc-group { grid-template-columns: auto 1fr; row-gap: 6px; }
    .acc-group .n { text-align: left; }
    .acc-group .acc-chs { grid-column: 1 / -1; }
    .role-fx-row { grid-template-columns: 1fr auto; row-gap: 6px; }
    .role-fx-row .acc-fx { grid-column: 1 / -1; grid-row: 2; }
    .access-card .dt-card-head { flex-wrap: wrap; row-gap: 8px; }
    .access-card .dt-card-head .tabs { order: 3; flex-basis: 100%; margin: 0; }
    .roles-table .hide-phone, .role-members .hide-phone, .diff-table .hide-phone { display: none; }
    /* Roles stack: name, members and the arrow, then what the role changes. */
    .roles-table thead { display: none; }
    .roles-table, .roles-table tbody { display: block; }
    .roles-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; align-items: center; column-gap: 10px; row-gap: 6px; padding: 10px 0; border-top: 1px solid var(--hairline); }
    .roles-table tr > td { padding: 0; border: 0; }
    .roles-table tr > td.acc-fx-cell { grid-column: 1 / -1; grid-row: 2; }
    .roles-table tr.bot-line { display: block; padding: 0; }
    .roles-table tr.bot-line > td { display: block; padding: 6px 10px; }
    .role-picker { width: min(340px, calc(100vw - 32px)); }
}
.roles-list-head .dt-card-aside .input input { text-align: left; }
/* An open role picker stays above the cards after the profile card. */
.dt-card:has(.role-picker.open) { position: relative; z-index: 5; }
