/* Shared Select2 appearance for forms, filters and dialogs. */
.select2-container.pakplan-select2-stable-width {
    /* A percentage inside an auto-sized label/table cell must not use the
       selected text as its intrinsic width. Keep the original field's size
       contribution while letting percentages and flex layouts stay responsive.
       Only the selection container is marked; detached dropdowns are untouched. */
    contain: inline-size;
    /* Bound the intrinsic contribution of auto table columns on narrow screens.
       Explicit field widths, percentages and flex sizing still take precedence. */
    contain-intrinsic-inline-size: min(var(--pakplan-select2-intrinsic-width, 240px), 240px, 50vw);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.select2-container.select2-container--default.pakplan-unified-select { flex: 1; min-width: 0; font: 14px/1.4 Arial, sans-serif; }
/* Apply theme colors immediately when Select2 replaces the native control. */
.pakplan-unified-select .select2-selection,
.pakplan-unified-select .select2-selection__rendered,
.pakplan-unified-select .select2-selection__choice {
    transition: border-color .2s ease, box-shadow .2s ease !important;
}
.select2-container.select2-container--default.pakplan-unified-select .select2-selection.select2-selection--single {
    position: relative; box-sizing: border-box; height: 42px !important;
    border: 1px solid var(--color-border-input, #cfd5dd) !important; border-radius: 10px !important;
    background: var(--color-bg-primary, #fff) !important; box-shadow: none;
}
.select2-container.select2-container--default.pakplan-unified-select .select2-selection--single .select2-selection__rendered {
    padding: 0 34px 0 12px; font-size: 16px !important; line-height: 40px !important;
    color: var(--color-text-primary, #202632) !important;
}
.select2-container.select2-container--default.pakplan-unified-select .select2-selection__placeholder { color: var(--color-text-secondary, #7b8491); }
.select2-container.select2-container--default.pakplan-unified-select .select2-selection__arrow { height: 40px !important; right: 7px; }
.select2-container.select2-container--default.pakplan-unified-select.select2-container--open .select2-selection--single,
.select2-container.select2-container--default.pakplan-unified-select.select2-container--focus .select2-selection.select2-selection--single {
    border-color: var(--color-accent-primary, #1671cb) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary, #1671cb) 12%, transparent);
}
.pakplan-unified-select .pakplan-select2-inline-search-active .select2-selection__rendered { visibility: hidden; }
.pakplan-unified-select .pakplan-select2-inline-search-active .select2-selection__arrow { opacity: 0; pointer-events: none; }
.pakplan-unified-select .pakplan-select2-inline-search {
    position: absolute !important; inset: 1px !important; z-index: 2; display: block;
    padding: 0 !important; border: 0 !important; border-radius: 9px; background: var(--color-bg-primary, #fff);
}
.select2-container.select2-container--default.pakplan-unified-select .pakplan-select2-inline-search .select2-search__field {
    box-sizing: border-box; width: 100% !important; height: 100% !important; min-height: 0 !important;
    margin: 0 !important; padding: 0 12px !important; border: 0 !important; border-radius: inherit;
    outline: 0 !important; box-shadow: none !important; background: transparent !important;
    color: var(--color-text-primary, #202632) !important; font: inherit; font-size: 16px !important;
}
.select2-container .pakplan-unified-select-dropdown.select2-dropdown {
    overflow: hidden !important; margin-top: 5px !important; max-height: none !important; border: 1px solid var(--color-border-input, #cfd5dd) !important;
    border-radius: 10px !important; background: var(--color-bg-primary, #fff);
    box-shadow: 0 10px 28px #15243b1a; font: 14px/1.4 Arial, sans-serif;
}
.pakplan-unified-select-dropdown .select2-search--dropdown { display: none !important; }
.pakplan-unified-select-dropdown .select2-results > .select2-results__options {
    max-height: 260px; overscroll-behavior: contain; scrollbar-width: thin;
    scrollbar-color: var(--color-border-input, #bfc8d4) transparent;
}
.pakplan-unified-select-dropdown .select2-results__option {
    min-height: 38px; box-sizing: border-box; padding: 9px 12px;
    color: var(--color-text-primary, #202632); white-space: normal; overflow-wrap: anywhere;
}
.pakplan-unified-select-dropdown .select2-results__option[aria-selected="true"] { background: var(--color-bg-secondary, #f1f5f9); }
.pakplan-unified-select-dropdown .select2-results__option--highlighted[aria-selected] {
    background: var(--color-accent-primary, #1671cb) !important; color: #fff !important;
}
.pakplan-unified-select-dropdown .select2-results__option[aria-disabled="true"] { color: var(--color-text-secondary, #7b8491); }
.select2-container.select2-container--default.pakplan-unified-select.select2-container--disabled .select2-selection.select2-selection--single { opacity: .55; }

.select2-container.select2-container--default.pakplan-unified-select .select2-selection.select2-selection--multiple {
    box-sizing: border-box; min-height: 42px !important; padding: 3px 6px;
    border: 1px solid var(--color-border-input, #cfd5dd) !important; border-radius: 10px !important;
    background: var(--color-bg-primary, #fff) !important;
    color: var(--color-text-primary, #202632);
}
.select2-container.select2-container--default.pakplan-unified-select .select2-selection--multiple .select2-search__field {
    min-width: 2ch; font: inherit; font-size: 16px !important; color: var(--color-text-primary, #202632);
    background: transparent !important; border: 0 !important; box-shadow: none !important;
}
.select2-container.select2-container--default.pakplan-unified-select.pakplan-select2-no-search .select2-search__field { cursor: pointer; caret-color: transparent; }
/* Keep the keyboard target, without an empty search row below selected values. */
.select2-container.pakplan-unified-select.pakplan-select2-no-search.pakplan-select2-has-values .select2-search--inline {
    position: absolute !important; width: 1px !important; height: 1px !important;
    min-width: 0 !important; overflow: hidden !important; clip-path: inset(50%);
    padding: 0 !important; margin: 0 !important;
}
.select2-container.select2-container--default.pakplan-unified-select .select2-selection__choice {
    box-sizing: border-box; max-width: 100%; white-space: normal; overflow-wrap: anywhere;
    border: 1px solid var(--color-border-input, #cfd5dd); border-radius: 6px;
    background: var(--color-bg-secondary, #f1f5f9); color: var(--color-text-primary, #202632);
}
.select2-container.select2-container--default.pakplan-unified-select.select2-container--open .select2-selection.select2-selection--multiple {
    border-color: var(--color-accent-primary, #1671cb) !important;
}

/* Business directions use the same inset, type size and arrow as single selects. */
.direction-select + .select2-container.pakplan-unified-select .select2-selection--multiple {
    position: relative; padding: 0 34px 0 12px !important; font-size: 16px;
}
.direction-select + .select2-container.pakplan-unified-select .select2-selection--multiple::after {
    content: ''; position: absolute; right: 13px; top: 19px;
    width: 0; height: 0; border: solid transparent; border-width: 4px 4px 0;
    border-top-color: #888; pointer-events: none;
}
.direction-select + .select2-container--open.pakplan-unified-select .select2-selection--multiple::after {
    border-width: 0 4px 4px; border-top-color: transparent; border-bottom-color: #888;
}
.direction-select + .select2-container.pakplan-unified-select .select2-selection--multiple .select2-selection__rendered {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    min-height: 40px; padding: 0; margin: 0; font-size: 16px;
}
.direction-select + .select2-container.pakplan-unified-select .select2-selection__choice {
    float: none; margin: 0; padding: 0; border: 0; border-radius: 0;
    background: transparent; line-height: 40px; max-width: 100%;
    white-space: normal; overflow-wrap: anywhere;
}
.direction-select + .select2-container.pakplan-unified-select .select2-selection__choice + .select2-selection__choice::before {
    content: ', ';
}
.direction-select + .select2-container.pakplan-unified-select:not(.select2-container--open) .select2-selection__rendered {
    display: block; height: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.direction-select + .select2-container.pakplan-unified-select:not(.select2-container--open) .select2-selection__choice {
    display: inline; white-space: nowrap;
}
.direction-select + .select2-container.pakplan-unified-select .select2-search--inline {
    float: none; max-width: 100%;
}
.direction-select + .select2-container.pakplan-unified-select .select2-search__field {
    max-width: 100%; height: 40px; margin: 0; padding: 0; line-height: 40px;
}
.direction-select + .select2-container.pakplan-unified-select .select2-search__field::placeholder {
    color: var(--color-text-primary, #202632); opacity: 1;
}
.direction-select + .select2-container--focus.pakplan-unified-select .select2-selection--multiple {
    border-color: var(--color-accent-primary, #1671cb) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent-primary, #1671cb) 12%, transparent);
}

/* The shared picker owns placement; old page offsets must not cover the field. */
.select2-container .pakplan-unified-select-dropdown.select2-dropdown--above {
    margin-top: -5px !important;
}
.pakplan-unified-select-dropdown .select2-results {
    max-height: none !important; overflow: visible !important;
}
/* Also cover caller-supplied selection adapters; modal close buttons are untouched. */
.select2-container .select2-selection__clear,
.select2-container .select2-selection__choice__remove {
    display: none !important;
}

/* Match the finished control even while HTML is streaming, or if JS fails.
   Never hide the form or disable the native fallback while waiting for Select2. */
[data-select2-form] select.js-select2:not([multiple]):not(.select2-hidden-accessible) {
    display: block; box-sizing: border-box; width: 100% !important; min-width: 0;
    height: 42px !important; margin: 0; padding: 0 34px 0 12px !important;
    border: 1px solid var(--color-border-input, #cfd5dd) !important; border-radius: 10px !important;
    background-color: var(--color-bg-primary, #fff) !important;
    color: var(--color-text-primary, #202632) !important; font: 16px/40px Arial, sans-serif;
    appearance: none; -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--color-accent-primary, #1671cb) 50%),
        linear-gradient(135deg, var(--color-accent-primary, #1671cb) 50%, transparent 50%);
    background-position: calc(100% - 22px) center, calc(100% - 16px) center;
    background-size: 6px 6px; background-repeat: no-repeat;
}
