/**
 * Global Select2 optional clear (×): right side, large tap target, separate from “open dropdown”.
 * Load after select2.min.css (included on pages that use Select2).
 */

.select2-selection {
    overflow: visible;
}

.select2-selection--single {
    display: flex !important;
    align-items: stretch;
    padding-right: 0;
}

.select2-selection--single .select2-selection__rendered {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 0.35rem;
    order: 1;
}

.select2-selection--single .select2-selection__arrow {
    flex: 0 0 auto;
    position: relative;
    height: auto;
    top: auto;
    width: 1.75rem;
    order: 2;
}

/* × on the far right (after chevron) */
.select2-selection--single .select2-selection__clear {
    order: 3;
    border-left: 1px solid var(--bs-border-color, #dee2e6);
    border-right: none;
}

.select2-selection__clear {
    float: none !important;
    position: relative;
    z-index: 2;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-width: 3rem;
    margin: 0 !important;
    padding: 0 0.55rem;
    cursor: pointer;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-weight: 800;
    font-size: 1.625rem;
    line-height: 1;
    color: #212529;
    -webkit-font-smoothing: antialiased;
    border-left: 1px solid var(--bs-border-color, #dee2e6);
    background-color: var(--bs-light, #f8f9fa);
    box-sizing: border-box;
}

.select2-selection--multiple {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
}

/* Multi-select chips: keep compact, wrap horizontally */
.select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center;
    gap: 0.25rem;
}

.select2-selection--multiple .select2-selection__choice {
    display: inline-flex !important;
    align-items: center;
    width: auto !important;
    max-width: 100%;
    margin: 0.15rem 0.15rem 0.15rem 0 !important;
}

/* Make remove "x" visible on dark chips (custom theme uses dark bg) */
.select2-selection--multiple .select2-selection__choice__remove {
    color: #fff !important;
    opacity: 0.9;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 0.35rem !important;
    margin: 0 0.25rem 0 0 !important;
    line-height: 1 !important;
    font-weight: 900;
}
.select2-selection--multiple .select2-selection__choice__remove:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.2rem;
}

/* Inline search box inside multi-select: make it larger */
.select2-container .select2-search--inline .select2-search__field {
    min-width: 10rem;
    height: 28px;
    padding: 3px 6px;
    margin-top: 4px;
    font-size: 0.95rem;
}

/* Dropdown list should scroll (some pages override this accidentally) */
.select2-container--open .select2-results__options {
    max-height: 260px !important;
    overflow-y: auto !important;
}

.select2-selection--multiple .select2-selection__clear {
    float: none !important;
    position: relative;
    z-index: 2;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    margin: 0.2rem 0 0.2rem auto !important;
    padding: 0.3rem 0.5rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1.625rem;
    font-weight: 800;
    color: #212529;
    -webkit-font-smoothing: antialiased;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    background-color: var(--bs-light, #f8f9fa);
    box-sizing: border-box;
    order: 99;
}
