/*
    THE SHARED DETAIL PANE FOR SETTINGS SPLIT SCREENS.

    The right-hand side of cim360-settings-split.css: a header with a title, pills and actions, then
    whatever that screen's body is. Used by Roles and by Column Sets.

    Global rather than a .razor.css for the reason set out at the top of cim360-settings-split.css -
    an isolated stylesheet cannot be shared between components, so a second screen wanting this look
    has no option but to reimplement it, and an approximation is what makes two screens look like two
    products.

    The crd- prefix is historical: these rules began in CompanyRoleDetailPanel.razor.css and were
    moved here verbatim so the Roles screen could not regress. Read crd- as "the split detail pane".

    ── Original header ──────────────────────────────────────────────────────────────────────────
    Measurements and colours from the Sprint 5 prototype - settings/lib/hifi-roles.jsx,
   RoleDetailPanel. Its inline tokens map onto this product's custom properties, which are used here
   so the pane themes with the rest of the product. */

.crd {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    /* clip, not hidden. hidden makes this a scroll container, and a sticky header inside one
       sticks to IT - which never scrolls, because the pane grows to its content and the settings
       card (.settings-content) is what actually scrolls. clip trims the same way without becoming
       a scroller, so .crd-head below can stick to the card. DEV-TC-1058. */
    overflow: clip;
}

/* ─── Identity header ─── */
/* A tinted band rather than plain white, so the role's identity reads as a first-class header
   rather than as body content. */
.crd-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--cim360-border);
    /* Pinned while the body scrolls, so the Save / Cancel pair for pending permission edits
       (.crd-actions-row.is-save, inside this header) stays reachable. Without it the bar sat at
       the top of a 6,000-8,000px matrix and was 3,300px above the viewport once scrolled, at
       every width - measured at 1600 and 768. The tint is laid over the card so the header is
       opaque when content passes beneath it, and the upward shadow in the card's colour covers
       the scroller's top padding strip, where the scrolled rows would otherwise show through.
       z-index above the matrix's own sticky column header (4). DEV-TC-1058. */
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 -1.25rem 0 0 var(--cim360-card);
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--cim360-primary) 7%, transparent) 0%,
            color-mix(in srgb, var(--cim360-primary) 2%, transparent) 100%),
        var(--cim360-card);
}

/* .crd-avatar has gone: the detail header now uses Cim360Monogram at Large/Solid, which carries
   these same 48px measurements. */

.crd-head-main {
    flex: 1 1 auto;
    min-width: 0;
}

.crd-head-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.crd-head-title h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--cim360-text);
}

/* ─── The three header pills ─── */
/* One metric for all of them. They previously carried three different paddings and two different
   font sizes - 4px/10px at 11.5px, 2px/7px at 10px, 3px/9px at 10px - so System, Active and Default
   sat at three visibly different heights on the same line. Only the colours differ now. */
.crd-sysbadge,
.crd-state,
.crd-default {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    height: 1.375rem;
    padding: 0 0.5625rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-radius: 62.4375rem;
    white-space: nowrap;
    box-sizing: border-box;
}

.crd-sysbadge {
    background: var(--cim360-info-bg);
    color: var(--cim360-caption);
    border: 1px solid var(--cim360-border);
}

.crd-sysbadge .bi {
    font-size: 0.75rem;
}

.crd-state-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: currentColor;
}

.crd-state.is-active {
    background: rgba(22, 163, 74, .12);
    color: var(--cim360-success-fg);
    border: 1px solid var(--cim360-success-border);
}

/* Red rather than slate: an inactive role grants nothing, which is a state worth noticing. */
.crd-state.is-inactive {
    background: rgba(220, 38, 38, .10);
    color: var(--cim360-danger-fg);
    border: 1px solid var(--cim360-danger-border);
}

.crd-default {
    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));
    white-space: nowrap;
}

.crd-desc {
    font-size: 0.7813rem;
    color: var(--cim360-text-muted);
    margin-top: 0.25rem;
}

