:root,
[data-bs-theme="light"] {
    color-scheme: light;
}

html:not([data-bs-theme="dark"]) {
    color-scheme: light;
}

html:not([data-bs-theme="dark"]) select,
html:not([data-bs-theme="dark"]) .form-select {
    color-scheme: light;
    background-color: #fff;
    color: #212529;
}

html:not([data-bs-theme="dark"]) select option,
html:not([data-bs-theme="dark"]) .form-select option,
html:not([data-bs-theme="dark"]) optgroup {
    background-color: #fff;
    color: #212529;
}

html:not([data-bs-theme="dark"]) .select2-dropdown,
html:not([data-bs-theme="dark"]) .select2-results__option {
    background-color: #fff;
    color: #212529;
}

html:not([data-bs-theme="dark"]) .choices__list--dropdown,
html:not([data-bs-theme="dark"]) .choices__list[aria-expanded] {
    background-color: #fff;
    color: #212529;
}

html:not([data-bs-theme="dark"]) .choices__list--dropdown .choices__item,
html:not([data-bs-theme="dark"]) .choices__list[aria-expanded] .choices__item {
    color: #212529;
}

html:not([data-bs-theme="dark"]) .choices__inner {
    background-color: #fff;
    color: #212529;
}

html:not([data-bs-theme="dark"]) .choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: #f6f7fb !important;
    color: #212529;
}

.choices:has(.form-select.is-invalid) .choices__inner {
    border-color: var(--ins-form-invalid-border-color, #f1556c);
}

/* Small selects: theme sets top/left padding only; keep room for the chevron */
.form-select-sm {
    padding-right: 2.31rem;
}

/* Page header filters (e.g. returns status) — auto width is too tight for the arrow */
.page-title-head .form-select {
    width: auto;
    min-width: 12rem;
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .page-title-head .form-select {
        width: 100%;
        min-width: 0;
    }
}

/* DataTables 2 renders length/search controls as sibling nodes (not inside one label). */
.dt-container .dt-length {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
}

.dt-container .dt-length select,
.dt-container .dt-length .form-select {
    width: auto !important;
    max-width: none;
    flex: 0 0 auto;
    min-width: 4.25rem;
    margin: 0 !important;
}

.dt-container .dt-length label {
    margin: 0;
    white-space: normal;
}

/* DataTables toolbar — stack and align length + search on mobile */
@media (max-width: 767.98px) {
    .dt-container > .row:first-of-type,
    .dt-container > .dt-layout-row:first-child {
        --bs-gutter-y: 0.75rem;
    }

    .dt-container > .row:first-of-type > [class*="col-"],
    .dt-container > .dt-layout-row:first-child > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .dt-container .dt-layout-start,
    .dt-container .dt-layout-end {
        width: 100%;
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        justify-content: flex-start;
    }

    .dt-container div.dt-length,
    .dt-container div.dt-search,
    .dt-container div.dt-info,
    .dt-container div.dt-paging {
        width: 100%;
        text-align: left !important;
    }

    .dt-container .dt-length {
        margin-bottom: 0.75rem;
    }

    .dt-container .dt-search {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.375rem;
    }

    .dt-container .dt-search label {
        display: block;
        margin: 0;
        white-space: normal;
    }

    .dt-container .dt-search input {
        width: 100% !important;
        max-width: none;
        margin: 0 !important;
        display: block;
    }

    .table-responsive > .dt-container > .row > div[class^="col-"]:first-child,
    .table-responsive > .dt-container > .row > div[class^="col-"]:last-child {
        padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
        padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    }
}

/* Product attribute selects — keep native dropdown visible (no Choices.js) */
[id$="_options"] select[id^="attribute_select_"] {
    display: block !important;
    width: 100%;
    visibility: visible;
    opacity: 1;
}
