/**
 * Tester Bundle - frontend styles
 * Select2 can clash with theme CSS (especially select/height rules),
 * which makes the box look oversized and misaligns the "max
 * selection" message. These rules override that clash with high
 * specificity so theme styles can't win.
 */

#tbf-tester-select-wrap {
    max-width: 500px;
}

/* Keep the native <select> hidden immediately, so no large native
   listbox flashes on page load before Select2 initializes */
#tbf-tester-select-wrap select#tbf-tester-search {
    display: none;
}

#tbf-tester-select-wrap .select2-container {
    display: block !important;
    width: 100% !important;
}

/* High-specificity selector (id + adjacent sibling) so this always
   wins over any theme/select2 default styling */
#tbf-tester-search + .select2-container .select2-selection--multiple,
#tbf-tester-select-wrap .select2-selection--multiple {
    box-sizing: border-box !important;
    display: block !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    line-height: 36px !important;
    padding: 0 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    border: 1px solid #d5d5d5 !important;
    border-radius: 4px !important;
}

/* Once at least one item is picked, allow the box to grow to fit a
   couple of wrapped rows of chips instead of scrolling sideways */
#tbf-tester-select-wrap .select2-selection--multiple.tbf-has-selection {
    height: auto !important;
    max-height: 84px !important;
    line-height: normal !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    white-space: normal !important;
    padding: 4px 6px !important;
}

#tbf-tester-select-wrap .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    padding: 0 !important;
    margin: 0;
}

#tbf-tester-select-wrap .select2-selection--multiple.tbf-has-selection .select2-selection__rendered {
    flex-wrap: wrap;
}

#tbf-tester-select-wrap .select2-selection--multiple .select2-selection__choice {
    margin: 2px 0 !important;
    white-space: nowrap;
}

#tbf-tester-select-wrap .select2-selection--multiple .select2-search--inline .select2-search__field {
    height: 30px !important;
    line-height: 30px !important;
    margin: 0 !important;
}

/* Dropdown panel (search results / "You can only select N items"
   message) always opens BELOW the selection box, at its own
   natural height */
#tbf-tester-select-wrap .select2-dropdown {
    z-index: 9999;
    border: 1px solid #d5d5d5;
}

#tbf-tester-select-wrap .select2-results__message {
    padding: 8px 12px;
    color: #767676;
    font-size: 13px;
}

#tbf-tester-select-wrap .select2-results__options {
    max-height: 200px;
    overflow-y: auto;
}

/* Size-picker rows — one per selected sized tester (3ml/5ml/10ml) */
#tbf-selected-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.tbf-size-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    background: #fafafa;
}

.tbf-size-row-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tbf-size-select {
    min-width: 160px;
}

.tbf-size-row.tbf-size-row-error {
    border-color: #d63638;
    background: #fcf0f1;
}

.tbf-size-error-msg {
    color: #d63638;
    font-size: 12px;
    flex-basis: 100%;
}

/* "Please select N more testers" hint */
.tbf-count-hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #767676;
}

.tbf-count-hint.tbf-count-hint-error {
    color: #d63638;
    font-weight: 600;
}
