/* Some older page styles use !important for focus. Keep the visible field edge
   in one layer so a page or a widget cannot add a second stroke. */
@layer agatix-field-borders {
    :where(
        input:not([type]), input:is([type="text"], [type="email"], [type="password"],
            [type="search"], [type="url"], [type="tel"], [type="number"], [type="date"],
            [type="datetime-local"], [type="month"], [type="week"], [type="time"]),
        select, textarea, button.input, .campaign-picker-trigger, .pop-version-button,
        .custom-select-trigger, .treeselect-input, .tf-multi-box, .tr-choice-trigger,
        .number:has(> input), :is(.price-picker, .an-picker, .te-period-picker) > summary,
        #ag-ai-compose
    ):not(.flatpickr-calendar *):not(.number > input, .tf-multi-box input, .treeselect-input input, #ag-ai-compose textarea) {
        box-sizing: border-box !important;
        border-width: 1px !important;
        border-style: solid !important;
        outline: none !important;
        box-shadow: none !important;
        transition: none !important;

        &:is(:hover, :focus-within, .treeselect-input--opened, .is-open, .is-clicked):not(:disabled, [aria-disabled="true"], [aria-invalid="true"], .tr-native-validation-invalid, .tf-weight-error, .tf-weight-invalid input, :user-invalid):not(:has([aria-invalid="true"], :user-invalid)) {
            border-color: var(--agatix-field-active, var(--black, #242424)) !important;
        }

        @media (forced-colors: active) {
            &:focus-within { --agatix-field-active: Highlight; }
        }
    }

    :where(.custom-select-trigger, .treeselect-input)::before,
    .treeselect .treeselect-input::after {
        content: none !important;
    }

    :is(.number > input, .tf-multi-box input, .treeselect-input input, #ag-ai-compose textarea) {
        border-width: 0 !important;
        outline: none !important;
        box-shadow: none !important;
        transition: none !important;
    }
    :where(.number, .tf-multi-box, .treeselect-input):has(input:is([aria-invalid="true"], .tf-weight-error, :user-invalid)) {
        border-color: #b53620 !important;
    }
}

/* Keep the controls' original rounded silhouette when replacing a pseudo-element. */
:is(.custom-select .custom-select-trigger, .treeselect .treeselect-input, .number:has(> input)) {
    border-radius: 1.6rem;
    border-color: var(--gray-2, #e5e5e5);
}
