/* Select2 container for Bootstrap 5 */
.select2-container {
    display: inline-block;
    width: 100% !important;
    box-sizing: border-box;
    position: relative;
}

/* Single selection */
.select2-container .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    user-select: none;
    -webkit-user-select: none;
    border-radius: .375rem; /* Bootstrap 5 border-radius */
    border: 1px solid lightgrey; /* Updated border to match Bootstrap's input styling */
}

/* The rendered selected text */
.select2-container .select2-selection--single .select2-selection__rendered {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem; /* Adjusted font size to match Bootstrap input fields */
}

/* Clear button */
.select2-container .select2-selection--single .select2-selection__clear {
    background-color: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
}

/* RTL support */
.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
    padding-left: 8px;
    padding-right: 20px;
}

/* Multiple selections */
.select2-container .select2-selection--multiple {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    min-height: 32px;
    border: 1px solid lightgrey; /* Adjusted border to match Bootstrap's input styling */
    border-radius: .375rem; /* Bootstrap 5 border-radius */
    padding: 4px;
}

/* Search field inside dropdown */
.select2-container .select2-search--inline .select2-search__field {
    box-sizing: border-box;
    border: 1px solid lightgrey;
    padding: 6px;
    margin: 4px 0;
    font-size: 1rem;
}

/* Dropdown styles */
.select2-dropdown {
    background-color: white;
    border: 1px solid #aaa;
    border-radius: .375rem;
    display: block;
    position: absolute;
    left: -10000px;
    width: 100%;
    z-index: 9999;
}

/* Results options */
.select2-results__options {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

/* Each option */
.select2-results__option {
    padding: 8px 12px;
    cursor: pointer;
}

.select2-results__option--selectable {
    cursor: pointer;
}

.select2-results__option--selected {
    background-color: #ddd;
}

/* Highlighted options */
.select2-results__option--highlighted.select2-results__option--selectable {
    background-color: #0d6efd;
    color: white;
}

/* Search dropdown */
.select2-search--dropdown .select2-search__field {
    padding: 6px;
    width: 100%;
}

/* Custom border colors on select2 open */
.select2-container--open .select2-dropdown {
    border-color: #0d6efd; /* Bootstrap primary color */
}

/* Close mask (overlay outside dropdown) */
.select2-close-mask {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    opacity: 0;
    z-index: 9998;
}

/* Disabled state for select2 */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #f8f9fa; /* Bootstrap 5 disabled input color */
    cursor: not-allowed;
}

.select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: #f8f9fa; /* Bootstrap 5 disabled input color */
    cursor: not-allowed;
}

/* Selection multiple clear button */
.select2-container--default .select2-selection--multiple .select2-selection__clear {
    font-size: 1rem;
    cursor: pointer;
    float: right;
    font-weight: bold;
}

/* Remove choice from multiple selections */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    background-color: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 5px;
    margin-left: 5px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #333;
    background-color: #f1f1f1;
}

/* Grouped results (optional) */
.select2-container--default .select2-results__group {
    cursor: default;
    display: block;
    padding: 6px 12px;
    background-color: #f8f9fa;
}

/* Scrollbar styles */
.select2-container--default .select2-results__options {
    max-height: 200px;
    overflow-y: auto;
}
