/* =========================================================
   Forms (v2) · label + field rows, errors and Choices.js
   Load after shared/vendor/choices/choices.min.css.
   ========================================================= */

/* Page of one record (auction, lot). The page never scrolls (see main.css): the form scrolls
   inside the remaining space. */
.form-page {
    padding: var(--token-space-3) var(--token-space-5) 80px;
    align-items: center;
    overflow-y: auto;
}

/* 1039px, as the frames of Figma. */
.form-page__form {
    width: 1039px;
    max-width: 100%;
}

.form-card {
    background-color: var(--background-form);
    border: 1px solid var(--border-form);
    border-radius: var(--token-radius-s);
    padding: var(--token-space-5) 106px 80px;
}

.form-card__header {
    color: var(--font-color-form);
    display: flex;
    flex-direction: column;
    gap: var(--token-space-2);
}

.form-card__title {
    font-size: var(--token-font-size-h1);
    font-weight: var(--token-font-weight-bold);
    letter-spacing: -0.48px;
}

.form-card__hint {
    font-size: var(--token-font-size-xs);
    font-style: italic;
    letter-spacing: -0.24px;
}

.form-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--token-space-6);
    counter-reset: form-section;
}

/* =========================================================
   Numbered sections
   The number comes from a CSS counter, so hidden sections (the ones of other lot types)
   do not leave gaps: «1. Subasta», «2. Identificación del Productor»...
   ========================================================= */

.form-section {
    display: flex;
    flex-direction: column;
    gap: var(--token-space-3);
}

/* display: flex would override the hidden attribute. Hidden sections take no number. */
.form-section[hidden] {
    display: none;
}

.form-section__title {
    font-size: var(--token-font-size-h2);
    font-weight: var(--token-font-weight-semibold);
    letter-spacing: -0.36px;
    color: var(--font-color-form);
    padding-left: var(--token-space-1);
}

.form-section__title::before {
    content: counter(form-section) ". ";
    counter-increment: form-section;
}

/* Section in a grey box, as «Precio Mínimo de Venta» in Figma. */
.form-section--boxed {
    background-color: var(--background-form-section-boxed);
    border: 1px solid var(--border-form-section-boxed);
    border-radius: var(--token-radius-s);
    padding: var(--token-space-3);
}

/* Title with a description right under it (no gap), as «Contenido de tierra» in Figma. */
.form-section__header {
    display: flex;
    flex-direction: column;
}

.form-section__description {
    font-size: var(--token-font-size-s);
    font-weight: var(--token-font-weight-regular);
    line-height: 20px;
    color: var(--font-color-form-description);
}

/* =========================================================
   Field rows
   ========================================================= */

.label-input-box {
    display: grid;
    grid-template-columns: 149px 171px;
    align-items: center;
    column-gap: var(--token-space-2);
}

/* display: grid would override the hidden attribute (the province field that does not apply to the country). */
.label-input-box[hidden] {
    display: none;
}

/* Long selects (auction, producer). */
.label-input-box--wide {
    grid-template-columns: 149px 388px;
}

/* Long texts: names, addresses, email, IBAN (user form, Figma 1375-4276). */
.label-input-box--long {
    grid-template-columns: 149px 283px;
}

/* Tall fields (textarea): the label stays on the first line of the field. */
.label-input-box--top {
    align-items: start;
}

.label-input-box--top > .label {
    padding-top: 6px;
}

/* Radio buttons and checkboxes take the room they need. On a <fieldset>, with the label as a
   <legend>: floated, the legend leaves the border and becomes the first cell of the grid. */
.label-input-box--choices {
    grid-template-columns: 149px auto;
    min-height: 40px;
    border: none;
    margin: 0;
    padding: 0;
    min-inline-size: 0;
}

.label-input-box--choices > legend {
    float: left;
    padding: 0;
}

/* Two short read-only fields on one row, ending where the long selects end (545px):
   label 149 + field 90, 66px apart, label 134 + field 90. */
.label-input-box--pair {
    grid-template-columns: 149px 90px 50px 134px 90px;
}

.label-input-box--pair .label-input-box__second {
    grid-column: 4;
}