.crd-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--cim360-text-muted);
    flex-wrap: wrap;
}

/* inline-flex with a gap, so the spacing between label and value cannot depend on whether Razor
   happened to keep a newline. Baseline rather than centre: the value is bold and the label is not,
   and centring two different weights leaves them visibly off each other. */
.crd-meta-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3125rem;
    white-space: nowrap;
}

.crd-meta-label {
    color: var(--cim360-text-muted);
}

.crd-meta strong {
    color: var(--cim360-text);
    font-weight: 700;
}

/* ─── Header actions ─── */
/* Two stacked rows: the record actions, then the save pair. The 340px cap this replaced was what
   wrapped five buttons onto two ragged lines on a non-system role - the break landed wherever the
   labels happened to fall, so Deactivate and Set default moved between lines as a role's name
   changed the header width. Sized to the content instead, and wrapping only when the viewport
   genuinely cannot take it. */
.crd-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    flex: 0 0 auto;
    min-width: 0;
}

.crd-actions-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

/* The save pair reads as a decision about unsaved work, not as another record action, so it gets
   its own separation rather than sitting flush under the row above. */
.crd-actions-row.is-save {
    align-items: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--cim360-border);
    width: 100%;
}

.crd-actions-note {
    margin-right: auto;
    font-size: 0.7813rem;
    font-weight: 600;
    color: var(--cim360-primary);
    white-space: nowrap;
}

.crd-btn {
}


.crd-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.crd-btn.is-primary {
    background: color-mix(in srgb, var(--cim360-primary) 6%, var(--cim360-card));
    border-color: color-mix(in srgb, var(--cim360-primary) 32%, var(--cim360-card));
    color: color-mix(in srgb, var(--cim360-primary) 72%, var(--cim360-text-strong));
}

.crd-btn.is-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--cim360-primary) 12%, var(--cim360-card));
    border-color: color-mix(in srgb, var(--cim360-primary) 55%, var(--cim360-card));
}

/* Ghost rather than filled, matching the Delete… convention used in modals across the project: the
   destructive option is available without being the loudest thing on the header. */
.crd-btn.is-danger {
    border-color: var(--cim360-danger-border);
    color: var(--cim360-danger-fg);
}

.crd-btn.is-danger:hover:not(:disabled) {
    background: var(--cim360-danger-bg);
}

.crd-btn.is-success {
    border-color: var(--cim360-success-border);
    color: var(--cim360-success-fg);
}

.crd-btn.is-success:hover:not(:disabled) {
    background: var(--cim360-success-bg);
}

/* ─── Refusal ─── */
/* Cim360Message now, as .c360-msg.is-error in css/forms/cim360-dialog.css. This was one of ten
   private spellings of the same line across Settings. */

/* ─── Tab bar ─── */
/* On a slate band, with the active tab as a raised white pill rather than an underline, so the
   chrome matches the other coloured surfaces on this screen. */
.crd-tabs {
    display: flex;
    gap: 0.375rem;
    padding: 0.5rem 1.5rem 0;
    background: var(--cim360-info-bg);
    border-bottom: 1px solid var(--cim360-border);
}

