/* Form Field — vertical label + input layout (default) */

.app-field {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    font-family: var(--font-family-primary);
}

.app-field__label {
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    line-height: var(--font-body-sm-line-height);
}

/* Secondary inline label inside a field row, e.g. a hint sitting between two controls */
.app-field__hint {
    font-size: var(--font-body-sm-size);
    color: var(--text-tertiary);
    line-height: var(--font-body-sm-line-height);
    flex-shrink: 0;
}

/* Inline variant — label and input side by side */

.app-field--inline {
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-md);
}

.app-field--inline > .app-field__label {
    flex-shrink: 0;
    min-width: 160px;
}

/* ========== Two fields sharing a row ==========
   A postcode is five to eight characters in every country we serve and a city name is not, so the
   pair must not be sized alike. The legacy `flex_stretch_*` family caps them in absolute pixels
   (zipcode 125px, city 260px) and then drops every cap to `max-width: 100%` below 1500px, so on a
   laptop the row splits 50/50 and a postcode gets as much room as a city — while on a wide screen
   the pair stops ~90px short of the single field on the row above.

   These size the pair by role instead: the narrow field takes a fixed column, its partner takes
   whatever is left. The pair then ends exactly where a lone field ends, at every width. Use them
   in place of the legacy caps, not alongside them — `div[class*='flex_stretch_']` is (0,1,1) and
   would keep winning.

   `--grow` is named for what it does rather than for the city, because the same shape serves sort
   code / account number and any other narrow-plus-wide pair, and because the missing grow
   modifier is what `open-questions.md` records as blocking paired fields.
   ============================================== */

/* 8rem clears the longest of the five countries' formats, LT-01100, with its label above it
   ("Pasta indekss" is the longest of those). It is also what the legacy 125px cap gave, so the
   field keeps the width it has on a wide screen today. */
.app-field--zip {
    flex: 0 0 8rem;
    max-width: 8rem;
}

.app-field--grow {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
}

/* In a detail-page column, a growing field's textarea fills it instead of sizing it, so a notes box ends level with the neighbouring column. */
.app-detail-page__fields-col > .app-field--grow > textarea.app-input {
    flex: 1 1 0;
    min-height: 0;
}

/* A field row whose value is read-only text rather than a control — an errand number, a created-by
   stamp, an "innan, via" caption between two inputs. Matches the input's own type so the row reads
   as one line. */
.app-field__static {
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
    color: var(--text-primary);
    white-space: nowrap;
}

/* Inline fields on list pages size to content instead of stretching across the page */
.app-list .app-field--inline > .app-input {
    width: auto;
    min-width: 240px;
}

/* Same inside a dialog: a full-width input has nothing bounding it there, so it stretches the
   dialog open — modal_project rendered 1955px wide before this. */
.app-dialog__body .app-field--inline > .app-input {
    width: auto;
    min-width: 240px;
}

/* And a field placed straight in a detail-page section, outside the __fields grid — nothing bounds
   it there either. The second selector is the Briox.Select anchor wrapper the settings pages use. */
.app-detail-page__section-content > .app-field--inline > .app-input,
.app-detail-page__section-content > .app-field--inline > .relative_flex_container > .app-input {
    width: auto;
    min-width: 240px;
}

/* Input Component — BEM */

/* ========== BASE ========== */
.app-input {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-family-primary);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-sizing: border-box;
}

.app-input:hover {
    border-color: var(--tertiary-500);
}

.app-input:focus-within {
    border-color: var(--tertiary-700);
    box-shadow: 0 0 0 var(--focus-ring-offset) color-mix(in srgb, var(--tertiary-400) 40%, transparent);
}

/* ========== SIZES ========== */
.app-input--sm {
    height: 28px;
    padding: 0 var(--spacing-sm);
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
    border-radius: var(--radius-sm);
}

/* Legacy novus_*_input size classes set height/radius/font on the same element.
   When both are present, the design system wins. */
select.app-input--sm.novus_medium_input,
select.app-input--sm.novus_long_input,
select.app-input--sm.novus_short_input {
    height: 28px;
    border-radius: var(--radius-sm);
}

.app-input--md {
    height: 34px;
    padding: 0 var(--spacing-md);
    font-size: var(--font-body-md-size);
    line-height: var(--font-body-md-line-height);
    border-radius: var(--radius-md);
}

.app-input--lg {
    height: 40px;
    padding: 0 var(--spacing-md);
    font-size: var(--font-body-lg-size);
    line-height: var(--font-body-lg-line-height);
    border-radius: var(--radius-lg);
}

/* ========== NATIVE INPUT ELEMENT ========== */
.app-input__field {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 0;
}

.app-input__field::placeholder {
    color: var(--text-tertiary);
}

