/*
 * Form fields.
 *
 * .jsds-field          Figma component "Field" (node 1:58): label, 48px
 *                      input, optional helper. Border border/field 1.5px,
 *                      no radius.
 * .jsds-field--l       Larger input used inside the quote card (Figma
 *                      "Quote form · 2 steps", node 360:20): 17px text,
 *                      14px side padding, 6px label gap.
 * .jsds-choice         Yes/No segmented choice from the quote card.
 * .jsds-note           Amber "honest price" note from the quote card.
 *
 * Focus and error states are not designed in Figma; the ones below are
 * assumptions kept inside the palette and the WCAG contrast rules.
 */

.jsds-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 0;
}

.jsds-field__label {
  display: block;
  margin: 0;
  padding: 0;
  font: 600 14px/1.3 var(--jsds-font-body);
  color: var(--jsds-ink-900);
}

.jsds-field__help {
  margin: 0;
  font: 400 13px/1.45 var(--jsds-font-body);
  color: var(--jsds-ink-500);
}

/* Input, select, textarea */
.jsds-field input.jsds-input,
.jsds-field select.jsds-input,
.jsds-field textarea.jsds-input,
input.jsds-input,
select.jsds-input,
textarea.jsds-input {
  display: block;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 16px;
  border: 1.5px solid var(--jsds-border-field);
  border-radius: 0;
  box-shadow: none;
  background-color: var(--jsds-surface-white);
  color: var(--jsds-ink-900);
  font: 400 16px/1.5 var(--jsds-font-body);
  -webkit-appearance: none;
  appearance: none;
}

textarea.jsds-input {
  height: auto;
  min-height: 120px;
  padding-top: 12px;
  padding-bottom: 12px;
  resize: vertical;
}

input.jsds-input::placeholder,
textarea.jsds-input::placeholder {
  color: var(--jsds-ink-400);
  opacity: 1;
}

.jsds-field select.jsds-input,
select.jsds-input {
  padding-right: 44px;
  background-image: url("../../icons/chevron-down.svg");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 13.4142px 8.12132px; /* the SVG's own size */
  cursor: pointer;
}

/* Placeholder option shown in muted ink, like the Figma "Select type" */
select.jsds-input:invalid,
select.jsds-input.is-placeholder {
  color: var(--jsds-ink-400);
}

input.jsds-input:focus,
select.jsds-input:focus,
textarea.jsds-input:focus {
  outline: none;
  border-color: var(--jsds-ink-900);
  box-shadow: 0 0 0 1px var(--jsds-ink-900);
}

.jsds-input[aria-invalid="true"],
.jsds-field.is-error .jsds-input {
  border-color: var(--jsds-brand-red);
}

.jsds-field.is-error .jsds-field__help {
  color: var(--jsds-brand-red);
}

/* Large variant (quote card) */
.jsds-field.jsds-field--l {
  gap: 6px;
}

.jsds-field--l input.jsds-input,
.jsds-field--l select.jsds-input {
  height: auto;
  padding: 13px 14px;
  font-size: 17px;
}

.jsds-field--l select.jsds-input {
  padding-right: 42px;
}

/* Two fields side by side (Make / Model) */
.jsds-field-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.jsds-field-row > * {
  flex: 1 1 0;
  min-width: 0;
}

/* ---------- Yes/No choice ---------- */

.jsds-choice {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.jsds-choice__legend {
  float: left; /* lets a legend sit inside the flex column */
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  border: 0; /* Bootstrap 3 draws a rule under legends */
  font: 600 14px/1.3 var(--jsds-font-body);
  color: var(--jsds-ink-900);
}

.jsds-choice__options {
  display: flex;
  clear: both;
  width: 100%;
}

.jsds-choice .jsds-field__help {
  margin-top: 6px;
}

.jsds-choice__option {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}

.jsds-choice__option + .jsds-choice__option {
  margin-left: -1.5px; /* share the middle border */
}

.jsds-choice__option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.jsds-choice__option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border: 1.5px solid var(--jsds-border-field);
  background: var(--jsds-surface-white);
  font: 600 14px/1.3 var(--jsds-font-body);
  /* Figma renders unselected labels grey even though the layer is bound to
     ink/900; matching the render with ink/500. */
  color: var(--jsds-ink-500);
}

.jsds-choice__option input:checked + span {
  position: relative;
  z-index: 1;
  border-color: var(--jsds-ink-900);
  background: var(--jsds-ink-900);
  color: var(--jsds-surface-white);
}

.jsds-choice__option input:focus-visible + span {
  position: relative;
  z-index: 2;
  outline: var(--jsds-focus-ring);
  outline-offset: 2px;
}

/* ---------- Note ---------- */

.jsds-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--jsds-border-warm);
  background: var(--jsds-surface-amber-tint);
  color: var(--jsds-accent-amber-ink);
  font: 400 15px/1.5 var(--jsds-font-body);
}
