/* Form primitives: field group, label, input, validation state, error text. */

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.field-label .required {
  color: var(--bad);
}

.field {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: 15px;
  width: 100%;
}

.field:focus {
  border-color: var(--accent);
}

/*
 * :user-invalid / :user-valid (Baseline 2023): validation styling only after
 * the person has interacted with the field, no JS. Colour is never the only
 * signal (SC 3.3.1) — the field-error text below carries the same message.
 */
.field:user-invalid {
  border-color: var(--bad);
}

.field:user-valid {
  border-color: var(--good);
}

.field-error {
  font-size: 13px;
  color: var(--bad);
}

.field-hint {
  font-size: 13px;
  color: var(--ink-3);
}

/*
 * Form errors, three layers and never colour alone (SC 3.3.1): a summary at the top whose items link
 * to the fields (`<div class="error-summary" data-error-summary tabindex="-1">`, focused by
 * /static/js/error-summary.js), the sentence beside each field, and aria-invalid on the field. The
 * word "Erro:" stays visible. Moved here from licenciados.css/meus-dados.css when a third screen
 * (produtos/form.html, produtos/confirmar.html) needed it. The gap below the summary is each
 * page's own (a flex column already has one).
 */
.error-summary {
  background: color-mix(in srgb, var(--bad) 7%, var(--surface));
  border: 1px solid var(--bad);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.error-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.error-summary-title {
  font-size: 16px;
  color: var(--bad);
}

.error-summary ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  font-size: 14px;
}

.error-summary a {
  color: var(--ink);
}

.field-error-label {
  font-weight: 600;
}

.field[aria-invalid="true"] {
  border-color: var(--bad);
}

form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* One checkbox or radio with its whole sentence beside it. */
.choice {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}

.choice b {
  color: var(--ink);
}

.choice:has(input:checked) {
  color: var(--ink);
}

.choice input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A short list of clients to pick from: name · document, and the action on the right. */
.client-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.client-picker-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.client-picker-list li form {
  gap: 0;
}

.client-picker-list__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* The line under a search box: how many came back, or what to type. */
.search-count {
  font-size: 13px;
  color: var(--ink-3);
  margin: 0;
}

.search-hint {
  font-size: 13px;
  color: var(--ink-3);
}