/* forms.css gives every ::placeholder one fixed size; here it follows the field's (--sm, --md, --lg). */
.app-input::placeholder,
.app-input__field::placeholder {
    font-size: inherit;
}

/* ========== STATES ========== */
/* Locked look shared by disabled and read-only: a read-only field (a looked-up name beside a number
   input) stays selectable, so only disabled adds the not-allowed cursor below. */
.app-input--disabled,
.app-input--disabled:hover,
.app-input:disabled,
.app-input:disabled:hover,
.app-input:has(> .app-input__field:disabled),
.app-input:has(> .app-input__field:disabled):hover,
/* Briox.Select.disable() puts a disabled attribute on the trigger div it built from the <select> */
.app-input.novus_filter_select[disabled],
.app-input.novus_filter_select[disabled]:hover,
.app-input[readonly],
.app-input[readonly]:hover {
    background: var(--color-disabled-bg);
    border-color: var(--border-tertiary);
    color: var(--color-disabled-text);
}

.app-input--disabled,
.app-input:disabled,
.app-input:has(> .app-input__field:disabled),
.app-input.novus_filter_select[disabled] {
    cursor: default;
}

.app-input[readonly]:focus-within {
    border-color: var(--border-secondary);
    box-shadow: none;
}

/* The background and colour repeat .app-input__field's own values: legacy `input[disabled]` is
   (0,1,1) and outranks it, painting the field #eee inside an already-grey box - two greys. */
.app-input--disabled .app-input__field,
.app-input .app-input__field:disabled,
.app-input__field:disabled {
    background: transparent;
    color: inherit;
    background: transparent;
    color: var(--color-disabled-text);
    cursor: default;
    -webkit-text-fill-color: var(--color-disabled-text);
    opacity: 1;
}

.app-input--error {
    border-color: var(--error);
}

.app-input--error:focus-within {
    border-color: var(--error);
    box-shadow: 0 0 0 var(--focus-ring-offset) rgba(239, 68, 68, 0.12);
}

/* ========== TEXTAREA ========== */

textarea.app-input {
    height: auto;
    min-height: 80px;
    padding: var(--spacing-sm) var(--spacing-md);
    resize: vertical;
    line-height: var(--font-body-sm-line-height);
}

/* ========== STANDALONE (no wrapper) ========== */
/* When .app-input is applied directly to <input> or <select> elements */
input.app-input,
select.app-input,
textarea.app-input {
    outline: none;
}

/* Select Component — same visual as input */
select.app-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236883a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--spacing-sm) center;
    cursor: pointer;
}

select.app-input--sm {
    padding-right: calc(var(--spacing-sm) + 16px);
}

select.app-input--md {
    padding-right: calc(var(--spacing-md) + 16px);
}

select.app-input--lg {
    padding-right: calc(var(--spacing-md) + 16px);
}

/* ========== RADIO & CHECKBOX ========== */

.app-radio-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-2xl);
}

/* Options stacked in a column — a package picker, a send-now / send-later choice.
   .app-radio-group is a horizontal row, so align-items has to be reset too. */
.app-radio-group--vertical {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.app-radio-group__option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    /* These are <label>s, and forms.css sets `fieldset label { font-size: 11px }` - below the
       smallest size in the scale. State the size so the option reads like the copy around it. */
    font-size: var(--font-body-sm-size);
}

.app-radio-group__option input[type="radio"],
.app-radio-group__option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--neutral-300);
    background: var(--bg-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.app-radio-group__option input[type="radio"] {
    border-radius: 50%;
	width: 18px;
	height: 18px;
}

.app-radio-group__option input[type="checkbox"] {
    border-radius: var(--radius-sm, 4px);
}

.app-radio-group__option input[type="radio"]:checked {
    border-color: var(--accent);
    border-width: 5px;
	width: 18px;
	height: 18px;
}

.app-radio-group__option input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px;
}

.app-radio-group__option input:hover {
    border-color: var(--neutral-400);
}

.app-radio-group__option input:checked:hover {
    border-color: var(--accent-dark);
}

/* Disabled state (settings pages disable options from JS when the user may not change them) */
.app-radio-group__option input[type="radio"]:disabled,
.app-radio-group__option input[type="checkbox"]:disabled,
.app-radio-group__option input:disabled:hover {
    border-color: var(--border-secondary);
    background: var(--color-disabled-bg);
    cursor: not-allowed;
}

.app-radio-group__option input[type="radio"]:disabled:checked,
.app-radio-group__option input[type="radio"]:disabled:checked:hover {
    border-color: var(--neutral-400);
}

.app-radio-group__option:has(> input:disabled) {
    cursor: not-allowed;
}

.app-radio-group__option:has(> input:disabled) > .app-radio-group__label {
    color: var(--color-disabled-text);
}

