/**
 * Field - Form field wrapper styles
 * @countermeasure/web-components/primitives/field
 */

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

.cmm-field__label {
  display: inline-block;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: hsl(var(--foreground));
}

.cmm-field__required {
  color: var(--color-error-text);
  margin-left: 0.25rem;
}

.cmm-field__content {
  /* Slot for consumer-provided input elements */
}

/*
 * When the field wraps multiple inline controls (checkboxes/switches) directly,
 * they are inline-flex labels mounted without whitespace between them, so they
 * collapse against each other. Lay them out as a wrapping row with a uniform
 * horizontal gap so every item is evenly spaced. Single-input fields (Input,
 * Select, RadioGroup, CheckboxGroup) are untouched — they don't match this rule.
 */
.cmm-field__content:has(> .cmm-checkbox, > .cmm-switch) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.5rem;
}

.cmm-field__hint {
  font-size: 0.75rem;
  line-height: 1rem;
  color: hsl(var(--foreground) / 0.78);
}

.cmm-field__error {
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--color-error-text);
}

.cmm-field__hint:empty,
.cmm-field__error:empty {
  display: none;
}

.cmm-field--error .cmm-field__label {
  color: var(--color-error-text);
}
