/* ========================================
   Select2 Base Styles
   Theme-agnostic styling for Select2 to match Bootstrap 5
   ======================================== */

/* ========================================
   BASE HEIGHT AND SIZING
   Match Bootstrap .form-control / .form-select
   ======================================== */

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    font-size: 1.1rem !important;
    padding: .775rem 1rem !important;
    border-radius: 0.475rem !important;
    min-height: calc(1.5em + 1.55rem + 2px) !important;
    line-height: 1.5 !important;
}

/* Single select - ensure proper height */
.select2-container--default .select2-selection--single {
    height: calc(1.5em + 1.55rem + 2px) !important;
}

/* Rendered text alignment */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(1.5em + 1.55rem) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ========================================
   FIELD-LEVEL CLEAR BUTTON
   Ensures "clear all" button is visible and properly positioned
   ======================================== */

/* Multiple selection needs extra padding for clear button */
.select2-container--default .select2-selection--multiple.select2-selection--clearable,
.select2-container--default .select2-selection--multiple {
    padding-right: 60px !important;
}

/* Position field-level clear button */
.select2-container--default .select2-selection--multiple .select2-selection__clear {
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1000 !important;
    width: 24px !important;
    height: 24px !important;
    margin: 0 !important;
    pointer-events: all !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Ensure tags wrap properly and don't extend into clear button area */
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    padding-right: 55px !important;
    display: flex !important;
    flex-wrap: wrap !important;
}

/* Ensure inline search field doesn't push into clear button */
.select2-container--default .select2-selection--multiple .select2-search--inline {
    max-width: calc(100% - 60px) !important;
}

.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    max-width: 100% !important;
}

/* ========================================
   TAG CHIPS AND REMOVE BUTTONS
   Prevents X buttons from overlapping tag text
   ======================================== */

/* Tag chip spacing */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    padding-left: 30px !important;
    padding-right: 8px !important;
    margin-right: 5px !important;
    margin-bottom: 5px !important;
}

/* Tag X buttons - explicit sizing and positioning */
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 24px !important;
    height: 100% !important;
    padding: 0 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border-right: 1px solid !important;
    border-right-color: #aaa !important;  /* Light mode default */
}

/* Tag text display - ensure proper spacing from button */
.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    padding-left: 6px !important;
    padding-right: 6px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* ========================================
   DROPDOWN ARROW AND SEARCH FIELD
   ======================================== */

/* Remove Bootstrap .form-select background chevron */
.select2-container--default .select2-selection--multiple {
    background-image: none !important;
}

/* Hide dropdown arrow element on multiple selects */
.select2-container--default .select2-selection--multiple .select2-selection__arrow {
    display: none !important;
}

/* Hide inline search cursor but keep typing functional */
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
    caret-color: transparent !important;
}

/* Dropdown search styling */
.select2-search--dropdown {
    display: block !important;
    padding: 8px !important;
}

.select2-search--dropdown .select2-search__field {
    width: 100% !important;
    padding: 8px 12px !important;
    box-sizing: border-box !important;
}
