/**
 * SENVIQ Design System — form primitives: Input, Textarea, Select,
 * Checkbox, Radio, Switch, FormField, FieldHelp, ValidationMessage,
 * SearchField. Every control here expects to be used with a real
 * `<label for>` — this file styles the control, it never substitutes
 * for the label markup itself (Prompt 43's "do not rely on
 * placeholder text as the only label" rule).
 */

.senviq-field {
  display: flex;
  flex-direction: column;
  gap: var(--senviq-space-2);
  margin-bottom: var(--senviq-space-4);
}

.senviq-field__label {
  font-size: var(--senviq-fs-label);
  font-weight: var(--senviq-fw-medium);
  color: var(--senviq-navy);
}

.senviq-field__label .senviq-field__required {
  color: var(--senviq-danger);
  margin-left: var(--senviq-space-1);
}

.senviq-field__help {
  font-size: var(--senviq-fs-small);
  color: var(--senviq-muted);
}

/**
 * ValidationMessage — pair with `aria-invalid="true"` and
 * `aria-describedby="<id-of-this-element>"` on the control itself
 * (PX-GATE-09 in PRODUCT_EXPERIENCE_GATES.md names this exact gap as a
 * currently-failing, not-yet-built pattern anywhere in the product —
 * this is the primitive that closes it once a future prompt wires it
 * up). `role="alert"` so assistive tech announces a NEW validation
 * error without the user needing to navigate to it.
 */
.senviq-field__validation {
  font-size: var(--senviq-fs-small);
  color: var(--senviq-danger);
  display: flex;
  align-items: center;
  gap: var(--senviq-space-1);
}
.senviq-field__validation::before {
  content: '✕';
  font-weight: var(--senviq-fw-bold);
}

.senviq-input,
.senviq-textarea,
.senviq-select {
  font-family: inherit;
  font-size: var(--senviq-fs-body);
  color: var(--senviq-navy);
  background: var(--senviq-white);
  border: 1px solid var(--senviq-border-strong);
  border-radius: var(--senviq-radius-sm);
  padding: 0.6rem 0.75rem;
  min-height: 40px;
  width: 100%;
  transition: border-color var(--senviq-duration-fast) var(--senviq-easing-standard),
    box-shadow var(--senviq-duration-fast) var(--senviq-easing-standard);
}
.senviq-textarea {
  min-height: 96px;
  resize: vertical;
}

.senviq-input::placeholder,
.senviq-textarea::placeholder {
  color: var(--senviq-disabled);
}

.senviq-input:hover,
.senviq-textarea:hover,
.senviq-select:hover {
  border-color: var(--senviq-muted);
}

.senviq-input:focus-visible,
.senviq-textarea:focus-visible,
.senviq-select:focus-visible {
  outline: none;
  border-color: var(--senviq-blue);
  box-shadow: 0 0 0 3px var(--senviq-blue-tint);
}

.senviq-input[aria-invalid='true'],
.senviq-textarea[aria-invalid='true'],
.senviq-select[aria-invalid='true'] {
  border-color: var(--senviq-danger);
}
.senviq-input[aria-invalid='true']:focus-visible,
.senviq-textarea[aria-invalid='true']:focus-visible,
.senviq-select[aria-invalid='true']:focus-visible {
  box-shadow: 0 0 0 3px var(--senviq-danger-bg);
}

.senviq-input:disabled,
.senviq-textarea:disabled,
.senviq-select:disabled {
  background: var(--senviq-bg);
  color: var(--senviq-disabled);
  cursor: not-allowed;
}

/* ---- SearchField — an input with a leading icon slot ---- */
.senviq-search-field {
  position: relative;
  display: flex;
  align-items: center;
}
.senviq-search-field .senviq-input {
  padding-left: 2.5rem;
}
.senviq-search-field__icon {
  position: absolute;
  left: 0.75rem;
  color: var(--senviq-muted);
  pointer-events: none;
  display: flex;
}

/* ---- Checkbox / Radio ---- */
.senviq-checkbox,
.senviq-radio {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--senviq-space-2);
  font-size: var(--senviq-fs-body);
  color: var(--senviq-navy);
  cursor: pointer;
}
.senviq-checkbox input,
.senviq-radio input {
  /* Native control kept (not visually replaced) — real, always-correct
     keyboard/AT behavior beats a custom-styled reimplementation for a
     control this fundamental. Sizing only. */
  width: 18px;
  height: 18px;
  margin-top: 0.1rem;
  accent-color: var(--senviq-blue);
  flex-shrink: 0;
}
.senviq-checkbox input:disabled + span,
.senviq-radio input:disabled + span {
  color: var(--senviq-disabled);
}

/* ---- Switch ---- */
.senviq-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--senviq-space-2);
  cursor: pointer;
}
.senviq-switch input {
  /* Visually hidden but present for real keyboard/AT operation — the track/thumb below are purely decorative, driven by :checked. */
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 24px;
  margin: 0;
  cursor: pointer;
}
.senviq-switch__track {
  width: 44px;
  height: 24px;
  border-radius: var(--senviq-radius-pill);
  background: var(--senviq-border-strong);
  position: relative;
  transition: background-color var(--senviq-duration-base) var(--senviq-easing-standard);
  flex-shrink: 0;
}
.senviq-switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--senviq-white);
  box-shadow: var(--senviq-shadow-sm);
  transition: transform var(--senviq-duration-base) var(--senviq-easing-standard);
}
.senviq-switch input:checked + .senviq-switch__track {
  background: var(--senviq-blue);
}
.senviq-switch input:checked + .senviq-switch__track::after {
  transform: translateX(20px);
}
.senviq-switch input:focus-visible + .senviq-switch__track {
  outline: 2px solid var(--senviq-focus-ring);
  outline-offset: var(--senviq-focus-ring-offset);
}
