/**
 * Select2 Registration Page Styling
 * Matches the form-floating input styles
 */

/* Override Select2 Bootstrap 5 Theme */
.form-floating > .select2-container--bootstrap-5 {
    width: 100% !important;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection {
    min-height: calc(3.5rem + 2px);
    padding: 1.625rem 0.75rem 0.625rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection--single {
    height: calc(3.5rem + 2px);
    display: flex;
    align-items: center;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection__rendered {
    padding: 0;
    color: #495057;
    line-height: 1.5;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection__arrow {
    height: calc(3.5rem + 2px);
    right: 0.75rem;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection__arrow b {
    border-color: #495057 transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
}

/* Focus State */
.form-floating > .select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Dropdown Menu */
.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background-color: #fff;
}

.select2-container--bootstrap-5 .select2-dropdown--above {
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.select2-container--bootstrap-5 .select2-dropdown--below {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Search Input */
.select2-container--bootstrap-5 .select2-search--dropdown {
    padding: 0.5rem;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    color: #495057;
    background-color: #fff;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field::placeholder {
    color: #939ba2;
}

/* Options */
.select2-container--bootstrap-5 .select2-results__option {
    padding: 0.5rem 0.75rem;
    color: #495057;
    cursor: pointer;
    font-size: 1rem;
}

.select2-container--bootstrap-5 .select2-results__option:hover {
    background-color: #f8f9fa;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: #914d2e;
    color: #fff;
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
    background-color: #e9ecef;
    color: #495057;
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected=true].select2-results__option--highlighted {
    background-color: #914d2e;
    color: #fff;
}

/* No Results */
.select2-container--bootstrap-5 .select2-results__message {
    color: #6c757d;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
}

/* Disabled State */
.select2-container--bootstrap-5.select2-container--disabled .select2-selection {
    background-color: #e9ecef;
    opacity: 1;
    color: #6c757d;
}

.select2-container--bootstrap-5.select2-container--disabled .select2-selection__rendered {
    color: #6c757d;
}

/* Label Positioning */
.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    padding: 1rem 0.75rem;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
    color: #6c757d;
    font-size: 1rem;
}

/* When Select2 has focus or value */
.form-floating > .select2-container--bootstrap-5.select2-container--open ~ label,
.form-floating > .select2-container--bootstrap-5.select2-container--focus ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* When Select2 has a selected value */
.form-floating > .select2-container--bootstrap-5 .select2-selection__rendered:not(:empty) ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Multiple Select */
.form-floating > .select2-container--bootstrap-5 .select2-selection--multiple {
    min-height: calc(3.5rem + 2px);
    padding: 1.625rem 0.75rem 0.625rem 0.75rem;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: #914d2e;
    border: 1px solid #6d3a1f;
    border-radius: 0.25rem;
    color: #fff;
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.form-floating > .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    color: #fff;
    cursor: pointer;
    display: inline-block;
    font-weight: bold;
    margin-right: 0.25rem;
}

/* Clear Button */
.select2-container--bootstrap-5 .select2-selection__clear {
    color: #6c757d;
    cursor: pointer;
    float: right;
    font-weight: bold;
    margin-right: 0.5rem;
}

.select2-container--bootstrap-5 .select2-selection__clear:hover {
    color: #495057;
}

/* Mobile Responsive */
@media (max-width: 576px) {
    .form-floating > .select2-container--bootstrap-5 .select2-selection {
        min-height: calc(2.5rem + 2px);
        padding: 1.125rem 0.5rem 0.375rem 0.5rem;
        font-size: 0.875rem;
    }

    .form-floating > .select2-container--bootstrap-5 .select2-selection--single {
        height: calc(2.5rem + 2px);
    }

    .form-floating > .select2-container--bootstrap-5 .select2-selection__arrow {
        height: calc(2.5rem + 2px);
        right: 0.5rem;
    }

    .form-floating > label {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    .select2-container--bootstrap-5 .select2-results__option {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }

    .select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
}

/* Error State */
.form-floating > .select2-container--bootstrap-5 .select2-selection.is-invalid {
    border-color: #dc3545;
}

.form-floating > .select2-container--bootstrap-5.select2-container--focus .select2-selection.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Success State */
.form-floating > .select2-container--bootstrap-5 .select2-selection.is-valid {
    border-color: #28a745;
}

.form-floating > .select2-container--bootstrap-5.select2-container--focus .select2-selection.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Animation */
.select2-container--bootstrap-5 .select2-dropdown,
.select2-container--bootstrap-5 .select2-selection {
    transition: all 0.15s ease-in-out;
}

/* Ensure proper z-index for dropdown */
.select2-container--bootstrap-5 .select2-dropdown {
    z-index: 1050;
}
