/* ==========================================================================
   Form controls
   ==========================================================================
   Input, select, textarea, field label and the two-step progress indicator.
   Shared by Contact and Estimation, so the two forms cannot drift.

   Ported from ui/input.tsx, ui/select.tsx and site/form-steps.tsx.
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field__label {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-weight: var(--text-label-weight);
  color: var(--foreground);
}

.field__required { color: var(--destructive); }

.field__hint {
  margin-top: 0.375rem;
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-weight: var(--text-caption-weight);
  color: var(--subtle-foreground);
}

/* -------------------------------------------------------------------------- */
.input,
.select {
  display: flex;
  height: 2.75rem;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--surface);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input { padding-inline: 0.875rem; }

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

.input:focus-visible,
.select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 30%, transparent);
}

.input:disabled,
.select:disabled { cursor: not-allowed; opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
  .input, .select { transition: none; }
}

/* --------------------------------------------------------------------------
   Select. The native picker stays, so keyboard, screen readers and the mobile
   sheet all keep working. Only the closed control is restyled: same box as
   .input, our chevron instead of the system one, and a placeholder tone while
   the empty option is selected.

   That last part matters. A bare select paints its empty option like a chosen
   value, which reads as a filled field the visitor has already answered.
   -------------------------------------------------------------------------- */
.select-wrap { position: relative; display: block; width: 100%; }

.select {
  appearance: none;
  padding-left: 0.875rem;
  padding-right: 2.5rem;
}

.select[data-placeholder] { color: var(--subtle-foreground); }

.select-wrap svg {
  pointer-events: none;
  position: absolute;
  right: 0.875rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--subtle-foreground);
}

/* --------------------------------------------------------------------------
   Textarea with an attached file row. Description and attachment are one
   field: a brief is a brief, whether it is typed or dropped in as a PDF.
   -------------------------------------------------------------------------- */
.textarea-group {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.textarea-group:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 30%, transparent);
}

/* The group carries the border; the field inside must not repeat it, and it
   sits as a block so no baseline gap opens above the file row. */
.textarea-group textarea {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  resize: none;
  background-color: transparent;
  padding: 0.625rem 0.875rem 0;
  font-size: var(--text-body-size);
  line-height: 1.5rem;
  color: var(--foreground);
  outline: none;
}

.textarea-group textarea::placeholder { color: var(--subtle-foreground); }

.textarea-group__foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  padding: 0.375rem 0.5rem;
}

.file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
              overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.file-label {
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius-md);
  padding: 0.375rem 0.625rem;
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-weight: var(--text-label-weight);
  color: var(--muted-foreground);
  transition: background-color 150ms ease, color 150ms ease;
}

.file-label:hover { background-color: var(--background-subtle); color: var(--foreground); }
.file-input:focus-visible + .file-label { outline: 2px solid var(--ring); outline-offset: 2px; }
.file-label svg { width: 1rem; height: 1rem; }

.file-hint,
.file-name {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-weight: var(--text-caption-weight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-hint { color: var(--subtle-foreground); }
.file-chosen { display: flex; min-width: 0; align-items: center; gap: 0.375rem; }
.file-name { color: var(--foreground); }

.file-remove {
  display: flex;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--subtle-foreground);
}

.file-remove:hover { color: var(--destructive); }
.file-remove svg { width: 0.875rem; height: 0.875rem; }

@media (prefers-reduced-motion: reduce) {
  .textarea-group, .file-label { transition: none; }
}

/* --------------------------------------------------------------------------
   Two-step progress. Numbered, with the rule between them carrying the
   distance. Ported from form-steps.tsx.
   -------------------------------------------------------------------------- */
.form-steps { display: flex; align-items: center; gap: 0.75rem; }

.form-steps li { display: flex; align-items: center; gap: 0.75rem; }
.form-steps li:first-child { flex: 1; }

.form-steps__n {
  display: flex;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-weight: var(--text-label-weight);
  background-color: var(--background-muted);
  color: var(--subtle-foreground);
  transition: background-color 150ms ease, color 150ms ease;
}

.form-steps__n svg { width: 1rem; height: 1rem; }

.form-steps li[data-state="current"] .form-steps__n {
  background-color: var(--brand);
  color: #ffffff;
}

.form-steps li[data-state="done"] .form-steps__n {
  background-color: var(--brand-subtle);
  color: var(--brand);
}

/* Dark variant, for the estimate dialog on ink. */
.form-steps--dark .form-steps__n {
  background-color: color-mix(in oklab, #ffffff 10%, transparent);
  color: color-mix(in oklab, #ffffff 60%, transparent);
}

.form-steps--dark li[data-state="done"] .form-steps__n {
  background-color: color-mix(in oklab, var(--color-blue-300) 15%, transparent);
  color: var(--color-blue-300);
}

.form-steps__rule { height: 1px; flex: 1; background-color: var(--border); }
.form-steps--dark .form-steps__rule { background-color: color-mix(in oklab, #ffffff 15%, transparent); }

/* Only the current step's glyph shows a number or a tick, never both. */
.form-steps__n .form-steps__tick { display: none; }
.form-steps li[data-state="done"] .form-steps__tick { display: block; }
.form-steps li[data-state="done"] .form-steps__digit { display: none; }

@media (prefers-reduced-motion: reduce) {
  .form-steps__n { transition: none; }
}
