/* ==========================================================================
   Premium Select2 Modern Alignment & UI Styling
   ========================================================================== */

/* Universal width constraint */
.select2-container {
    width: 100% !important;
    display: inline-block;
}

/* Mimic Bootstrap 4 form-control feel */
.select2-container .select2-selection--single {
    position: relative !important; /* CRITICAL: Set containing block for absolute children */
    height: 38px !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
    background-color: #fff !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    display: flex !important;
    align-items: center !important;
}

/* Elegant Focus state matching Bootstrap outline */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container.select2-container--focus .select2-selection--single,
.select2-container.select2-container--open .select2-selection--single {
    border-color: #80bdff !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* Main Text Selection Container alignment */
.select2-container .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #495057 !important;
    line-height: 36px !important; /* Perfect vertical centering inside 38px border */
    padding-left: 12px !important;
    padding-right: 60px !important; /* CRITICAL: Generous right padding ensures text truncates before buttons */
    text-align: left !important;
    width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Beautiful Clear Selection Icon ('x') absolute alignment to avoid overlap */
.select2-container .select2-selection--single .select2-selection__clear,
.select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    right: 36px !important; /* Perfectly offset to the left of the arrow with clear whitespace */
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    color: #95aac9 !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 3 !important;
    transition: all 0.2s ease-in-out !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
}

.select2-container .select2-selection--single .select2-selection__clear:hover,
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #e63757 !important; /* Warm premium red on hover */
    background-color: rgba(230, 55, 87, 0.1) !important; /* Soft circular background glow on hover */
    transform: translateY(-50%) scale(1.1) !important; /* Elegant modern micro-scale interaction */
}

/* Custom caret arrow dropdown button positioning */
.select2-container .select2-selection--single .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
    position: absolute !important;
    right: 12px !important; /* Perfectly proportioned on the far right */
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 14px !important;
    height: 14px !important;
    border: none !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 2 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Replace Select2 default chunky caret with a high-end chevron-caret */
.select2-container .select2-selection--single .select2-selection__arrow b,
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #95aac9 transparent transparent transparent !important;
    border-style: solid !important;
    border-width: 5px 4px 0 4px !important;
    height: 0 !important;
    left: 50% !important;
    margin-left: -4px !important;
    margin-top: -2px !important;
    position: absolute !important;
    top: 50% !important;
    width: 0 !important;
    transition: all 0.2s ease-in-out !important;
}

/* Open/Rotated state arrow */
.select2-container--open .select2-selection--single .select2-selection__arrow b,
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #12263f transparent !important;
    border-width: 0 4px 5px 4px !important;
}

/* Premium styled dropdown popup box */
.select2-dropdown {
    border: 1px solid #ced4da !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1) !important;
    z-index: 1060 !important; /* Sits perfectly above Bootstrap modals (z-index 1050) */
}

/* Search section inside dropdown */
.select2-container--default .select2-search--dropdown {
    padding: 8px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    padding: 6px 12px !important;
    outline: none !important;
    transition: border-color 0.15s ease-in-out !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #80bdff !important;
    box-shadow: 0 0 0 0.15rem rgba(0, 123, 255, 0.15) !important;
}

/* Options dropdown list items */
.select2-results__option {
    padding: 8px 12px !important;
    font-size: 14px !important;
}

/* Modern hover active highlight color */
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #007bff !important;
    color: #fff !important;
}

/* Modern selected option styling */
.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #f1f3f5 !important;
    color: #212529 !important;
    font-weight: 500 !important;
    background-image: none !important;
}

/* Disabled styling integration */
.select2-container--default.select2-container--disabled .select2-selection--single {
    background-color: #e9ecef !important;
    cursor: not-allowed !important;
    border-color: #dee2e6 !important;
}
