/*
 * Select2 4.1 multi-select presentation.
 * Keep these rules scoped to multiple selections and their tagged dropdowns so
 * the application's existing single-select controls retain their current look.
 */

.select2-container--default .select2-selection--multiple {
    display: flex;
    min-height: 48px;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid #D6DCE5;
    border-radius: var(--input-border-radius, 8px);
    background: #FFFFFF;
    color: var(--primary-color, #354359);
    cursor: text;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: rgba(var(--primary-btn-color, 51, 113, 242), 0.75);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(var(--primary-btn-color, 51, 113, 242), 0.12);
}

.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple,
.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
    border-radius: var(--input-border-radius, 8px);
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: contents;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: normal;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex;
    min-width: 0;
    max-width: min(100%, 320px);
    min-height: 38px;
    flex: 0 1 auto;
    align-items: stretch;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #DCE3EC;
    border-radius: 8px;
    background: #F4F6F9;
    color: var(--primary-color, #354359);
    cursor: default;
    float: none;
}

/* Select2 4.0's RTL theme adds an auto margin that spreads every chip apart. */
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
    margin: 0;
    float: none;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: flex-start;
    padding: 5px 9px;
    overflow: hidden;
    text-align: start;
}

.select2-multi-value {
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 1px;
    text-align: start;
}

.select2-multi-value__primary,
.select2-multi-value__secondary {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select2-multi-value__primary {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.select2-multi-value__secondary {
    color: #667085;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.3;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    display: inline-flex;
    width: 28px;
    min-width: 28px;
    align-items: center;
    justify-content: center;
    order: 2;
    margin: 0;
    padding: 0;
    border: 0;
    border-inline-start: 1px solid #DCE3EC;
    border-inline-end: 0;
    border-radius: 0;
    background: transparent;
    color: #7B8798;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: color 140ms ease, background-color 140ms ease;
}

.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
    margin: 0;
    border-inline-start: 1px solid #DCE3EC;
    border-inline-end: 0;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:focus-visible {
    border: 0;
    border-inline-start: 1px solid #F1C7CC;
    border-inline-end: 0;
    background: #FDECEE;
    color: var(--danger-color, #DC3545);
    outline: 0;
}

.select2-container--default .select2-selection--multiple .select2-search--inline {
    display: flex;
    min-width: 130px;
    min-height: 34px;
    flex: 1 1 160px;
    align-items: center;
    margin: 0;
    float: none;
}

/* Once values exist, keep the search compact so chips can pack naturally. */
.select2-container--default .select2-selection--multiple:has(.select2-selection__choice) .select2-search--inline {
    min-width: 96px;
    flex: 0 1 140px;
}

.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    width: 100% !important;
    height: 32px;
    min-height: 32px;
    margin: 0;
    padding: 5px 3px;
    overflow: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--primary-color, #354359);
    font: inherit;
    line-height: 22px;
    outline: 0;
    resize: none;
}

.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field::placeholder {
    color: #98A2B3 !important;
    opacity: 1;
}

.select2-container--default.select2-container--disabled .select2-selection--multiple {
    border-color: #E3E8EF;
    background: #F5F6F8;
    box-shadow: none;
    cursor: not-allowed;
}

/* The dropdown gets this class only when its source select allows multiple values. */
.select2-multiple-dropdown {
    overflow: hidden;
    border: 1px solid #D6DCE5;
    border-radius: 8px;
    background: #FFFFFF;
    box-shadow: 0 12px 28px rgba(27, 38, 56, 0.14);
}

.select2-multiple-dropdown .select2-results__options {
    max-height: 300px !important;
    white-space: normal !important;
}

.select2-multiple-dropdown .select2-results__option--selectable {
    position: relative;
    padding: 9px 36px 9px 12px;
    border-bottom: 1px solid #EEF1F5;
    background: #FFFFFF;
    color: var(--primary-color, #354359);
    font-size: 12px;
    line-height: 1.45;
    cursor: pointer;
}

[dir="ltr"] .select2-multiple-dropdown .select2-results__option--selectable {
    padding-right: 12px;
    padding-left: 36px;
}

.select2-multiple-dropdown .select2-results__option--selectable:last-child {
    border-bottom: 0;
}

.select2-multiple-dropdown .select2-results__option--selected {
    background: #EEF8F0 !important;
    color: var(--primary-color, #354359) !important;
}

.select2-multiple-dropdown .select2-results__option--selected::before {
    position: absolute;
    top: 50%;
    right: 13px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--success-color, #4FA55C);
    color: #FFFFFF;
    content: "✓";
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    transform: translateY(-50%);
}

[dir="ltr"] .select2-multiple-dropdown .select2-results__option--selected::before {
    right: auto;
    left: 13px;
}

.select2-multiple-dropdown .select2-results__option--highlighted:not(.select2-results__option--selected) {
    background: rgba(var(--primary-btn-color, 51, 113, 242), 0.09) !important;
    color: var(--primary-color, #354359) !important;
}

.select2-multiple-dropdown .select2-results__option--selected.select2-results__option--highlighted {
    background: #E1F2E5 !important;
    color: var(--primary-color, #354359) !important;
}

@media (max-width: 575.98px) {
    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        max-width: 100%;
        flex-basis: 100%;
    }
}
