/* ==========================================================================
   SOURCE: form-sections-flow.css
   ========================================================================== */
/* ============================================================
   FORM BUILDER + PUBLISHED FORM
   SECTION PAGES, INDEPENDENT SCROLLING, CONDITIONAL FLOW
   Load after form-builder.css and published-form.css.
   ============================================================ */

/* ============================================================
   BUILDER - THREE INDEPENDENT SCROLL REGIONS
   ============================================================ */

.form-builder-shell {
  height: calc(100dvh - 130px);
  min-height: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

.form-builder-workspace {
  flex: 1 1 auto;

  min-height: 0;
  height: auto;

  overflow: hidden;
}

.form-builder-palette,
.form-builder-canvas,
.form-builder-properties {
  min-height: 0;
  height: 100%;

  overflow-y: auto;
  overscroll-behavior: contain;

  scrollbar-gutter: stable;
}

.form-builder-palette,
.form-builder-properties {
  scrollbar-width: thin;
}

.form-builder-canvas {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Keep panel headings visible while their own panel scrolls. */

.form-builder-palette > .builder-panel-heading,
.form-builder-properties > .builder-panel-heading {
  position: sticky;
  top: 0;
  z-index: 8;

  background: var(--if-surface, #ffffff);
}

/* ============================================================
   BUILDER - SECTION / NEW PAGE FIELD
   Keep the section element visually consistent with every other
   form element in the canvas.
   ============================================================ */

/*
 * Palette button uses the same surface/border treatment as the
 * rest of the field palette. The icon still identifies it as a
 * page/section element. Border stays transparent at rest, same
 * as every other palette button, and only shows on hover.
 */

.builder-field-button-section:hover {
  border-color: var(--if-secondary);

  background: color-mix(in srgb, var(--if-secondary), white 96%);
}

/*
 * Do not give section elements a separate dashed/gradient card.
 * Let .builder-canvas-field supply the same card, toolbar,
 * selected state, and hover treatment used by every other field.
 */

.builder-canvas-field:has(.builder-section-divider-preview) {
  border-style: solid;

  background: var(--if-surface);
}

/*
 * The page distinction lives inside the normal field body instead
 * of changing the entire field container.
 */

.builder-section-divider-preview {
  position: relative;

  display: grid;

  gap: 5px;

  padding: 2px 0;
}

.builder-section-divider-kicker {
  display: inline-flex;
  align-items: center;

  width: fit-content;

  margin: 0 0 2px;

  padding: 3px 7px;

  border-radius: 999px;

  background: var(--if-secondary-soft);

  color: var(--if-secondary);

  font-size: 0.875rem;
  font-weight: 800;

  letter-spacing: 0.06em;

  text-transform: uppercase;
}

.builder-section-divider-preview :is(h1, h2, h3) {
  margin: 0;
  font-weight: 700;

  line-height: 1.35;
}

.builder-section-divider-preview p {
  margin: 0;

  font-size: 0.875rem;

  line-height: 1.45;
}

/*
 * A subtle page-break indicator communicates behavior without
 * making the element look like a different component family.
 */

.builder-section-divider-preview::after {
  content: "New page begins here";

  display: flex;
  align-items: center;

  gap: 8px;

  margin-top: 8px;
  padding-top: 8px;

  border-top: 1px solid var(--if-border);

  color: var(--if-slate-400);

  font-size: 0.75rem;
  font-weight: 650;

  letter-spacing: 0.025em;
}

/* ============================================================
   BUILDER - CONDITIONAL FLOW SETTINGS
   ============================================================ */

.builder-flow-field-list {
  display: grid;

  max-height: 220px;

  overflow-y: auto;

  border: 1px solid var(--if-border);
  border-radius: var(--if-radius-control);

  background: var(--if-surface);
}

.builder-flow-field-option {
  display: flex;
  align-items: center;

  gap: 8px;

  padding: 8px 10px;

  border-bottom: 1px solid var(--if-border);

  color: var(--if-text-strong);

  font-size: 0.875rem;

  cursor: pointer;
}

.builder-flow-field-option:last-child {
  border-bottom: 0;
}

.builder-flow-field-option:hover {
  background: var(--if-secondary-soft);
}

.builder-flow-field-option input {
  margin: 0;

  accent-color: var(--if-secondary);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .form-builder-shell {
    height: auto;

    overflow: visible;
  }

  .form-builder-workspace {
    overflow: visible;
  }

  .form-builder-palette,
  .form-builder-canvas,
  .form-builder-properties {
    height: auto;
    max-height: none;

    overflow: visible;
  }
}
