/* ============================================================================
   Select2 – Premium SmartHome Teal & Obsidian Theme Override
   ============================================================================ */

/* ── Container ── */
.select2-container {
    width: 100% !important;
}

/* ── Single Selection Box ── */
.select2-container--bootstrap4 .select2-selection--single,
.select2-container--default .select2-selection--single {
    height: 42px !important;
    border: 1.5px solid #ebf1f6 !important;
    border-radius: 12px !important;
    background-color: #ffffff !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex !important;
    align-items: center !important;
    position: relative !important;
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px !important;
    padding-left: 12px !important;
    padding-right: 52px !important; /* Space for both clear button & arrow */
    color: #2a3547 !important;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ── Multiple Selection Box ── */
.select2-container--bootstrap4 .select2-selection--multiple,
.select2-container--default .select2-selection--multiple {
    min-height: 42px !important;
    border: 1.5px solid #ebf1f6 !important;
    border-radius: 12px !important;
    background-color: #ffffff !important;
    padding: 2px 36px 2px 6px !important; /* 36px padding-right to prevent choices overlapping the clear button */
    position: relative !important;
}

/* ── Clear Selection Button ── */
/* Base clear button styles for both single & multiple select */
.select2-container--bootstrap4 .select2-selection__clear,
.select2-container--default .select2-selection__clear {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    float: none !important;
    margin: 0 !important;
    z-index: 2 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #f1f3f5 !important;
    color: #6c757d !important;
    border-radius: 50% !important;
    line-height: 0 !important; /* Ensures multiplication character centers nicely */
    padding-bottom: 2px !important; /* Vertical centering adjustment for multiplication sign */
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: background-color 0.15s, color 0.15s;
}

/* Position clear button specifically for single select (needs to sit to the left of the arrow) */
.select2-container--bootstrap4 .select2-selection--single .select2-selection__clear,
.select2-container--default .select2-selection--single .select2-selection__clear {
    right: 32px !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 12px !important;
}

/* Position clear button specifically for multiple select (can sit closer to the right edge since there is no arrow) */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__clear,
.select2-container--default .select2-selection--multiple .select2-selection__clear {
    right: 12px !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 12px !important;
}

.select2-container--bootstrap4 .select2-selection__clear:hover,
.select2-container--default .select2-selection__clear:hover {
    background-color: #e2e6ea !important;
    color: #343a40 !important;
}

/* Arrow */
.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 12px !important;
    height: 20px !important;
    width: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b,
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    position: static !important;
    margin: 0 !important;
    border-color: #a1aab2 transparent transparent transparent !important;
    border-style: solid !important;
    border-width: 5px 4px 0 4px !important;
    height: 0 !important;
    width: 0 !important;
    display: inline-block !important;
}

/* ── Small Sizing Overrides (.form-select-sm, .form-control-sm) ── */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--single,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--single,
select.form-select-sm + .select2-container--default .select2-selection--single,
select.form-control-sm + .select2-container--default .select2-selection--single {
    height: 32px !important;
    border-radius: 8px !important;
}

select.form-select-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered,
select.form-select-sm + .select2-container--default .select2-selection--single .select2-selection__rendered,
select.form-control-sm + .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 30px !important;
    padding-left: 10px !important;
    padding-right: 44px !important; /* Space for small clear & small arrow */
    font-size: 0.8rem !important;
}

/* Small Arrow for single select */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow,
select.form-select-sm + .select2-container--default .select2-selection--single .select2-selection__arrow,
select.form-control-sm + .select2-container--default .select2-selection--single .select2-selection__arrow {
    right: 8px !important;
    height: 16px !important;
    width: 16px !important;
}

/* Small Clear Button for single select */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__clear,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--single .select2-selection__clear,
select.form-select-sm + .select2-container--default .select2-selection--single .select2-selection__clear,
select.form-control-sm + .select2-container--default .select2-selection--single .select2-selection__clear {
    right: 26px !important;
    width: 14px !important;
    height: 14px !important;
    font-size: 10px !important;
    padding-bottom: 2px !important;
}

/* Small Multiple Selection Box */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--multiple,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--multiple,
select.form-select-sm + .select2-container--default .select2-selection--multiple,
select.form-control-sm + .select2-container--default .select2-selection--multiple {
    min-height: 32px !important;
    border-radius: 8px !important;
    padding: 1px 28px 1px 6px !important; /* Smaller right padding for small multiple clear button */
}