.app-radio-group__label {
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    line-height: var(--font-body-sm-line-height);
    cursor: pointer;
    user-select: none;
}

/* ========== RADIO CARDS ==========
   Each option as a bordered card, two per row, tinted when chosen. Works for radios and checkboxes.
     .app-radio-group.app-radio-group--cards
       label.app-radio-group__option > input + .app-radio-group__text
         .app-radio-group__label + .app-radio-group__desc (optional)
   Must stay below .app-radio-group and --vertical: it overrides their display, gap and alignment. */

.app-radio-group--cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    align-items: stretch;
    gap: var(--spacing-md);
}

@media (max-width: 640px) {
    .app-radio-group--cards {
        grid-template-columns: minmax(0, 1fr);
    }
}

.app-radio-group--cards > .app-radio-group__option {
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
}

.app-radio-group--cards > .app-radio-group__option:has(> input:checked) {
    border-color: var(--accent);
    background: var(--accent-50);
}

.app-radio-group--cards > .app-radio-group__option:has(> input:disabled) {
    opacity: 0.55;
}

/* Level with the title's first line rather than the top of the card. */
.app-radio-group--cards > .app-radio-group__option > input {
    margin-top: 1px;
}

.app-radio-group__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-radio-group__desc {
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-regular);
    line-height: var(--font-body-sm-line-height);
    color: var(--text-tertiary);
}

/* ========== CHECKBOX ========== */

.app-checkbox {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.app-checkbox__option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-size: var(--font-body-sm-size);
}

.app-checkbox__option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--neutral-300);
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.app-checkbox__option input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px;
}

.app-checkbox__option input[type="checkbox"]:hover {
    border-color: var(--neutral-400);
}

.app-checkbox__option input[type="checkbox"]:checked:hover {
    border-color: var(--accent-dark);
}

/* background-color, not the `background` shorthand: the shorthand resets background-image, which
   erases the checkmark :checked draws - a disabled checked box then reads as unchecked. */
.app-checkbox__option input[type="checkbox"]:disabled {
    background-color: var(--neutral-100, #f3f4f6);
    border-color: var(--neutral-200, #e5e7eb);
    cursor: not-allowed;
    opacity: 0.6;
}

.app-checkbox__option input[type="checkbox"]:disabled:checked {
    background-color: var(--neutral-300, #d1d5db);
    border-color: var(--neutral-300, #d1d5db);
}

.app-checkbox__label {
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    line-height: var(--font-body-sm-line-height);
    cursor: pointer;
    user-select: none;
}

/* ========== FIELD ROW — side-by-side inputs within a single field ==========
   Use .app-field__row as a flex container below a label when two or more controls share one field.
   Children use --grow (fills remaining space) or --fixed-* (fixed proportional width).

   Markup:
     .app-field
       .app-field__label
       .app-field__row
         .app-input.app-field__row-item--grow
         .app-input.app-field__row-item--fixed-sm
   ============================================================================ */

.app-field__row {
    display: flex;
    gap: var(--spacing-sm);
    min-width: 0;
}

.app-field__row > * {
    min-width: 0;
}

/* Fluid item — fills available space equally with siblings */
.app-field__row-item--grow {
    flex: 1 1 0%;
    width: auto;
}

/* Fixed proportional items — shrink with the column but keep their ratio */
.app-field__row-item--fixed-sm {
    flex: 0 0 25%;
    max-width: 50px;
}

.app-field__row-item--fixed-md {
    flex: 0 0 35%;
    max-width: 70px;
}

/* Briox.Select copies element classes onto its replacement div but drops inline styles.
   Scoped to .app-field__row so legacy selects elsewhere are untouched. */
.app-field__row .novus_filter_select.app-field__row-item--grow {
    flex: 1 1 0%;
    width: auto;
}

/* ========== INFO ICON ========== */

/* Short numeric field — a percentage, a number of days, a small amount. .app-input is width:100%,
   so without this one it stretches the whole row and its unit label lands at the far edge. */
.app-input--narrow {
    width: auto;
    max-width: 7rem;
}

/* A date with its calendar icon: YYYY-MM-DD / DD.MM.YYYY fits with room to spare, instead of a full-width row. */
.app-input--date {
    width: auto;
    max-width: 9.5rem;
}

.app-info-icon {
    font-size: var(--icon-size-sm);
    color: var(--text-tertiary);
    flex-shrink: 0;
    vertical-align: middle;
}

.app-field__label .app-info-icon,
.app-form__label .app-info-icon {
    font-size: var(--icon-size-md);
}

/* Autocomplete loading dropdown — DS-styled spinner shown while results load */
.app-autocomplete-loading-drop {
    display: none;
    position: absolute;
    z-index: 999;
    padding: var(--spacing-md);
    text-align: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
}

