/*
    THE SHARED SPLIT-SCREEN SHELL FOR SETTINGS.

    A rail of things on the left, a detail pane on the right. Used by Company Settings > Roles and
    Company Settings > Column Sets, and by anything else in Settings that takes the same shape.

    Global rather than a .razor.css, and that is the whole point of the file. Blazor rewrites an
    isolated stylesheet's selectors per component, so styles living beside one screen cannot reach
    another - which is exactly how Column Sets ended up with a second, hand-written copy of these
    measurements that only approximated them. The two screens looked like two products. There is now
    one set of rules and they cannot drift.

    The cr- prefix is historical: these rules began life in CompanyRolesPanel.razor.css and were
    moved here verbatim, deliberately, so the Roles screen's markup did not have to change and could
    not regress. Read cr- as "the split shell", not as "company roles".

    Anything genuinely specific to one screen stays in that screen's own .razor.css. The test is
    whether a second screen would want it.

    ── Original header ──────────────────────────────────────────────────────────────────────────
    Measurements, colours and behaviour taken from the Sprint 5 prototype -
   settings/lib/hifi-roles.jsx, RolesRail and RoleRailRow. Its inline tokens map onto this
   product's custom properties: primary var(--cim360-primary) -> --cim360-primary, border var(--cim360-border) ->
   --cim360-border, text #1f2937 -> --cim360-text, textMuted var(--cim360-text-muted) -> --cim360-text-muted.
   The tokens are used rather than the literals so the tab themes with the rest of the product. */

.cr-split {
    display: flex;
    align-items: stretch;
    min-height: 32.5rem;
    border: 1px solid var(--cim360-border);
    border-radius: 0.625rem;
    /* clip, not hidden: rounds the corners without becoming a scroll container, which would
       capture the detail pane's sticky header (.crd-head) - see .crd. DEV-TC-1058. */
    overflow: clip;
    background: var(--cim360-card);
}

/* ─── Rail ─── */
/* 340px fixed, per the prototype. Not a percentage: the rail holds names and two counts, so its
   useful width does not change with the viewport, and a proportional one starves the detail pane. */
.cr-rail {
    display: flex;
    flex-direction: column;
    width: 21.25rem;
    flex: 0 0 21.25rem;
    border-right: 1px solid var(--cim360-border);
    background: var(--cim360-card);
    min-height: 0;
}

.cr-rail-head {
    background: var(--cim360-headerband-bg);
    color: var(--cim360-headerband-fg);
    padding: 0.75rem 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.cr-rail-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.cr-rail-head-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.cr-rail-head-title strong {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--cim360-headerband-fg);
}

.cr-rail-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 0.5rem;
    /* A DARK tint and the band's own foreground. The 18% white tint this had lifted the brand blue
       under white text to under 4.5:1 (axe, Settings - Roles, 2026-09-25) - the same fault
       .c360-dlg-btn had - and a hard-coded #fff was unreadable on the themes whose band is light. */
    background: rgba(0, 0, 0, .12);
    color: var(--cim360-headerband-fg);
    border-radius: 62.4375rem;
    white-space: nowrap;
}

.cr-rail-new {
    height: 1.75rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    background: var(--cim360-card);
    color: var(--cim360-primary);
    border: 0;
    border-radius: 0.25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: 0 0 auto;
}

.cr-rail-new:hover {
    background: color-mix(in srgb, var(--cim360-primary) 10%, var(--cim360-card));
}

/* Search sits on the blue, so it is a white pill rather than the tinted field used on white. */
.cr-rail-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--cim360-card);
    height: 1.75rem;
    padding: 0 0.75rem;
    border-radius: 62.4375rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    min-width: 0;
}

.cr-rail-search > i {
    font-size: 0.75rem;
    line-height: 1;
    color: var(--cim360-text-muted);
    flex: 0 0 auto;
    pointer-events: none;
}

.cr-rail-search input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--cim360-text);
    font-size: 0.75rem;
    font-family: inherit;
}

.cr-rail-search input::placeholder {
    color: var(--cim360-text-muted);
}

.cr-rail-search button {
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cim360-text-muted);
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.cr-rail-search button:hover {
    color: var(--cim360-text);
}

