/* Relation-filtered object picker shared by commercial and execution editors. */
.object-picker {
    --object-picker-row-height: 50px;
    --object-picker-row-gap: 6px;
    --object-picker-scrollbar-width: 8px;
    --object-picker-summary-width: 360px;
    display: flex;
    width: 100%;
    min-height: var(--interface-control-height);
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

/* Five equal rows stay visible; additional linked objects scroll above the linking action. */
.object-picker__summary {
    display: flex;
    width: min(100%, calc(var(--object-picker-summary-width, 225px) + var(--object-picker-scrollbar-width)));
    min-height: var(--interface-control-height);
    max-height: calc(5 * var(--object-picker-row-height) + 4 * var(--object-picker-row-gap));
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--object-picker-row-gap);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

/* A visible scrollbar makes further selected objects discoverable without changing bar widths. */
.object-picker__summary::-webkit-scrollbar {
    width: var(--object-picker-scrollbar-width);
}

.object-picker__summary::-webkit-scrollbar-track {
    background: var(--interface-edit-surface);
}

.object-picker__summary::-webkit-scrollbar-thumb {
    border: 2px solid var(--surface);
    border-radius: 8px;
    background: var(--interface-placeholder);
}

.object-picker__summary:has(.object-picker__reference) {
    min-height: 0;
}

.object-picker__summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 8px;
}

.object-picker__summary > span {
    color: var(--interface-placeholder);
    font-size: var(--interface-value-size);
    font-style: italic;
    font-weight: 450;
    line-height: 1.5;
}

/* Linked object dossiers use one calm reference card in every editor. */
.object-picker__reference {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    height: var(--object-picker-row-height);
    min-width: 0;
    flex: 0 0 var(--object-picker-row-height);
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    overflow: hidden;
    border: 1px solid #cfe0ec;
    border-radius: 8px;
    background: #f4faff;
    color: var(--navy-900);
    text-decoration: none;
    transition: border-color .15s ease, background .15s ease;
}

.object-picker__reference:hover,
.object-picker__reference:focus-visible {
    border-color: #9fbed3;
    background: #eaf6ff;
    color: var(--navy-900);
}

.object-picker__reference:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.object-picker__reference-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.object-picker__reference-copy strong,
.object-picker__reference-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.object-picker__reference-copy strong {
    font-size: 12px;
    font-weight: 750;
    line-height: 1.35;
}

.object-picker__reference-copy small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;
}

.object-picker__reference-chevron {
    flex: 0 0 auto;
    color: var(--blue-700);
    font-size: 19px;
    font-weight: 500;
    line-height: 1;
}

/* The linking action follows the central secondary-action contract. */
.association-link-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.association-link-action > span,
.association-link-action > .link-icon {
    display: block;
}

.object-picker__open {
    min-height: 32px;
    gap: 6px;
    padding: 6px 10px;
    border-color: #c8d7e2;
    border-radius: var(--radius-small);
    color: var(--blue-700);
    font-size: var(--interface-helper-size);
    font-weight: 700;
    line-height: 1.2;
}

.object-picker__open:hover,
.object-picker__open:focus-visible {
    border-color: #9fbed3;
    background: var(--blue-050);
    color: var(--blue-700);
    box-shadow: none;
    transform: none;
}

.object-picker__open-icon,
.association-link-action .link-icon {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

/* The picker dialog reuses the shared modal, field, and action rhythm. */
.object-picker__dialog {
    width: min(672px, 92vw);
    max-width: 100%;
    max-height: min(78vh, 736px);
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 22px 64px rgba(15, 23, 42, .24);
    color: var(--text);
}

.object-picker__dialog::backdrop {
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
}

/* Keep actions visible while the result list scrolls within short viewports. */
.object-picker__dialog[open] {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.object-picker__dialog > header,
.object-picker__dialog > footer,
.object-picker__search {
    flex-shrink: 0;
}

.object-picker__dialog > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--interface-divider);
}

.object-picker__dialog > header h3 {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: var(--interface-heading-size);
    line-height: 1.25;
}

.object-picker__dialog > header p {
    margin: 0;
    color: var(--muted);
    font-size: var(--interface-helper-size);
    line-height: 1.5;
}

.object-picker__dialog > header button {
    min-height: 0;
    padding: 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.object-picker__dialog > header button:hover {
    background: transparent;
    color: var(--navy-900);
    box-shadow: none;
    transform: none;
}

.object-picker__dialog .object-picker__search {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 16px 20px 10px;
}

.object-picker__search span {
    font-size: var(--interface-label-size);
    font-weight: 750;
}

.object-picker__choices {
    display: grid;
    min-height: 0;
    max-height: 352px;
    gap: 7px;
    overflow: auto;
    padding: 4px 20px 16px;
}

.object-picker__choices > div[id] {
    display: grid;
    gap: 7px;
}

/* Choice rows keep their horizontal layout inside editors with vertical field labels. */
.object-picker__dialog .object-picker__choices label {
    display: flex;
    min-width: 0;
    min-height: 60px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin: 0;
    padding: 11px 12px;
    border: 1px solid var(--interface-border);
    border-radius: var(--interface-tile-radius);
    background: var(--surface);
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.object-picker__dialog .object-picker__choices label:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.object-picker__dialog .object-picker__choices label:has(input:checked) {
    border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.object-picker__dialog .object-picker__choices label:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Search and relation filtering also hide Django's checkbox row wrappers. */
.object-picker__dialog .object-picker__choices label[hidden],
.object-picker__choices > div[id] > div:has(> label[hidden]) {
    display: none;
}

/* Retain the central checkbox appearance without inheriting full-width text-field geometry. */
.object-picker__choices label > input[type="checkbox"] {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    min-height: 20px;
    margin: 0;
    padding: 0;
    border-width: 1.5px;
    border-radius: 5px;
    color: var(--surface);
}

.object-picker__choices label > input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--navy-900);
    box-shadow: none;
}

.object-picker__choices label span {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.object-picker__choices label strong {
    color: var(--navy-900);
    font-size: var(--interface-value-size);
}

.object-picker__choices label small {
    color: var(--muted);
    font-size: var(--interface-helper-size);
    line-height: 1.5;
}

/* Empty and truncated results use the shared quiet placeholder typography. */
.object-picker__no-results,
.object-picker__more {
    padding: 16px 20px;
    color: var(--interface-placeholder);
    font-size: var(--interface-value-size);
    font-style: italic;
    font-weight: 450;
    text-align: center;
}

/* Centre empty feedback between the search control and footer without leftover list spacing. */
.object-picker__dialog:has(.object-picker__no-results:not([hidden])) .object-picker__search {
    padding-bottom: 0;
}

.object-picker__choices:has(+ .object-picker__no-results:not([hidden])) {
    display: none;
}

.object-picker__no-results:not([hidden]) {
    display: flex;
    min-height: calc(2 * var(--interface-control-height));
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

.object-picker__dialog > footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--interface-divider);
}

@media (max-width: 672px) {
    .object-picker__dialog {
        width: 100%;
        max-width: 100%;
        max-height: 88vh;
        margin: auto 0 0;
        border-radius: 14px 14px 0 0;
    }

    .object-picker__choices {
        max-height: 48vh;
    }
}

/* Keep both actions within reach on narrow screens without horizontal scrolling. */
@media (max-width: 420px) {
    .object-picker__dialog > footer {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 12px 16px;
    }

    .object-picker__dialog > footer .button {
        min-width: 0;
        padding-right: 8px;
        padding-left: 8px;
        white-space: normal;
    }
}
