/* ============================================================
   CCD BRB Design System — Forms
   ------------------------------------------------------------
   One vocabulary for every form widget. Namespace .f-*.

   Locked rules:
   - 36px row height across input / select / button
   - --fs-body in fields, --fs-small + --fw-semi for labels
   - Ring-only focus (no border-color flip, no custom shadow)
   - .is-error border swap; helper line becomes error line
   - Hover lifts border to --ink-muted (skipped on disabled/error)
   - Switch wrapper is .f-switch-row — never .f-choice (avoids
     checkbox/radio rule bleed-through)
   - Native <select> for forms; reserve custom dropdowns for
     in-app pickers (filter bars, type-aheads)

   Spec: ../DESIGN-SYSTEM.md §9 Forms
   ============================================================ */

/* ── Field wrapper ─────────────────────────────────────── */
.f-field { display: flex; flex-direction: column; gap: var(--s-2); }
.f-field__label { font-size: var(--fs-small); font-weight: var(--fw-semi); color: var(--ink); }
.f-field__help  { font-size: var(--fs-small); color: var(--ink-muted); line-height: var(--lh-normal); }
.f-field__error { font-size: var(--fs-small); color: var(--dot-negative); line-height: var(--lh-normal); }

.f-field.is-disabled,
.f-field:has(.f-control:disabled) { opacity: 0.6; }

/* Required marker — same red as error, intentional industry convention */
.f-req { color: var(--dot-negative); margin-left: 2px; }

/* ── Shared control surface (input, select, textarea) ──── */
.f-control {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--s-3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: var(--lh-snug);
  color: var(--ink);
  box-sizing: border-box;
}
.f-control::placeholder { color: var(--ink-muted); }
.f-control:not(:disabled):not(.is-error):hover { border-color: var(--ink-muted); }
.f-control:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  /* Ring-only — no border-color flip, no custom shadow. */
}
.f-control:disabled {
  background: var(--paper-tint);
  border-style: dashed;
  color: var(--ink-muted);
  pointer-events: none;
  user-select: none;
}
.f-control.is-error { border-color: var(--dot-negative); }

/* Textarea — same surface, vertical padding restored */
textarea.f-control {
  padding: var(--s-2) var(--s-3);
  min-height: 96px;
  resize: vertical;
  line-height: var(--lh-normal);
}

/* Select — same surface + caret. Native <select>: open list is OS-rendered,
   which is fine for one-off picks (Department, Country). For frequent in-app
   pickers, use a custom dropdown component (e.g., .dd-menu in toolkit). */
select.f-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--s-7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23647B9B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 12px;
}

/* ── Choice (checkbox + radio share the wrapper) ───────── */
.f-choice {
  display: flex; align-items: center; gap: var(--s-2);
  cursor: pointer; font-size: var(--fs-body); color: var(--ink);
}
.f-choice + .f-choice { margin-top: var(--s-2); }
.f-choice input {
  appearance: none; -webkit-appearance: none;
  margin: 0; flex-shrink: 0; box-sizing: border-box;
  background: var(--paper); border: 1px solid var(--rule);
  cursor: pointer;
}
.f-choice input:hover { border-color: var(--ink-muted); }
.f-choice input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.f-choice input[type="checkbox"] {
  width: 18px; height: 18px;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
}
.f-choice input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.f-choice input[type="checkbox"]:checked::after {
  content: ""; width: 10px; height: 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5L5 9.5L10 3.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
}

.f-choice input[type="radio"] {
  width: 18px; height: 18px;
  border-radius: var(--r-pill);
}
.f-choice input[type="radio"]:checked {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: inset 0 0 0 3px var(--paper);
}

.f-choice input:disabled { background: var(--paper-tint); border-style: dashed; }
.f-choice:has(input:disabled) { opacity: 0.6; }

/* ── Switch ─ for instant toggles (settings).
   Own wrapper — NOT .f-choice — so checkbox/radio rules don't bleed in. */
.f-switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); cursor: pointer;
  font-size: var(--fs-body); color: var(--ink);
}
.f-switch-row + .f-switch-row { margin-top: var(--s-2); }

.f-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.f-switch input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  appearance: none; -webkit-appearance: none; margin: 0;
  background: var(--rule); border: 0; border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.f-switch input:hover { background: var(--ink-muted); }
.f-switch input:checked { background: var(--brand); }
.f-switch input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}
.f-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--paper); border-radius: var(--r-pill);
  box-shadow: var(--shadow-1); pointer-events: none;
  transition: transform var(--dur-fast) var(--ease);
}
.f-switch:has(input:checked)::after { transform: translateX(16px); }