/* ─── Quick filters ─── */
/* Same treatment as the Users tab quick filters (.cu-toolbar-status): a white pill group, a dot per
   state, the count beside the label, and solid primary when selected. They previously sat as
   translucent-white segments on the blue band, which read as a different control doing the same job
   on the next settings screen along. */

.cr-rail-filters {
    display: flex;
    align-items: stretch;
    /* Wraps rather than clips. Four filters in a 340px rail is genuinely tight, and a second row is
       always better than a label reading "Inactiv". */
    flex-wrap: wrap;
    background: var(--cim360-card);
    border-radius: 0.5rem;
    padding: 0.1875rem;
    gap: 0.1875rem;
}

/* flex: 1 1 auto - grow to fill the rail, but from each button's OWN content width.
   The basis is what makes this work, and it has been wrong in both directions:
     flex: 1 1 0    gave every button an equal share, so "All" was as wide as "Inactive" and the
                    long labels clipped;
     flex: 0 1 auto sized each to its content but let them bunch at the left with dead space
                    trailing.
   With an auto basis they share the spare width proportionally: "All" stays the narrowest,
   "Inactive" the widest, the group fills the rail and nothing truncates. */
.cr-filter-btn {
    flex: 1 1 auto;
    background: transparent;
    border: 0;
    color: var(--cim360-text);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3125rem 0.375rem;
    border-radius: 0.375rem;
    cursor: pointer;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 0;
    transition: background 160ms ease, color 160ms ease;
}

@media (prefers-reduced-motion: reduce) {
    .cr-filter-btn { transition: none; }
}

.cr-filter-btn:hover:not(.active) {
    background: color-mix(in srgb, var(--cim360-primary) 8%, var(--cim360-card));
}

.cr-filter-btn.active {
    background: var(--cim360-primary-surface);
    color: var(--cim360-text-inverse);
    font-weight: 600;
}

/* No ellipsis: the group wraps instead, so a label never needs truncating. Truncation here is
   worse than a second row - "System" and "Custom" clip to the same few letters. */
.cr-filter-label {
    white-space: nowrap;
}

.cr-filter-count {
    font-weight: 700;
    opacity: .9;
}

.cr-filter-btn.active .cr-filter-count {
    color: var(--cim360-text-inverse);
}

/* A filter matching nothing is still shown - a zero is an answer, and a bar whose buttons come and
   go is harder to use than one that stays put. Same call as the Users tab. */
/* Receded by COLOUR, not opacity: the button still filters when clicked, so it is not an inactive
   component WCAG exempts, and .55 opacity took its label under 4.5:1 (axe, 2026-09-25). */
.cr-filter-btn.is-empty:not(.active) {
    color: var(--cim360-text-muted);
}

.cr-filter-dot {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

/* Each dot takes the colour that state already uses elsewhere on this screen: slate for the system
   padlock, brand for a custom role, red for inactive - which the header pill also draws in red
   because a role that grants nothing is worth noticing. "All" has no dot: it is the absence of a
   filter, not a fifth state. */
.cr-filter-dot.cr-filter-system   { background: #64748b; }
.cr-filter-dot.cr-filter-custom   { background: var(--cim360-primary-surface); }
.cr-filter-dot.cr-filter-inactive { background: var(--cim360-danger); }

/* On the selected (solid primary) button the dots would otherwise disappear into the fill. */
.cr-filter-btn.active .cr-filter-dot {
    background: var(--cim360-text-inverse);
}

.cr-rail-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--cim360-surface-2);
}

.cr-rail-note {
    padding: 2rem 0.875rem;
    text-align: center;
    color: var(--cim360-text-muted);
    font-size: 0.7813rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    line-height: 1.5;
}

.cr-rail-note strong {
    color: var(--cim360-text);
    font-size: 0.8125rem;
}

/* A failure must not look like "nothing here". */
.cr-rail-note.is-error {
    color: var(--cim360-danger);
}

.cr-rail-note.is-error strong,
.cr-rail-note.is-error > i {
    color: var(--cim360-danger, var(--cim360-danger));
}

.cr-rail-note.is-error > i {
    font-size: 1.25rem;
}

.cr-rail-retry {
    margin-top: 0.25rem;
    height: 1.875rem;
    padding: 0 0.875rem;
    border: 1px solid var(--cim360-danger, var(--cim360-danger));
    border-radius: 0.25rem;
    background: var(--cim360-card);
    color: var(--cim360-danger);
    font-family: inherit;
    font-size: 0.7813rem;
    font-weight: 600;
    cursor: pointer;
}

