/* ============================================================================
   Forms
   ----------------------------------------------------------------------------
   The app's forms are `.field`-wrapped label/field pairs. These rules give
   them comfortable rhythm, plus the .required-marker primitive used in the
   views.
   ============================================================================ */

@layer components {
  /* Default vertical rhythm for stacked fields. */
  .field { margin-bottom: var(--space-4); }

  form label { display: inline-block; margin-bottom: var(--space-1); }
  .field > label,
  .field > input:not([type="checkbox"]):not([type="radio"]),
  .field > textarea,
  .field > select { display: block; }

  /* A label that sits beside its control (checkbox / inline select). */
  form label > input[type="checkbox"],
  form label > input[type="radio"] { margin-right: var(--space-1); }

  .required-marker { color: var(--danger-text); font-weight: 500; }

  /* The click-to-add competitor suggestions under the competitors box: the
     lead-in line, then the suggestion buttons wrapping beside it. */
  .competitor-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    margin-top: var(--space-2);
  }
  .competitor-suggestions > .muted { flex-basis: 100%; }

  .form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    /* The row carries its own clearance so it never sits flush against
       neighbors without margins of their own (the invitation fields grid
       before it, the invite hint after it). Against a .field the top margins
       collapse into the same one step, and .card-body's :last-child rule
       zeroes the bottom when the actions end the form. */
    margin: var(--space-4) 0;
  }

  /* Explicit-Save controls stay disabled until their form has unsaved changes;
     the adjacent live text makes that state perceivable beyond color. */
  .save-state { margin: 0; color: var(--text-secondary); font-size: 11.5px; }

  .invitation-form-fields {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, auto);
    gap: var(--space-3);
  }
  .invitation-form-fields .field { margin-bottom: 0; }
  .invitation-form-fields input,
  .invitation-form-fields select { width: 100%; }

  @media (max-width: 560px) {
    .invitation-form-fields { grid-template-columns: 1fr; }
  }

  /* The per-row role editor in the team table: the select and its Save sit on
     one line, wrapping rather than widening the column on narrow screens. */
  .role-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }
  /* Why the sole owner's row has no editor, on its own line under the role. */
  .role-note { display: block; margin-top: var(--space-1); }

  /* Help text that follows an input (e.g. "One domain per line"). */
  form .muted { display: inline-block; margin-top: var(--space-1); }

  /* The credit price quoted under a button that starts a paid AI run (the
     AI job cards and their failure retries). */
  .credit-cost-note { margin: var(--space-1) 0 0; }

  /* A form's lead-in paragraph (the project form explains how the brand
     details steer prompt generation and answer judging). */
  .form-intro { margin: 0 0 var(--space-4); max-width: 68ch; }

  /* On narrow screens the fixed-size fields (size= / cols=) turn fluid instead
     of clamping at max-width with a ragged right edge. Scoped to `.field` so
     inline controls (nav switcher, fieldset selects) keep their intrinsic
     width. */
  @media (max-width: 480px) {
    .field input[type="text"],
    .field input[type="email"],
    .field input[type="password"],
    .field input[type="search"],
    .field input[type="url"],
    .field input[type="number"],
    .field textarea,
    .field select { width: 100%; }
  }
}
