/**
 * Form layout molecules (r-39 step f5 rest, f5r-b).
 *
 * How the fields in a pop-up are laid out, in edit and view mode alike
 * (ui-design-system.md §13 "Forms"):
 *   .field          one label above one control (edit) or value (view)
 *   .field-label    the label; its type is the .text-label role (typography.css)
 *   .field-label-row  the label with an inline label action after it
 *                   (.btn-label-action, a small icon button; case line cards)
 *   .field-value    a read-only value in view mode
 *   .field-value-multiline  a read-only free-text value (a case's Notes) that keeps
 *                   the line breaks CK typed
 *   .form-grid      two columns; one gap in edit and view mode, so nothing
 *                   shifts when a pop-up enters edit mode (Peter, 2026-09-28)
 *   .form-grid-1    one column: the create forms and a vertical field stack
 *   .span-full      a wide field (Notes, a path, a website)
 *                   across both columns
 *   .section-label  a heading between sections: "Items", "History", ...
 *   .form-row       the inline add-item row: product, qty stepper, note, +
 *   .form-row-grow  the field that takes the row's spare width
 *   .form-list-row  one listed line with its remove button (no app user since
 *                   v0.108.0, when the create forms stopped taking items)
 *   .form-check     a checkbox with its text, as a choice inside a form
 *                   ("Remember me" on the sign-in page, 30 days on this computer)
 * The controls themselves are the field primitives (fields.css); this file
 * only arranges them.
 *
 * @see docs/architecture/ui-design-system.md §13 "Forms"
 * @see docs/architecture/module-map/forms.css.md
 */

/* ── Field ── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

/* Inline label action (ui-design-system.md §17): a small icon on the label's
   own line. Its height never exceeds the label's, and a hidden one keeps its
   place, so showing, hiding or clicking it moves nothing (Peter,
   2026-10-13: no extra rows, no jumping). */
/* A label only a screen reader needs: the field's place names it (r-158: Currency beside ITEMS). */
.field-label-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.field-label-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.field-label-row > .btn-label-action {
  position: relative;
  height: 1em;
  font-size: var(--font-size-xs);
  line-height: 1;
}

/* The icon is label-sized, but its target is 24x24 px (WCAG 2.5.8): an
   invisible area around it takes the click without moving anything. */
.field-label-row > .btn-label-action::before {
  content: '';
  position: absolute;
  inset: calc((1em - 24px) / 2);
}

.field-label-row > .btn-label-action.hidden {
  display: inline-flex;
  visibility: hidden;
}

/* "Use supplier price" (use-supplier-price.js, §17). With a mouse it is
   only the icon, and its tooltip names the price. A touch device can't
   hover, so a first tap asks in a small bubble, "Tap again to use
   8 460 Ft", laid over the card like the lock reason (fields.css), so it
   adds no row and moves nothing (Peter, 2026-10-15: CK uses a tablet). */
.use-supplier-price {
  gap: var(--space-1);
  white-space: nowrap;
}

.use-supplier-price-text {
  display: none;
}

.use-supplier-price.is-armed .use-supplier-price-text {
  display: block;
  position: absolute;
  bottom: calc(100% + var(--space-1));
  right: 0;
  z-index: 20;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-2);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

/* No supplier price: words, not an icon, on every device, so the line never
   looks like one already at its supplier price. Information only, so it
   overrides the faded look of .btn[aria-disabled] (buttons.css), whatever
   the stylesheet order. */
.btn.use-supplier-price[data-state='none'] {
  color: var(--color-text-secondary);
  cursor: default;
  opacity: 1;
}

.btn.btn-inline.use-supplier-price[data-state='none']:hover {
  text-decoration: none;
}

.use-supplier-price[data-state='none'] > .fas {
  display: none;
}

.use-supplier-price[data-state='none'] .use-supplier-price-text {
  display: inline;
  font-weight: var(--font-weight-medium);
}

.field > .input,
.field > .select,
.field > .textarea {
  width: 100%;
}

/* The data in a field stands out from its small, muted uppercase label by
   weight and contrast, in view mode (.field-value) and edit mode (the
   control) alike, so the pop-up doesn't change size between modes (Peter,
   2026-09-29, variant B). Descendant, not child: a control inside a
   .field-suffix wrapper counts too. */
.field .input,
.field .select,
.field .textarea {
  font-size: var(--font-size-field-value);
  font-weight: var(--font-weight-field-value);
}

.field-value {
  font-size: var(--font-size-field-value);
  font-weight: var(--font-weight-field-value);
  color: var(--color-text-primary);
  word-break: break-word;
}

/* Notes are typed in a textarea, so their line breaks carry meaning; the
   read-only view keeps them instead of running the lines together (Peter,
   2026-10-11, r-73 chunk C). A modifier, not the default: other values are
   one line, and pre-line on them would turn template whitespace into breaks. */
.field-value-multiline { white-space: pre-line; }

/* ── Grids ── */
.form-grid,
.form-grid-1 {
  display: grid;
  gap: var(--space-4) var(--space-6);
  align-content: start; /* rows keep their height in a taller box */
}

.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-1 { grid-template-columns: minmax(0, 1fr); }

.span-full { grid-column: 1 / -1; }

/* A grid that follows other content (e.g. Pricing Note / Total under the
   item table) keeps its distance from it. */
* + .form-grid,
* + .form-grid-1 { margin-top: var(--space-5); }
.section-label + .form-grid,
.section-label + .form-grid-1 { margin-top: 0; }

/* A narrow window: two columns would squeeze every field. */
@media (max-width: 40rem) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Section label ── */
.section-label { margin: var(--space-6) 0 var(--space-3); }
.section-label:first-child { margin-top: 0; }

/* ── Add-item row ── */
.form-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0 var(--space-3);
}

.section-label + .form-row { margin-top: 0; }

.form-row-grow {
  flex: 1;
  min-width: 0;
}

.form-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-1) 0;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
}

