/**
 * Levridge Equity - Select2 Custom Styling
 * Provides consistent styling for all Select2 dropdowns across the application
 * 
 * Color Scheme (consistent with theme.min.css):
 * - Active text: #18113c (--bs-dark, matches form-control)
 * - Placeholder: #a8a3b9 (matches theme placeholder color) 
 * - Secondary text: #79758f (--bs-secondary)
 * - Disabled text: #79758f with opacity
 * - Backgrounds: #fff (normal), #f5f4f8 (disabled/hover)
 * - Focus state: #2f5265 border with rgba(47,82,101,.25) shadow
 * 
 * Fixes ADO #16427 - Font consistency between text inputs and Select2 dropdowns
 */

/* Select2 container styling to match theme form-select */
.select2-container--default .select2-selection--single {
    height: calc(1.6em + 1.5rem + 2px);
    padding: .75rem 3.75rem .75rem 1.25rem;
    font-size: .875rem;
    font-weight: 400;
    line-height: 1.6;
    color: #18113c;
    background-color: #fff;
    border: 1px solid #e8e7ed;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: calc(1.6em + 1.5rem + 2px);
        position: absolute;
        top: 0;
        right: 1.25rem;
        width: 1.5rem;
    }

        /* Hide default Select2 arrow and replace with theme arrow */
        .select2-container--default .select2-selection--single .select2-selection__arrow b {
            display: none;
        }

.select2-container--default .select2-selection--single {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2379758f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 1.25rem center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
}

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 1.6;
        padding-left: 0;
        color: #18113c;
    }

/* Complete reset of Select2 dropdown styling */
.select2-results__option {
    background-color: white !important;
    color: #18113c !important;
    padding: 8px 12px;
}

    .select2-results__option:hover,
    .select2-results__option:focus,
    .select2-results__option:active,
    .select2-results__option.select2-results__option--highlighted {
        background-color: #f5f4f8 !important;
        color: #18113c !important;
    }

/* Reset all Select2 highlighted options */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected],
.select2-container--default .select2-results__option[aria-selected=true],
.select2-container--default .select2-results__option[data-selected=true] {
    background-color: #f5f4f8 !important;
    color: #18113c !important;
}

/* Dropdown styling */
.select2-dropdown {
    border: 1px solid #e8e7ed;
    border-radius: .25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.select2-search--dropdown {
    padding: 0.5rem;
}

    .select2-search--dropdown .select2-search__field {
        border: 1px solid #e8e7ed;
        border-radius: .25rem;
        padding: .75rem 1.25rem;
        font-size: .875rem;
        color: #18113c;
    }

        .select2-search--dropdown .select2-search__field::-webkit-input-placeholder {
            color: #a8a3b9;
        }

        .select2-search--dropdown .select2-search__field::-moz-placeholder {
            color: #a8a3b9;
            opacity: 1;
        }

        .select2-search--dropdown .select2-search__field::placeholder {
            color: #a8a3b9;
            opacity: 1;
        }

/* Loading indicator */
.select2-results__message {
    color: #79758f;
    padding: 8px 12px;
}

/* Member result styling */
.select2-result-member__name {
    font-weight: 500;
    color: #18113c;
}

.select2-result-member__account {
    color: #79758f;
    font-size: 0.875rem;
}

/* Focus state */
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #2f5265;
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(47,82,101,.25);
}

/* Placeholder */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #a8a3b9;
}

/* Clear button - styled to match theme arrow */
.select2-container--default .select2-selection--single .select2-selection__clear {
    cursor: pointer;
    position: absolute;
    right: 2.75rem; /* Position to the left of the dropdown arrow */
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2379758f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 4L4 12M4 4l8 8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px 12px;
    font-size: 0; /* Hide any text content */
    line-height: 0;
    margin: 0;
    padding: 0;
}

    .select2-container--default .select2-selection--single .select2-selection__clear:hover {
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23a8a3b9' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 4L4 12M4 4l8 8'/%3E%3C/svg%3E");
    }

/* Disabled state with improved accessibility */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #f5f4f8;
    cursor: default;
    opacity: 0.65;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2379758f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
}

    .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__rendered {
        color: #79758f;
    }

    /* Disabled placeholder text */
    .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__placeholder {
        color: #a8a3b9;
        opacity: 0.75;
    }

/* Validation states to match theme */
/* Valid state */
.select2-container--default.is-valid .select2-selection--single,
.was-validated .select2-container--default:valid .select2-selection--single {
    border-color: #19cb98;
}

.select2-container--default.is-valid.select2-container--focus .select2-selection--single,
.was-validated .select2-container--default:valid.select2-container--focus .select2-selection--single {
    border-color: #19cb98;
    box-shadow: 0 0 0 .25rem rgba(25,203,152,.25);
}

/* Invalid state */
.select2-container--default.is-invalid .select2-selection--single,
.was-validated .select2-container--default:invalid .select2-selection--single {
    border-color: #e53f3c;
}

.select2-container--default.is-invalid.select2-container--focus .select2-selection--single,
.was-validated .select2-container--default:invalid.select2-container--focus .select2-selection--single {
    border-color: #e53f3c;
    box-shadow: 0 0 0 .25rem rgba(229,63,60,.25);
}

/* Input group compatibility */
.input-group .select2-container--default .select2-selection--single {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group .select2-container--default.select2-container--focus .select2-selection--single {
    z-index: 3;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 15px !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .select2-container--default .select2-selection--single {
        transition: none;
    }
}
