/* Single-line controls share a border-box height on every browser, including
   Safari's native selects. Change the context variables, not a field's height.
   Contract: docs/formulaires.md / AGENTS.md. */
.app-theme, .app-login {
    --app-control-height: 44px;
    --app-control-font-size: 13px;
    --app-control-min-size: 0px;
}
.app-theme :is(.app-controls--compact, .app-control--compact) {
    --app-control-height: 36px;
    --app-control-font-size: 12px;
}
.app-theme :is(.table, .input-group-sm, .form-control-sm, .custom-select-sm, .input-sm, .app-controls--small, .app-control--small) {
    --app-control-height: 32px;
    --app-control-font-size: 12px;
}
.app-theme :is(.input-group-lg, .form-control-lg, .custom-select-lg, .app-controls--large, .app-control--large) {
    --app-control-height: 48px;
    --app-control-font-size: 16px;
}
.app-theme :is(
    input.form-control:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
    select.form-control:not([multiple]):not([size]:not([size="1"])):not(.selectpicker):not(.bs-select-hidden),
    select.custom-select:not([multiple]):not([size]:not([size="1"])):not(.selectpicker):not(.bs-select-hidden),
    .bootstrap-select > .dropdown-toggle,
    .dataTables_filter input,
    .dataTables_length select,
    .uber-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
    .uber-field select:not([multiple]),
    .uber-sales-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
    .uber-sales-field select:not([multiple])
),
.app-login .app-form-field input {
    box-sizing: border-box !important;
    min-width: 0;
    max-width: 100%;
    height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    min-height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    font-family: Montserrat, sans-serif;
    font-size: var(--app-control-font-size, 13px) !important;
    line-height: 1.4 !important;
}
/* Keep native select semantics and keyboard behavior; draw a consistent arrow. */
.app-theme :is(
    select.form-control, select.custom-select,
    .dataTables_length select, .uber-field select, .uber-sales-field select
):not([multiple]):not([size]:not([size="1"])):not(.selectpicker):not(.bs-select-hidden) {
    -webkit-appearance: none !important;
    appearance: none !important;
    padding-right: 34px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23667585' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 12px !important;
}
.app-theme .bootstrap-select > .dropdown-toggle .filter-option {
    display: flex;
    align-items: center;
}
/* Date/time values otherwise use different internal alignment on WebKit. */
.app-theme input.form-control::-webkit-date-and-time-value {
    min-height: 1.4em;
    text-align: left;
}
/* Match addons and adjacent action buttons to their input, including sm/lg. */
.app-theme .input-group :is(.input-group-text, .input-group-append > .btn, .input-group-prepend > .btn) {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    min-height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
/* The outer shell, not the nested text input, is the pilotage search control. */
.app-theme .hp-search {
    box-sizing: border-box;
    height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px));
    min-height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px));
}
.app-theme .hp-search input { font-size: var(--app-control-font-size, 13px); }
/* A quantity stepper is an intentionally larger control: all three parts match. */
.app-theme .inventory-stepper {
    --app-control-height: 48px;
    --app-control-font-size: 24px;
}
.app-theme .inventory-stepper > .btn {
    height: 48px !important;
    min-height: 48px !important;
}
/* File controls share the standard outer height; their native button remains usable. */
.app-theme :is(input.form-control[type="file"], .custom-file, .custom-file-input, .custom-file-label) {
    box-sizing: border-box;
    height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    min-height: max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) !important;
    font-size: var(--app-control-font-size, 13px);
}
.app-theme .custom-file-label { display: flex; align-items: center; padding-top: 0; padding-bottom: 0; }
.app-theme .custom-file-label::after { display: flex; align-items: center; height: calc(max(var(--app-control-height, 44px), var(--app-control-min-size, 0px)) - 2px); padding-top: 0; padding-bottom: 0; }
/* Multi-line fields and list boxes keep their content-driven height. */
.app-theme textarea.form-control { box-sizing: border-box; height: auto; min-height: 88px; }
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
    .app-theme, .app-login { --app-control-min-size: 44px; --app-control-font-size: 16px; }
    .app-theme :is(.app-controls--compact, .app-control--compact, .table, .input-group-sm, .form-control-sm, .custom-select-sm, .input-sm, .app-controls--small, .app-control--small) { --app-control-font-size: 16px; }
    .app-theme .inventory-stepper { --app-control-font-size: 24px; }
    /* Invisible native picker overlay: retain the size of the visible trigger. */
    .app-theme.inventory-page .inventory-controls #inventory-select { --app-control-height: 32px; --app-control-min-size: 0px; }
}
@media (forced-colors: active) {
    .app-theme :is(select.form-control, select.custom-select, .dataTables_length select):not([multiple]) {
        appearance: auto !important;
        background-image: none !important;
    }
}
