.select2-container {
    width: 100% !important;
}

.select2-container .select2-selection--single {
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color-translucent);
    height: 38px;
}

.select2-container .select2-selection--single:focus {
    outline: 0;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 0.75rem;
    color: var(--bs-secondary-color);
}

.select2-container .select2-selection--single .select2-selection__arrow {
    height: 34px;
    width: 34px;
    right: 3px;
}

.select2-container .select2-selection--single .select2-selection__arrow b {
    border-color: var(--bs-gray-500) transparent transparent transparent;
    border-width: 6px 6px 0 6px;
}

.select2-container .select2-selection--single .select2-selection__placeholder {
    color: var(--bs-body-color);
}

[dir=rtl] .select2-selection__rendered {
    text-align: end;
}

.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--bs-gray-500) transparent !important;
    border-width: 0 6px 6px 6px !important;
}

.select2-container--default .select2-search--dropdown {
    padding: 10px;
    background-color: var(--bs-secondary-bg);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--bs-border-color-translucent);
    background-color: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    outline: 0;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #556ee6;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--bs-light);
    color: var(--bs-emphasis-color);
}

.select2-container--default .select2-results__option[aria-selected=true]:hover {
    background-color: #556ee6;
    color: #fff;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: var(--bs-light);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover,
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:focus {
    background-color: var(--bs-danger);
}
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
    border-radius: 0;
    border: none;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    border-right: none;
    color: var(--bs-emphasis-color);
}

.select2-results__option {
    padding: 6px 12px;
}

.select2-container[dir=rtl] .select2-selection--single .select2-selection__rendered {
    padding-left: 0.75rem;
}

.select2-dropdown {
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-secondary-bg);
}

.select2-search input {
    border: 1px solid var(--bs-border-color);
}

.select2-container .select2-selection--multiple {
    min-height: 38px;
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color-translucent) !important;
    padding: 2px 0.75rem;
}

.select2-container .select2-selection--multiple .select2-selection__rendered {
    padding: 2px 0.75rem;
}

.select2-container .select2-selection--multiple .select2-search__field {
    border: 0;
    color: var(--bs-emphasis-color);
}

.select2-container .select2-selection--multiple .select2-search__field::placeholder {
    color: var(--bs-secondary-color);
}

.select2-container .select2-selection--multiple .select2-selection__choice {
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    padding: 0 10px 0 25px;
}

.select2-container .select2-selection--multiple .select2-selection__rendered {
    padding: 0;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--bs-border-color-translucent);
}

.select2-container--default .select2-results__group {
    font-weight: 600;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    padding-left: 16px;
}


.select2-selection__clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 4px;
    color: var(--bs-secondary-color);
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    border-radius: 0;
    padding: 0;
    position: relative;
}

.select2-selection__clear::before {
    content: '↺';
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

.select2-selection__clear span {
    display: none;
}

.select2-selection__clear:hover {
    color: var(--bs-danger);
    background-color: var(--bs-danger-bg-subtle);
    border-color: var(--bs-danger-border-subtle);
}

.select2-selection__clear span {
    display: block;
    line-height: 1;
    margin-top: -1px;
}

/* تنسيق إضافي عند استخدام multiple selection */
.select2-selection--multiple .select2-selection__clear {
    position: absolute;
    right: 5px;
    top: 13px;
    transform: translateY(-50%);
    z-index: 1;
}

.select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 30px; /* مكان الزر بجانب السهم */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

/* تحسين التوافق مع RTL */
[dir="rtl"] .select2-selection--multiple .select2-selection__clear {
    right: auto;
    left: 5px;
}

[dir="rtl"] .select2-selection--single .select2-selection__clear {
    right: auto;
    left: 30px;
}
[dir="rtl"] .select2-selection__rendered {
    text-align: right !important;
}

.select2-container--disabled .select2-selection__clear {
    display: none;
}

.select2-container--focus .select2-selection__clear {
    opacity: 0.9;
}

.select2-selection__clear:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 1px;
}



/* Select2 Dropdown فوق الجميع */
.select2-container--open .select2-dropdown {
    z-index: 999999 !important;
}

/* لو داخل Modal Bootstrap */
.modal .select2-container--open .select2-dropdown {
    z-index: 999999 !important;
}