.cr-rail-retry:hover {
    background: var(--cim360-danger-bg, var(--cim360-danger-bg));
}

/* ─── Rail row ─── */
.cr-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    background: var(--cim360-card);
    border-left: 0.1875rem solid transparent;
    border-bottom: 1px solid var(--cim360-border);
    cursor: pointer;
    user-select: none;
    transition: background 90ms;
}

.cr-row.is-stripe {
    background: var(--cim360-card);
}

.cr-row:hover {
    background: color-mix(in srgb, var(--cim360-primary) 6%, var(--cim360-card));
}

/* Declared after hover so a selected row stays selected-looking under the pointer. */
.cr-row.is-selected,
.cr-row.is-selected:hover {
    background: color-mix(in srgb, var(--cim360-primary) 10%, var(--cim360-card));
    border-left-color: var(--cim360-primary);
}

.cr-row:focus-visible {
    outline: 2px solid var(--cim360-primary);
    outline-offset: -2px;
}

/* Dimmed, not struck through: deactivating is reversible and keeps every member attached. */
.cr-row.is-off {
    opacity: .6;
}

/* .cr-row-avatar has gone: the row now uses Cim360Monogram at Medium/Tint, which carries these
   same 32px measurements AND the squares-for-things rule that was written down here. */

.cr-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.cr-row-title {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.cr-row-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--cim360-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* One line only. Two roles with long descriptions would otherwise give the rail rows of three
   different heights, and the list stops scanning as a list. */
.cr-row-desc {
    margin-top: 2px;
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--cim360-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cr-row-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.1875rem;
    font-size: 0.75rem;
    color: var(--cim360-text-muted);
    white-space: nowrap;
}

.cr-row-meta .cr-dot {
    font-size: 0.75rem;
}

.cr-row-meta .cr-row-inactive {
    color: var(--cim360-danger-fg);
    font-weight: 600;
}

/* ─── System badge (rail size) ─── */
.cr-sysbadge {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 2px 0.4375rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 62.4375rem;
    background: var(--cim360-info-bg);
    color: var(--cim360-caption);
    border: 1px solid var(--cim360-border);
    white-space: nowrap;
    flex: 0 0 auto;
}

.cr-sysbadge .bi {
    font-size: 0.75rem;
}

/* ─── Detail side ─── */
.cr-detail-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cr-detail-none {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--cim360-text-muted);
    background: var(--cim360-surface-3);
}

.cr-detail-none > i {
    font-size: 1.875rem;
    color: color-mix(in srgb, var(--cim360-primary) 45%, var(--cim360-text-tint-base));
}

.cr-detail-none strong {
    font-size: 0.875rem;
    color: var(--cim360-text);
}

.cr-detail-none span {
    font-size: 0.7813rem;
    max-width: 40ch;
    line-height: 1.5;
}

/* ─── Responsive ─── */
/* The rail stops being a rail and becomes a list above the detail. A 340px column beside a detail
   pane does not fit a tablet, and shrinking it truncates the names the rail exists to show. */
@media (max-width: 900px) {
    .cr-split {
        flex-direction: column;
        min-height: 0;
    }

    .cr-rail {
        width: auto;
        flex: 0 0 auto;
        border-right: 0;
        border-bottom: 1px solid var(--cim360-border);
    }

    .cr-rail-list {
        max-height: 20rem;
    }
}

/* The DEFAULT marker on a rail row. Geometry from .cr-sysbadge beside it so the two sit on one
   line without one nudging the other; colours from .crd-default in the detail header so the same
   fact is the same colour wherever it is stated. Not a shared class because the two live in
   different scoped stylesheets - if a third place ever needs it, that is the moment it moves to
   the shared sheet rather than being copied again. */
.cr-defaultbadge {
    display: inline-flex;
    align-items: center;
    padding: 2px 0.4375rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 62.4375rem;
    white-space: nowrap;
    background: color-mix(in srgb, var(--cim360-primary) 10%, var(--cim360-card));
    color: color-mix(in srgb, var(--cim360-primary) 72%, var(--cim360-text-strong));
    border: 1px solid color-mix(in srgb, var(--cim360-primary) 32%, var(--cim360-card));
}