.crd-tabs button {
    padding: 0.5rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    color: var(--cim360-text-muted);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
    cursor: pointer;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.crd-tabs button.is-on {
    background: var(--cim360-card);
    color: var(--cim360-primary);
    font-weight: 700;
    border-color: var(--cim360-border);
    box-shadow: 0 -1px 0 color-mix(in srgb, var(--cim360-primary) 40%, transparent) inset;
}

.crd-tab-count {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 1px 0.4375rem;
    border-radius: 62.4375rem;
    background: var(--cim360-info-bg);
    color: var(--cim360-text-muted);
}

.crd-tabs button.is-on .crd-tab-count {
    background: color-mix(in srgb, var(--cim360-primary) 12%, var(--cim360-card));
    color: color-mix(in srgb, var(--cim360-primary) 72%, var(--cim360-text-strong));
}

/* ─── Body ─── */
.crd-body {
    padding: 0 1.5rem 1.5rem;
    background: var(--cim360-surface-3);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.crd-pending {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3.5rem 1.5rem;
    text-align: center;
    color: var(--cim360-text-muted);
}

.crd-pending > i {
    font-size: 1.75rem;
    color: color-mix(in srgb, var(--cim360-primary) 45%, var(--cim360-text-tint-base));
}

.crd-pending strong {
    font-size: 0.875rem;
    color: var(--cim360-text);
}

.crd-pending span {
    font-size: 0.7813rem;
    max-width: 46ch;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .crd-head {
        flex-wrap: wrap;
    }

    /* Below 900px the header has already wrapped, so the actions start a line of their own and
       read better left-aligned under the name than pushed to the right edge. Both the column and
       the rows inside it, or the rows would stay right-aligned within a left-aligned column. */
    .crd-actions {
        align-items: stretch;
        width: 100%;
    }

    .crd-actions-row {
        justify-content: flex-start;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════
   SHARED DATA LIST — the long scrolling list inside a detail pane.

   The chrome only: the scroller, the sticky column-header bar, the row separator and the hover.
   Each screen keeps its own cell geometry, because that is the part that genuinely differs - the
   permission matrix has a name column and N verb columns, the column-set list has a tick, a label
   and two buttons.

   The values are the permission matrix's, moved here rather than copied so the two cannot drift.
   RolePermissionMatrix's own stylesheet no longer declares them.
   ═══════════════════════════════════════════════════════════════════════════════════════════════ */

.c360-dl-scroll {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
    background: var(--cim360-card);
}

.c360-dl-head,
.c360-dl-row {
    display: flex;
    align-items: center;
}

/*
    36px, surface-2, 11px uppercase muted-and-bold - the same bar the Locations grid uses. Sticky,
    because these lists run to 69 rows and the header is what says which column is which.
*/
.c360-dl-head {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 2.25rem;
    background: var(--cim360-surface-2);
    border-bottom: 1px solid var(--cim360-border);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--cim360-text-muted);
}

.c360-dl-row {
    background: var(--cim360-card);
    border-bottom: 1px solid var(--cim360-border-soft);
}

.c360-dl-row:hover {
    background: var(--cim360-surface-2);
}

/* A row whose thing is switched on. Tint rather than a weight change: at 69 rows a bold run reads
   as a heading. */
.c360-dl-row.is-on {
    background: var(--cim360-primary-soft);
}

.c360-dl-row.is-on:hover {
    background: var(--cim360-primary-tint);
}

/* ---- printer settings (DEV-443) ---- */

/* The margin is what separates the Add a printer button from the heading below it. It used to be
   overridden by a `.settings-section h2` rule in SettingsShell.razor.css, which carried the shell's
   scope attribute and so outweighed this class, and the heading sat against the button (DEV-586).
   That rule is gone. Each heading now owns its margin and colour, the way SettingsPageHeader
   already did. */
.ps-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--cim360-primary);
    margin: 1.25rem 0 .25rem;
}

.ps-hint {
    font-size: .75rem;
    color: var(--cim360-text-muted);
    margin: 0 0 .75rem;
    max-width: 62ch;
}

.ps-list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.ps-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .375rem .5rem;
    border: 1px solid var(--cim360-border);
    border-radius: 0.25rem;
}

/* A printer out of service still reads, but recedes - it is not a fault, it is a choice. */
.ps-row.off { opacity: .65; }

.ps-row > .n {
    display: flex;
    flex-direction: column;
    min-width: 12rem;
    flex: 1 1 auto;
}

.ps-row > .n > .t { font-weight: 600; }

.ps-row > .n > .d {
    font-size: .75rem;
    color: var(--cim360-text-muted);
}

.ps-row > .a {
    font-size: .75rem;
    color: var(--cim360-text-muted);
    min-width: 12rem;
}

.ps-add {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--cim360-border);
}
