/* selection.css -- Phase 2 "Project Work" (scoped Selection) panel on Matched Contractor cards.
 * Reuses the card's own accent via var(--card-color) (the contractor card resolves to orange), per the
 * "one set of role colors" rule -- no hardcoded hex. Minimal by design; richer Project Status is Phase 3. */

.npca-v2-assigned-work {
    margin: 0.75rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.npca-v2-assigned-work__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.npca-v2-assigned-work__title {
    font-weight: 600;
    font-size: 0.9rem;
}
.npca-v2-assigned-work__panel {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.npca-v2-assigned-work__group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.npca-v2-assigned-work__label {
    /* Softened 0.17.109: sentence-case (not all-caps) so section labels read as friendly guidance rather
       than administrative headers, while staying a clear muted sub-heading in the hierarchy. */
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--match-ink-muted, #5A6577);
}
.npca-v2-assigned-work__list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.npca-v2-assigned-work__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
    padding: 0.1rem 0;
    font-size: 0.92rem;
}
/* Assigned-row primary content (0.17.109): the check + scope name owns the row; the destructive action
   stays compact and right-aligned (margin-left:auto on __remove). */
.npca-v2-assigned-work__item-name {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--match-ink, #272F3D);
}
.npca-v2-assigned-work__item label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
}
.npca-v2-assigned-work__item--muted {
    color: rgba(0, 0, 0, 0.45);
    font-style: italic;
}
.npca-v2-assigned-work__empty {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.55);
}
.npca-v2-assigned-work__flag {
    font-size: 0.7rem;
    font-weight: 600;
    color: #8a5a00;
    background: rgba(248, 105, 2, 0.12);
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
}
.npca-v2-assigned-work__assign {
    align-self: flex-start;
    background: var(--card-color, #036836);
}
/* Compact destructive row action (0.17.109): a small trash-icon button -- red, right-aligned, clearly
   SECONDARY to the scope name -- replacing the oversized outlined "Remove" pill. 36px hit target (above
   the WCAG 2.5.8 minimum), visible keyboard focus, and destructive meaning carried by icon + red +
   aria-label/title (never colour-only). */
.npca-v2-assigned-work__remove {
    flex: 0 0 auto;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--match-danger, #B3261E);
    cursor: pointer;
}
.npca-v2-assigned-work__remove:hover {
    background: color-mix(in srgb, var(--match-danger, #B3261E) 10%, transparent);
    border-color: color-mix(in srgb, var(--match-danger, #B3261E) 35%, transparent);
}
.npca-v2-assigned-work__remove:focus-visible {
    outline: 2px solid var(--match-danger, #B3261E);
    outline-offset: 2px;
}
.npca-v2-assigned-work__remove:disabled { opacity: 0.5; cursor: default; }
.npca-v2-assigned-work__remove svg { width: 16px; height: 16px; display: block; }
.npca-v2-assigned-work__error {
    margin: 0.6rem 0 0;
    color: #b3261e;
    font-size: 0.85rem;
}

/* Read-only at-a-glance summary on the card (populated after the modal loads). */
.npca-v2-assigned-work__summary {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.75);
}
.npca-v2-assigned-work__summary-label {
    font-weight: 600;
    color: rgba(0, 0, 0, 0.55);
    margin-right: 0.25rem;
}
.npca-v2-assigned-work__hint {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: rgba(0, 0, 0, 0.5);
}
/* Reset the fieldset used to group the "Available to assign" checkboxes. */
.npca-v2-assigned-work__group[class] { border: 0; padding: 0; margin: 0; min-width: 0; }
legend.npca-v2-assigned-work__label { padding: 0; }

/* ---- Project Work action group (0.17.105) -------------------------------------------------------
 * On a Matched Contractor card, the "Project Work" heading + its scoped-selection trigger (Select /
 * Manage / Re-select for Project) used to sit in their own row with the trigger pushed to the far
 * right (justify-content: space-between on __head), reading as a stranded control disconnected from
 * the card's Save / Withdraw Interest actions below. This groups them: the heading (and the
 * "Assigned:" summary) sit on their own line, and Save + Withdraw Interest + the Project Work trigger
 * read as ONE wrapping action row.
 *
 * Mechanism: the card wraps the actions row and the assigned-work component in .npca-v2-match-card__pw-group
 * and flattens the intermediate boxes with display:contents so all three buttons share one flex row.
 * The trigger button STAYS inside [data-npca-assigned-work] (selection.js binds its modal via
 * closest(), unchanged) and the position:fixed modal is unaffected by the flattening. The actions row
 * is rendered first in the DOM (so keyboard focus order is Save -> Withdraw -> Re-select, matching the
 * visual left-to-right order); the non-focusable heading/summary are lifted above the buttons with
 * `order`. Wraps cleanly at narrow widths -- no absolute positioning. */
.npca-v2-match-card__pw-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.npca-v2-match-card__pw-group > .npca-v2-match-card__actions,
.npca-v2-match-card__pw-group > .npca-v2-assigned-work,
.npca-v2-match-card__pw-group .npca-v2-assigned-work__head {
    display: contents;
}
.npca-v2-match-card__pw-group .npca-v2-assigned-work__title { order: -2; flex: 0 0 100%; margin: 0; }
.npca-v2-match-card__pw-group .npca-v2-assigned-work__summary { order: -1; flex: 0 0 100%; margin: 0; }
/* Vertical alignment: the 0.17.106 scoped `margin-top: 0` override that used to live here is gone --
   0.17.107 removed the legacy `margin-top: 6px` at its source (match.css) and introduced the canonical
   Match-card action-button geometry (box-sizing/min-height/inline-flex/margin:0) that governs every
   action button in both the standard row and this group. No per-button vertical margins remain. */
/* Narrow widths: match the card's own 720px behavior -- all three actions stack full-width, comfortable
   tap targets, no overflow, no button detached from the group. */
@media (max-width: 720px) {
    .npca-v2-match-card__pw-group .npca-v2-button {
        flex: 1 0 100%;
        width: 100%;
        text-align: center;
    }
}

/* ---- Scope-selection modal (Phase 2 modal refinement) ---- */
body.npca-v2-modal-open { overflow: hidden; }
.npca-v2-select-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
/* CRITICAL (2026-09-10): the modal is shown/hidden purely by toggling the `hidden` attribute in
   selection.js (openModal -> hidden=false, closeModal/Escape/backdrop/Cancel -> hidden=true). An
   author-origin `display:flex` above beats the UA stylesheet's `[hidden]{display:none}` by cascade
   ORIGIN (regardless of specificity), so WITHOUT this guard the attribute has no visual effect: the
   modal paints open on every Matched Contractor card at load ("spontaneous modal") and no close
   control (X, Escape, backdrop, Cancel) can hide it. This guard makes `hidden` authoritative again --
   the same fix already present for .npca-v2-match-track[hidden] (match.css) and
   .npca-v2-portal-nav__children[hidden] (dashboard.css). Do not remove. */
.npca-v2-select-modal[hidden] { display: none; }
.npca-v2-select-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.npca-v2-select-modal__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 30rem;
    max-height: 85vh;
    overflow-y: auto;
    background: #ffffff;
    color: #1a1a1a;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    padding: 1.15rem 1.25rem 1.35rem;
    outline: none;
}
.npca-v2-select-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}
.npca-v2-select-modal__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}
.npca-v2-select-modal__close {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.5);
    padding: 0 0.15rem;
}
.npca-v2-select-modal__close:hover { color: rgba(0, 0, 0, 0.85); }
.npca-v2-select-modal__close:focus-visible { outline: 2px solid var(--match-ink, #272F3D); outline-offset: 2px; border-radius: 4px; }
.npca-v2-select-modal__sub {
    margin: 0.4rem 0 0.9rem;
    font-size: 0.88rem;
    color: rgba(0, 0, 0, 0.62);
}
.npca-v2-select-modal__panel {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}
.npca-v2-select-modal__error {
    margin: 0.75rem 0 0;
    color: #b3261e;
    font-size: 0.85rem;
}
/* Context note shown in "Re-select" mode (the Contractor was previously removed from this Project). */
.npca-v2-select-modal__note {
    margin: 0.4rem 0 0.9rem;
    font-size: 0.86rem;
    color: rgba(0, 0, 0, 0.68);
    background: rgba(248, 105, 2, 0.08);
    border-left: 3px solid rgba(248, 105, 2, 0.5);
    border-radius: 4px;
    padding: 0.5rem 0.7rem;
}
/* Modal action footer (0.17.109) -- a single clear "Okay" (done) action, separated from the panel by a
   top divider. Every action in this modal is immediate, so "Okay" only closes (no deferred write); the
   former standalone "Cancel" was removed as byte-for-byte identical to it. "Okay" uses the base
   .npca-v2-button (the same primary footer-close treatment the legal-viewer modals use) -- one
   modal-footer-primary look across the family, no per-modal restyle. */
.npca-v2-select-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Dark-mode block REMOVED in 0.17.99 (CSS isolation Phase B). The host Bricks site is permanently
   light. This block turned the on-card "Assigned:" summary/labels WHITE on the light card (illegible
   when a viewer's OS was dark), and gave the modal its own dark surface. NPCA now commits to light
   (`.npca-v2-shell { color-scheme: light }`): the on-card text stays dark, and the modal keeps its
   light-mode white dialog + dark text -- readable on the light host regardless of the OS setting. */