/* Values shown under a long select (producer NIF and phone), aligned with its field. */
.label-input-box--details {
    grid-template-columns: auto 138px auto 138px;
    justify-content: start;
    padding-left: 157px;
}

.label-input-box--details .label-input-box__second {
    margin-left: var(--token-space-4);
}

/* Options of a radio or checkbox group: the second one starts 118px after the first, as in Figma. */
.choice-group {
    display: flex;
    gap: var(--token-space-5);
}

.choice-group > * {
    min-width: 78px;
}

.label {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-semibold);
    line-height: 21px;
    color: var(--font-color-form);
}

.input {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-medium);
    line-height: 21px;
    width: 100%;
    height: 40px;
    color: var(--font-color-form);
    background-color: var(--background-input);
    border: 1px solid var(--border-input);
    border-radius: var(--token-radius-m);
    padding: 0 var(--token-space-2);
}

/* Multi-line text, 120px high as in Figma; it grows downwards only. */
.input--textarea {
    height: 120px;
    padding: var(--token-space-2);
    resize: vertical;
}

.input:focus-visible {
    border-color: var(--border-input-focus);
    outline: none;
}

.input[readonly],
.input:disabled {
    background-color: var(--background-input-readonly);
    cursor: default;
}

/* Date fields use the calendar icon of Figma instead of the browser one. */
.input[type="date"]::-webkit-calendar-picker-indicator {
    width: 16px;
    height: 16px;
    background: url("../assets/icons/icon-calendar.svg") no-repeat center / 16px 16px;
    cursor: pointer;
}

.input[type="time"]::-webkit-calendar-picker-indicator {
    display: none;
}

/* Field with its unit inside, on the right («€»); the value is right-aligned before the unit. */
.input-unit {
    position: relative;
}

.input-unit__input {
    text-align: right;
    padding-right: var(--token-space-6);
}

.input-unit__unit {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-medium);
    color: var(--font-color-input-placeholder);
    position: absolute;
    top: 50%;
    right: var(--token-space-2);
    transform: translateY(-50%);
    pointer-events: none;
}

/* Show / hide password (shared/js/password-toggle.js): eye inside the field, at its right edge. Login,
   registration, «Mis datos» of the producer (24px eye, 16px from the edge) and the user form of the admin. */
.password-field {
    position: relative;
}

.password-field .input {
    padding-right: var(--token-space-7);
}

.password-field__toggle {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    right: var(--token-space-3);
    transform: translateY(-50%);
    cursor: pointer;
}

.password-field__toggle:focus-visible {
    outline: 2px solid var(--border-input-focus);
    outline-offset: 2px;
}

/* 40px fields of the admin rows: 8px from the edge, as the text padding. */
.label-input-box .password-field .input {
    padding-right: var(--token-space-6);
}

.label-input-box .password-field__toggle {
    right: var(--token-space-2);
}

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

.field-error {
    font-size: var(--token-font-size-xs);
    color: var(--font-color-error);
    width: max-content;
    max-width: 400px;
    grid-column: 2;
    margin-top: var(--token-space-1);
}

.form-error {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-semibold);
    color: var(--font-color-error);
}

/* =========================================================
   Choices.js (overrides of choices.min.css)
   ========================================================= */

.label-input-box .choices {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-medium);
    margin-bottom: 0;
}

.label-input-box .choices__inner {
    font-size: var(--token-font-size-xs);
    min-height: 40px;
    color: var(--font-color-form);
    background-color: var(--background-input);
    border: 1px solid var(--border-input);
    border-radius: var(--token-radius-m);
    padding: 0 var(--token-space-2);
    display: flex;
    align-items: center;
}

/* choices.min.css adds 7.5px at the bottom of single selects, which pushes the text up. */
.label-input-box .choices[data-type*="select-one"] .choices__inner {
    padding-bottom: 0;
}

.label-input-box .choices.is-focused .choices__inner,
.label-input-box .choices.is-open .choices__inner {
    border-color: var(--border-input-focus);
    border-radius: var(--token-radius-m);
}

.label-input-box .choices.is-disabled .choices__inner {
    background-color: var(--background-input-readonly);
}

.label-input-box .choices.input--error .choices__inner {
    border-color: var(--border-input-error);
}