/* Small Clear Button for multiple select */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__clear,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__clear,
select.form-select-sm + .select2-container--default .select2-selection--multiple .select2-selection__clear,
select.form-control-sm + .select2-container--default .select2-selection--multiple .select2-selection__clear {
    right: 8px !important;
    width: 14px !important;
    height: 14px !important;
    font-size: 10px !important;
    padding-bottom: 2px !important;
}

/* Small select choices styling */
select.form-select-sm + .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice,
select.form-control-sm + .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice,
select.form-select-sm + .select2-container--default .select2-selection--multiple .select2-selection__choice,
select.form-control-sm + .select2-container--default .select2-selection--multiple .select2-selection__choice {
    font-size: 0.75rem !important;
    margin-top: 2px !important;
    padding: 1px 6px !important;
}

/* ── Focus & Open States ── */
.select2-container--bootstrap4.select2-container--focus .select2-selection,
.select2-container--bootstrap4.select2-container--open .select2-selection {
    border-color: #00b4d8 !important;
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15) !important;
    outline: none;
}

/* ── Dropdown Panel ── */
.select2-container--bootstrap4 .select2-dropdown {
    border: 1.5px solid rgba(0, 180, 216, 0.3) !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
    background-color: #ffffff !important;
    overflow: hidden;
    padding: 6px !important;
    z-index: 9999 !important;
    margin-top: 4px;
}

/* ── Search Box inside Dropdown ── */
.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field {
    border: 1.5px solid #ebf1f6 !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 0.85rem;
    color: #2a3547 !important;
    background-color: #f8fafc !important;
    margin-bottom: 6px;
}

.select2-container--bootstrap4 .select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: #00b4d8 !important;
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.12) !important;
}

/* ── Options ── */
.select2-container--bootstrap4 .select2-results__option {
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
    color: #2a3547 !important;
    margin: 2px 0;
    transition: background-color 0.15s, color 0.15s;
}

/* Highlighted (hover) */
.select2-container--bootstrap4 .select2-results__option--highlighted[aria-selected] {
    background-color: #00b4d8 !important;
    color: #ffffff !important;
}

/* Already selected */
.select2-container--bootstrap4 .select2-results__option[aria-selected="true"] {
    background-color: rgba(0, 180, 216, 0.1) !important;
    color: #00b4d8 !important;
    font-weight: 600;
}

/* Tags Multiple Choices */
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(0, 180, 216, 0.08) !important;
    border: 1px solid rgba(0, 180, 216, 0.2) !important;
    color: #00b4d8 !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    font-weight: 600;
    font-size: 0.8rem;
    margin-top: 4px !important;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove {
    color: #00b4d8 !important;
    border-right: 1px solid rgba(0, 180, 216, 0.15) !important;
    padding-right: 6px !important;
    margin-right: 6px !important;
}

.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: transparent !important;
    color: #0096c7 !important;
}

/* ============================================================================
   DARK MODE OVERRIDES ([data-bs-theme="dark"])
   ============================================================================ */
[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--single,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single {
    border-color: #333336 !important;
    background-color: #111111 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #f5f5f7 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b,
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #86868b transparent transparent transparent !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--multiple,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple {
    border-color: #333336 !important;
    background-color: #111111 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-dropdown,
[data-bs-theme="dark"] .select2-container--default .select2-dropdown {
    border-color: rgba(0, 180, 216, 0.4) !important;
    background-color: #1d1d1f !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-search--dropdown .select2-search__field,
[data-bs-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
    border-color: #333336 !important;
    color: #f5f5f7 !important;
    background-color: #111111 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-results__option,
[data-bs-theme="dark"] .select2-container--default .select2-results__option {
    color: #f5f5f7 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-results__option[aria-selected="true"],
[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: rgba(0, 180, 216, 0.15) !important;
    color: #48cae4 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(0, 180, 216, 0.15) !important;
    border-color: rgba(0, 180, 216, 0.3) !important;
    color: #48cae4 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove,
[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #48cae4 !important;
    border-right-color: rgba(0, 180, 216, 0.25) !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection__clear,
[data-bs-theme="dark"] .select2-container--default .select2-selection__clear {
    background-color: #2d2d30 !important;
    color: #a1a1a6 !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap4 .select2-selection__clear:hover,
[data-bs-theme="dark"] .select2-container--default .select2-selection__clear:hover {
    background-color: #3a3a3c !important;
    color: #ffffff !important;
}
