/* Form building blocks for every layout: field, input, select, choices, checkbox row, inline forms.
   Inputs and selects share one look (edge, height, focus ring). Reference: /styleguide. */

/* ---------- Field: label, control, hint, error ---------- */
.form-field,
.field { display: flex; flex-direction: column; gap: var(--space-6); }

.form-field__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-12); }

.form-field__label,
.field__label { font-size: var(--text-md); font-weight: 500; color: var(--ink); }

/* 44px tap target without pushing the label row apart. */
.form-field__aside { display: inline-flex; align-items: center; min-height: 44px; margin-block: -12px; font-size: var(--text-md); font-weight: 500; } /* ds-keep: -12px offsets the 44px target */
.form-field__hint { font-size: var(--text-md); color: var(--text-muted); }
.form-field__error { font-size: var(--text-md); color: var(--error-field); }
.form-field__error:not([hidden]) { display: flex; align-items: flex-start; gap: var(--space-6); font-weight: 500; }

.form-field__error:not([hidden])::before {
  content: "!";
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-top: 1px; /* ds-keep: optical alignment with the first line */
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--white);
  background: var(--error-field);
  border-radius: 50%;
}

.form-field__error:empty::before { content: none; }

/* ---------- Text inputs and selects ---------- */
.input,
.field__select {
  width: 100%;
  min-height: var(--control-lg);
  padding: 0 var(--space-16);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--ink);
  background-color: var(--white);
  border: var(--border-control) solid var(--line-input);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.input::placeholder { color: var(--placeholder); }

.input:hover:not(:focus, :disabled),
.field__select:hover:not(:focus, :disabled) { border-color: var(--text-muted); }

.input:focus,
.field__select:focus { border-color: var(--purple); box-shadow: var(--shadow-focus); }

.input:disabled,
.field__select:disabled { color: var(--text-muted); background-color: var(--canvas); cursor: not-allowed; }

/* The chevron is an inline SVG; its stroke is --ink (#2D2A4A), since url() cannot read custom properties. */
.field__select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px; /* ds-keep: room for the chevron */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232D2A4A' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}

.input--invalid,
.input--invalid:hover:not(:focus) { border-color: var(--error-field); }
.input--invalid:focus { border-color: var(--error-field); box-shadow: 0 0 0 4px var(--error-bg); }

.input--area { min-height: 120px; padding-top: var(--space-12); padding-bottom: var(--space-12); line-height: var(--leading-normal); resize: vertical; }
.input--with-toggle { padding-right: 84px; } /* ds-keep: room for the show/hide button */

/* ---------- Radio choices as cards ---------- */
.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  border: 0;
}

.choices legend { margin-bottom: var(--space-8); padding: 0; }
.choices--inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.choices--inline > .form-field__label { grid-column: 1 / -1; }

.choice {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  min-height: var(--control-lg);
  padding: var(--space-10) var(--space-16);
  font-size: var(--text-lg);
  color: var(--ink);
  background: var(--white);
  border: var(--border-control) solid var(--line-lilac);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.choice:hover { border-color: var(--lilac-soft); }
.choice:has(.choice__input:checked) { border-color: var(--purple); box-shadow: var(--shadow-focus); }
.choice__input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--purple); }

/* ---------- A checkbox with its label (.admin-check is the older name) ---------- */
.checkbox-row,
.admin-check { display: flex; align-items: flex-start; gap: var(--space-10); font-size: var(--text-base); line-height: var(--leading-normal); }

.checkbox-row input,
.admin-check input { flex: none; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--purple); } /* ds-keep: optical alignment */

/* ---------- Layouts for fields ---------- */
.form-row { display: grid; gap: var(--space-16); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

/* Fields and a button on one line; wraps on narrow screens. */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-10); }
.inline-form .form-field { flex: 1 1 192px; margin: 0; }