.label-input-box .choices__list--single {
    padding: 0 var(--token-space-5) 0 0;
}

/* Chevron of Figma (down-small) instead of the Choices.js triangle. */
.label-input-box .choices[data-type*="select-one"]::after {
    width: 15px;
    height: 15px;
    background: url("../assets/icons/icon-chevron-down.svg") no-repeat center / 15px 15px;
    border: none;
    margin: 0;
    transform: translateY(-50%) rotate(90deg);
    right: var(--token-space-2);
    top: 50%;
}

.label-input-box .choices[data-type*="select-one"].is-open::after {
    margin: 0;
    transform: translateY(-50%) rotate(-90deg);
}

.label-input-box .choices__list--dropdown {
    font-size: var(--token-font-size-xs);
    border-color: var(--border-input);
    z-index: 10;
}

/* From 640px, choices.min.css keeps 100px on the right of each option for its «Press to select» text (empty in
   form.js) and breaks words at any letter: in a 171px field (Estado, Provincia) the options came out cut in the
   middle of a word (first test round, 28/10/2026). Same padding on both sides, words kept whole. */
.choices__list--dropdown .choices__item--selectable {
    padding-right: 10px;
}

.choices__list--dropdown {
    word-break: normal;
    overflow-wrap: break-word;
}

/* The open list as wide as its longest option, never narrower than the field. */
.label-input-box .choices.is-open .choices__list--dropdown {
    width: max-content;
    min-width: 100%;
    max-width: 400px;
}

.label-input-box .choices__list--dropdown .choices__item {
    font-size: var(--token-font-size-xs);
}

/* Search box of the long selects (producers, provinces). */
.label-input-box .choices__input {
    font-size: var(--token-font-size-xs);
    background-color: var(--background-input);
}

/* =========================================================
   Status badge (colors of the status catalog, set by the page as --status-color and
   --status-background on the row)
   ========================================================= */

.form-status .choices__list--single .choices__item {
    font-weight: var(--token-font-weight-bold);
    letter-spacing: -0.12px;
    color: var(--status-color, var(--font-color-form));
    background-color: var(--status-background, transparent);
    border-radius: var(--token-radius-s);
    padding: var(--token-space-1);
}

/* =========================================================
   Radio buttons and checkboxes of forms (16px, Figma «Checkbox»)
   The 20px radio of the modals is in main.css.
   ========================================================= */

.radio--small,
.checkbox {
    font-size: var(--token-font-size-xs);
    font-weight: var(--token-font-weight-medium);
    line-height: 21px;
    color: var(--font-color-form);
}

.radio--small .radio__input {
    width: 16px;
    height: 16px;
    background-color: var(--background-choice);
    border-color: var(--border-input);
}

.radio--small .radio__input:checked {
    background-image: url("../assets/icons/icon-radio-checked-small.svg");
    background-size: 17px 17px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    /* 7px in Figma, rounded to the 8px grid. */
    gap: var(--token-space-2);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox__input {
    width: 16px;
    height: 16px;
    background-color: var(--background-choice);
    border: 1px solid var(--border-input);
    border-radius: 2px;
    margin: 0;
    flex-shrink: 0;
    appearance: none;
    cursor: pointer;
}

/* Checked state of Figma: 17px drawing on the 16px box. */
.checkbox__input:checked {
    background: url("../assets/icons/icon-checkbox-checked.svg") center / 17px 17px no-repeat;
    border-color: transparent;
}

.checkbox__input:focus-visible {
    outline: 2px solid var(--border-radio-focus);
    outline-offset: 2px;
}

.radio__input.input--error,
.checkbox__input.input--error {
    border-color: var(--border-input-error);
}

.radio__input:disabled,
.checkbox__input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* =========================================================
   Actions (Cancelar <record> on the left, Cancelar and Guardar on the right)
   ========================================================= */

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--token-space-3);
}

.form-actions__buttons {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.form-actions__error {
    text-align: right;
}

/* Why the action on the left is disabled: 8px under it instead of the 24px gap of .form-card__body. */
.form-actions__notice {
    font-size: var(--token-font-size-xs);
    font-style: italic;
    color: var(--font-color-form-description);
    margin-top: calc(var(--token-space-2) - var(--token-space-6));
}
