/* ============================================================
   Workflow Template Builder (admin) page, built from design-system
   components. This sheet only places them: the cards are panes, the lists
   are data tables or rows, the fields and buttons are components, and every
   rule hangs on the page's domain-concept class.
   ============================================================ */

@layer layout {
  .admin-workflows { display: grid; gap: var(--t-space-5); align-content: start; }

  /* Page / view intro: the title block takes the room the actions leave, so a
     long explanatory line wraps beside them. */
  .admin-workflows .intro {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    justify-content: space-between; gap: var(--t-space-3);
  }
  .admin-workflows .intro-copy {
    display: grid; gap: var(--t-space-1); min-inline-size: 0; flex: 1 1 20rem;
  }
  .admin-workflows .actions {
    display: flex; flex-wrap: wrap; gap: var(--t-space-2);
    flex-shrink: 0; max-inline-size: 100%;
  }

  /* Two fields per row as width allows, the base's field grid. The fields
     sit on the row's foot, so a label that wraps to two lines never pushes
     its box below its neighbour's. */
  .admin-workflows .field-row {
    display: grid; gap: var(--t-space-3); align-items: end;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  }

  .admin-workflows .settings-form { display: grid; gap: var(--t-space-4); }

  /* Every submit in the page's forms sits at its own width at the start, as
     the base drew them. */
  .admin-workflows .settings-form > :is(button, .button) { justify-self: start; }

  /* Actions in a pane header, a table row and a list row. */
  .admin-workflows .panel-actions,
  .admin-workflows .row-actions {
    display: flex; flex-wrap: wrap; gap: var(--t-space-2);
  }

  /* A flush pane's empty state and its sub-forms keep the card's padding. */
  .admin-workflows .pane-empty { padding: var(--t-space-4) var(--t-space-5); }

  /* The steps table and the add-step form share one wrapper inside the pane.
     It may shrink below the table's width, so the table scrolls in its own
     region and the form's fields stay inside the pane on a phone. */
  .admin-workflows .steps-body { min-inline-size: 0; }
  .admin-workflows .panel-pad {
    display: grid; gap: var(--t-space-4);
    padding: var(--t-space-4) var(--t-space-5) var(--t-space-5);
  }

  /* A legend is not a grid item, so the fieldset's gap never reaches below it;
     it carries its own space down to the step choices. */
  .admin-workflows fieldset.field > legend { margin-block-end: var(--t-space-2); }

  .admin-workflows .step-choices { display: grid; gap: var(--t-space-2); }

  /* The phase list and the Add Phase form under it keep a pane's gap. */
  .admin-workflows .phases-body { display: grid; gap: var(--t-space-5); }

  /* Phase cards stack, one per row. */
  .admin-workflows .phase-list {
    display: grid; gap: var(--t-space-3);
    margin: 0; padding: 0; list-style: none;
  }
  .admin-workflows .phase-description { margin: 0; font-size: var(--t-font-size-sm); }

  /* Sanctions and rewards stand side by side on a desk. */
  .admin-workflows .response-groups {
    display: grid; gap: var(--t-space-4);
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }
  .admin-workflows .response-group {
    display: grid; gap: var(--t-space-3); align-content: start; min-inline-size: 0;
  }
}
