/* Shared sizing for native controls and Select2, including HTMX modals. */
input.form-control:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
select.form-control:not([multiple]):not([size]),
select.custom-select:not([multiple]):not([size]),
select.form-control[size="1"],select.custom-select[size="1"] {
    height: var(--ogesa-control-height, 42px);
    min-height: var(--ogesa-control-height, 42px);
}
.form-control-sm,.custom-select-sm { --ogesa-control-height: 34px; }
.form-control-lg,.custom-select-lg { --ogesa-control-height: 48px; }
select.form-control-sm + .select2-container { --ogesa-control-height: 34px; }
select.form-control-lg + .select2-container { --ogesa-control-height: 48px; }
.select2-container { max-width: 100%; min-width: 0; }
.select2-container .select2-selection--single,
.ogesa-responsive-form .select2-container .select2-selection--single {
    height: var(--ogesa-control-height, 42px);
    min-height: var(--ogesa-control-height, 42px);
    position: relative;
}
.select2-container .select2-selection--single .select2-selection__rendered {
    display: block;
    height: 100%;
    line-height: calc(var(--ogesa-control-height, 42px) - 2px);
    padding: 0 3.5rem 0 .75rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.select2-container .select2-selection--single .select2-selection__arrow {
    height: calc(var(--ogesa-control-height, 42px) - 2px);
    top: 0;
    right: 4px;
    width: 24px;
}
.select2-container .select2-selection--single .select2-selection__clear {
    position: absolute;
    top: 0;
    right: 32px;
    height: calc(var(--ogesa-control-height, 42px) - 2px);
    line-height: inherit;
    margin: 0;
    padding: 0 3px;
}
.select2-container .select2-selection--multiple {
    height: auto;
    min-height: var(--ogesa-control-height, 42px);
}
.select2-container .select2-selection--multiple .select2-selection__rendered {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    line-height: 1.5;
    height: auto;
    padding: 4px 8px;
    white-space: normal;
    overflow: visible;
}
.select2-container .select2-selection--multiple .select2-selection__choice {
    float: none;
    margin: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}
.select2-container .select2-selection--multiple .select2-search--inline {
    float: none;
    max-width: 100%;
}
.select2-container .select2-search--inline .select2-search__field {
    max-width: 100%;
    height: 28px;
    line-height: 28px;
    margin-top: 0;
}
.select2-dropdown .select2-results__option { overflow-wrap: anywhere; }
html,body,body * {
    scrollbar-width: thin;
    scrollbar-color: var(--ogesa-scroll-thumb, #bd8057) var(--ogesa-scroll-track, #eef2f6);
}
html::-webkit-scrollbar,body::-webkit-scrollbar,body *::-webkit-scrollbar,.modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
html::-webkit-scrollbar-track,body::-webkit-scrollbar-track,body *::-webkit-scrollbar-track,.modal-body::-webkit-scrollbar-track {
    background: var(--ogesa-scroll-track, #eef2f6); border-radius: 8px;
}
html::-webkit-scrollbar-thumb,body::-webkit-scrollbar-thumb,body *::-webkit-scrollbar-thumb,.modal-body::-webkit-scrollbar-thumb {
    background: var(--ogesa-scroll-thumb, #bd8057);
    border: 2px solid var(--ogesa-scroll-track, #eef2f6); border-radius: 8px;
}
html::-webkit-scrollbar-thumb:hover,body::-webkit-scrollbar-thumb:hover,body *::-webkit-scrollbar-thumb:hover,.modal-body::-webkit-scrollbar-thumb:hover { background: #a95119; }
body *::-webkit-scrollbar-corner { background: var(--ogesa-scroll-track, #eef2f6); }
.page-sidebar { --ogesa-scroll-thumb: #6f8391; --ogesa-scroll-track: #162b3d; }
.page-sidebar .primary-nav { scrollbar-color: var(--ogesa-scroll-thumb) var(--ogesa-scroll-track); }
.modal-body { scrollbar-color: var(--ogesa-scroll-thumb) var(--ogesa-scroll-track); }
@media(max-width:575.98px) {
    :root { --ogesa-control-height: 44px; }
    /* Avoid iOS zoom when focusing a field. Textareas remain freely resizable. */
    form .form-control,form .custom-select,.select2-container .select2-selection__rendered,
    .select2-container .select2-search__field { font-size: 16px; }
}
@media(forced-colors:active) {
    html,body,body *, .modal-body,.page-sidebar .primary-nav { scrollbar-color: auto; }
}
