/* Custom Select2 Styles for Bootstrap Theme */

/* Main container */
.select2-container .select2-selection {
    border: 1px solid #d9dee3;
    border-radius: 0.375rem;
    min-height: 38px;
    font-size: 0.9375rem;
}

.select2-container .select2-selection--single {
    height: 38px;
    line-height: 36px;
    padding-left: 12px;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    color: #697a8d;
    padding-right: 20px;
}

.select2-container .select2-selection--single .select2-selection__placeholder {
    color: #626262;
}

/* Focus state */
.select2-container.select2-container--focus .select2-selection {
    border-color: #696cff;
    box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.25);
}

/* Dropdown with high z-index */
.select2-container .select2-dropdown {
    border: 1px solid #d9dee3;
    border-radius: 0.375rem;
    box-shadow: 0 0.25rem 1rem rgba(161, 172, 184, 0.45);
    z-index: 9999;
}

/* Open container z-index fix */
.select2-container.select2-container--open {
    z-index: 9999;
}

.select2-container .select2-search--dropdown .select2-search__field {
    border: 1px solid #d9dee3;
    border-radius: 0.375rem;
    padding: 8px 12px;
    margin: 8px;
    width: calc(100% - 16px);
}

.select2-container .select2-results__option {
    padding: 8px 12px;
    font-size: 0.9375rem;
}

.select2-container .select2-results__option--highlighted {
    background-color: #696cff;
    color: white;
}

.select2-container .select2-results__option--selected {
    background-color: #f8f9fa;
    color: #697a8d;
}

/* Clear button - Redesigned */
.select2-container .select2-selection__clear {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: #626262 !important;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
    z-index: 10;
}

.select2-container .select2-selection__clear:hover {
    transform: translateY(-50%) scale(1.1);
}

.select2-container .select2-selection__clear:active {
    transform: translateY(-50%) scale(1.1);
}

/* For multiple select clear buttons */
.select2-container .select2-selection--multiple .select2-selection__choice__remove {
    background: #8592a3;
    border-radius: 50%;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    margin-left: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select2-container .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: #ff3e1d;
    transform: scale(1.1);
    box-shadow: 0 1px 3px rgba(255, 62, 29, 0.3);
}

/* Invalid state */
.is-invalid + .select2-container .select2-selection {
    border-color: #ff3e1d;
}

.is-invalid + .select2-container.select2-container--focus .select2-selection {
    border-color: #ff3e1d;
    box-shadow: 0 0 0 0.2rem rgba(255, 62, 29, 0.25);
}

/* Multi-select */
.select2-container .select2-selection--multiple {
    min-height: 38px;
    padding: 4px 8px;
}

.select2-container .select2-selection--multiple .select2-selection__choice {
    background-color: #696cff;
    border: 1px solid #696cff;
    border-radius: 0.25rem;
    color: white;
    padding: 2px 8px;
    margin: 2px;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .select2-container .select2-dropdown {
        width: 100% !important;
    }
}

/* Form floating labels compatibility */
.form-floating .select2-container .select2-selection {
    height: calc(3.5rem + 2px);
    padding-top: 1.625rem;
    padding-bottom: 0.625rem;
}

.form-floating .select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 1.25;
}

.form-floating > .select2-container .select2-selection {
    padding-left: 0.75rem;
}

/* Loading state */
.select2-container .select2-selection--single .select2-selection__arrow {
    height: 36px;
    right: 10px;
}

.select2-container[dir="rtl"] .select2-selection--single .select2-selection__arrow {
    left: 10px;
    right: auto;
}

/* Additional custom styles */
.select2-container .select2-selection--single .select2-selection__rendered {
    padding-left: 0;
    padding-right: 20px;
}

/* Enhanced dropdown styling */
.select2-container .select2-dropdown {
    border-top: none;
}

.select2-container.select2-container--open .select2-dropdown--below {
    border-top: 1px solid #d9dee3;
}

.select2-container.select2-container--open .select2-dropdown--above {
    border-bottom: 1px solid #d9dee3;
}
