/**
 * Global Select2 Custom Styles
 * Bootstrap 5 Compatible
 */

/* ============================================
   General Select2 Styling
   ============================================ */

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

.select2-container--bootstrap-5 .select2-selection--single {
    height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.select2-container--bootstrap-5 .select2-selection--single:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ============================================
   Search Input Styling
   ============================================ */

.select2-container--bootstrap-5 .select2-search__field {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    height: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

.select2-container--bootstrap-5 .select2-search__field:focus {
    outline: none !important;
    border-color: #80bdff !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* ============================================
   Dropdown Container Styling
   ============================================ */

.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.select2-container--bootstrap-5 .select2-dropdown.select2-dropdown--below {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.select2-container--bootstrap-5 .select2-dropdown.select2-dropdown--above {
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* ============================================
   Options List Styling
   ============================================ */

.select2-container--bootstrap-5 .select2-results__option {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #212529;
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
    background-color: #e7f3ff;
    color: #007bff;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: #0d6efd;
    color: #fff;
}

.select2-container--bootstrap-5 .select2-results__option:hover {
    background-color: #f8f9fa;
}

/* ============================================
   Modal-Specific Styling
   ============================================ */

.modal .select2-container--open .select2-dropdown {
    z-index: 1051 !important;
}

.select2-in-modal .select2-search__field {
    width: 100%;
}

.select2-in-modal .select2-search__field:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ============================================
   Responsive Styling
   ============================================ */

@media (max-width: 576px) {
    .select2-container--bootstrap-5 .select2-selection--single {
        height: calc(1.5em + 0.5rem + 2px);
        padding: 0.25rem 0.5rem;
        font-size: 0.8125rem;
    }

    .select2-container--bootstrap-5 .select2-search__field {
        padding: 0.25rem 0.5rem;
        font-size: 0.8125rem;
    }

    .select2-container--bootstrap-5 .select2-results__option {
        padding: 0.375rem 0.5rem;
        font-size: 0.8125rem;
    }
}

/* ============================================
   Disabled State
   ============================================ */

.select2-container--bootstrap-5.select2-container--disabled .select2-selection {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 1;
}

.select2-container--bootstrap-5.select2-container--disabled .select2-selection,
.select2-container--bootstrap-5.select2-container--disabled .select2-search__field {
    cursor: not-allowed;
    color: #6c757d;
}

/* ============================================
   No Results Message
   ============================================ */

.select2-container--bootstrap-5 .select2-results__message {
    padding: 1rem 0.75rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.875rem;
}

/* ============================================
   Loading Message
   ============================================ */

.select2-container--bootstrap-5 .select2-results__option.loading-results {
    padding: 1rem 0.75rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.875rem;
}
