/**
 * Custom Select2 Styles - Fully Compatible with Your Theme
 * Version 1.2 - Complete solution for height and background issues
 */

/* ===== BASE STYLES ===== */
.select2-container {
    width: 100% !important;
    box-sizing: border-box;
    display: inline-block;
    margin: 0;
    position: relative;
    vertical-align: middle;
}

/* ===== SINGLE SELECT ===== */
.select2-container--default .select2-selection--single {
    background-color: var(--inputBackground, #f8f9fa) !important;
    border: 2px solid var(--inputBorder, #ced4da) !important;
    border-radius: var(--inputRadius, 0.25rem) !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 5px 30px 5px 12px !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Rendered selection text */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--bodyTextColor, #212529) !important;
    line-height: 28px !important;
    padding-left: 0 !important;
    width: 100%;
    text-align: left;
}

/* Placeholder styling */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--inputPlaceholder, #6c757d) !important;
    line-height: 28px !important;
    opacity: 1 !important;
}

/* Dropdown arrow */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
    width: 30px !important;
    right: 2px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Arrow icon */
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--bodyTextColor, #212529) transparent transparent transparent !important;
    border-width: 6px 6px 0 6px !important;
    border-style: solid !important;
    left: 50% !important;
    margin-left: -6px !important;
    margin-top: -3px !important;
    position: absolute;
    top: 50%;
}

/* ===== DROPDOWN STYLES ===== */
.select2-container--default .select2-dropdown {
    background-color: var(--inputBackground, #f8f9fa) !important;
    border: 2px solid var(--inputBorder, #ced4da) !important;
    border-radius: var(--inputRadius, 0.25rem) !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    z-index: 1060;
}

/* Dropdown options */
.select2-container--default .select2-results__option {
    color: var(--bodyTextColor, #212529) !important;
    padding: 8px 12px !important;
    transition: background-color 0.15s ease;
}

/* Highlighted option */
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--hoverBlack, rgba(0, 0, 0, 0.075)) !important;
    color: var(--bodyTextColor, #212529) !important;
}

/* Selected option in dropdown */
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--inputBackgroundDark, #e9ecef) !important;
}

/* Search field in dropdown */
.select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--inputBackground, #f8f9fa) !important;
    border: 2px solid var(--inputBorder, #ced4da) !important;
    border-radius: var(--inputRadius, 0.25rem) !important;
    color: var(--bodyTextColor, #212529) !important;
    padding: 6px 12px !important;
    margin: 4px !important;
    width: calc(100% - 8px) !important;
}

/* ===== MULTIPLE SELECT ===== */
.select2-container--default .select2-selection--multiple {
    background-color: var(--inputBackground, #f8f9fa) !important;
    border: 2px solid var(--inputBorder, #ced4da) !important;
    border-radius: var(--inputRadius, 0.25rem) !important;
    min-height: 40px !important;
    padding: 0 5px !important;
}

/* Selected choices in multiple select */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--inputBorder, #e9ecef) !important;
    border: 1px solid var(--inputBorder, #ced4da) !important;
    color: var(--bodyTextColor, #212529) !important;
    border-radius: 0.25rem !important;
    padding: 0 6px 0 20px !important;
    margin-top: 6px !important;
    margin-right: 5px !important;
    position: relative;
}

/* Remove button in multiple select */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--bodyTextColor, #212529) !important;
    position: absolute !important;
    left: 5px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin-right: 0 !important;
}

/* ===== STATES ===== */
/* Focus state */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primaryColor, #007bff) !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Disabled state */
.select2-container--default.select2-container--disabled .select2-selection--single,
.select2-container--default.select2-container--disabled .select2-selection--multiple {
    background-color: var(--inputBackgroundDark, #e9ecef) !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

/* Open state - arrow rotation */
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--bodyTextColor, #212529) transparent !important;
    border-width: 0 6px 6px 6px !important;
    margin-top: -3px !important;
}

/* Clear button */
.select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--bodyTextColor, #212529) !important;
    font-size: 1.2em !important;
    margin-right: 25px !important;
    float: right;
    display: none;
}

/* ===== VALIDATION STATES ===== */
.select2-container--default.is-valid .select2-selection--single,
.select2-container--default.is-valid .select2-selection--multiple {
    border-color: #28a745 !important;
}

.select2-container--default.is-invalid .select2-selection--single,
.select2-container--default.is-invalid .select2-selection--multiple {
    border-color: #dc3545 !important;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 767px) {
    .select2-container--default .select2-selection--single {
        height: 42px !important;
    }

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 10px !important;
    }
}

/* ===== HIDDEN NATIVE SELECT ===== */
.select2-hidden-accessible {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
}

/* ===== LOADING ANIMATION ===== */
.select2-container--default .select2-selection--single .select2-selection__arrow .select2-selection__loading {
    border: 2px solid var(--inputBorder, #ced4da);
    border-radius: 50%;
    border-top-color: transparent;
    animation: select2-spinner 1s linear infinite;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
}

@keyframes select2-spinner {
    to { transform: rotate(360deg); }
}

