/* ===== FORMS: EDITOR OVERLAY (frm-editor.css) ===== */
/* Owned by form-editor.js — the full-screen takeover chrome (top bar + pane
   tab strip + pane mount layout) ONLY. Each pane's own content is styled by
   its own frm-*.css fragment; this file never reaches into a #frmPane-*
   mount's inner markup. Buttons/badges lean on the shared primitives in
   frm-shared.css (.frm-btn / .frm-badge); everything else uses the kanban
   design tokens in index.css, so dark (default) and [data-theme=light] both
   work untouched. */

/* ── overlay shell: hidden until .active, then a "different app" takeover
   sitting above the topnav (z-index:120) and ordinary modals (z-index:200),
   but below toasts/dropdowns (9999/10000) so those still surface inside it ── */
#formEditorOverlay {
  display: none;
}
#formEditorOverlay.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: var(--bg);
}

/* The editor overlay (z-index:5000) sits above ordinary modals (z-index:200)
   and the confirm dialog (z-index:250). Any dialog opened FROM the editor —
   the Settings / Share modals from the top bar, the confirm dialog behind
   delete/unpublish in the builder — must therefore be lifted above it, or it
   opens invisibly behind the takeover. Scoped to the editor being open so the
   normal (editor-closed) stacking is untouched. Loaded last of the frm-*.css,
   so this wins over the panes' own modal z-indexes. */
#formEditorOverlay.active ~ #confirmModal,
#formEditorOverlay.active ~ #formSettingsModal.active,
#formEditorOverlay.active ~ #formShareModal.active {
  z-index: 6000;
}

/* ── top bar ── */
/* Ultrawide (3440-3822px): .frm-ed-title-wrap (flex:1 1 auto) and the
   right-hand actions are the only two content clusters in this row, so an
   uncapped bar leaves the title pinned far left and Saved/Preview/Settings/
   Share/Publish pinned far right with a huge dead gap between — reads as
   broken chrome, not a deliberate layout. Fixed with padding-inline (NOT a
   max-width/margin-inline:auto on the bar itself) so the shell background and
   border-bottom stay full-bleed edge-to-edge — only the padding grows past
   1760px of content, which centers the actual title/actions cluster the same
   way #tab-forms centers everything below it. */
.frm-ed-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding-block: var(--s3);
  padding-inline: max(var(--s5), calc((100% - 1760px) / 2));
  background: var(--shell);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.frm-ed-back {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: var(--r2);
  border: 1px solid var(--border2);
  background: var(--card2);
  color: var(--text2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.frm-ed-back:hover {
  background: var(--card-hover);
  border-color: var(--border3);
  color: var(--text);
}
.frm-ed-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.frm-ed-back .mi,
.frm-ed-back .frm-ico {
  width: 18px;
  height: 18px;
}
.frm-ed-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.frm-ed-name-input {
  flex: 0 1 440px;
  min-width: 120px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r2);
  color: var(--text);
  font-size: var(--fz-xl);
  font-weight: var(--fw-bold);
  font-family: inherit;
  letter-spacing: -0.01em;
  padding: 7px 11px;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.frm-ed-name-input:hover {
  background: var(--card2);
}
.frm-ed-name-input:focus {
  outline: none;
  background: var(--bg2);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
/* status pill (shared .frm-badge, plus a flex hook so the icon sits inline) */
.frm-ed-status {
  flex: 0 0 auto;
}
.frm-ed-save-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fz-xs);
  font-weight: var(--fw-medium);
  color: var(--text3);
  white-space: nowrap;
  min-width: 64px;
  justify-content: flex-end;
  transition: color 0.15s;
}
.frm-ed-save-status .mi,
.frm-ed-save-status .frm-ico {
  width: 13px;
  height: 13px;
}
.frm-ed-save-status .frm-ed-save-spin {
  animation: frmEdSpin 0.9s linear infinite;
}
.frm-ed-save-status.frm-ed-saving {
  color: var(--text2);
}
@keyframes frmEdSpin {
  to {
    transform: rotate(360deg);
  }
}
.frm-ed-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.frm-ed-action-btn {
  white-space: nowrap;
}
.frm-ed-publish-btn {
  min-width: 104px;
}

/* ── pane tab strip (#frmEditorTabs — static markup, buttons decorated with
   an icon + label span by form-editor.js's _decorateTabs) ── */
/* Same padding-inline trick as .frm-ed-topbar above: tabs stay left-packed
   and the bar itself (background/border-bottom) stays full-bleed, but on an
   ultrawide monitor the tab strip is pulled in from the literal screen edge
   so it lines up under the now-centered topbar content instead of starting
   flush left under a title that no longer sits at x:0. */
.frm-ed-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: var(--s1);
  padding-block: 0;
  padding-inline: max(var(--s5), calc((100% - 1760px) / 2));
  background: var(--shell);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.frm-ed-tabs::-webkit-scrollbar {
  display: none;
}
.frm-ed-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  padding: 13px 14px 11px;
  font-size: var(--fz-md);
  font-weight: var(--fw-medium);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.frm-ed-tab .mi,
.frm-ed-tab .frm-ico {
  width: 16px;
  height: 16px;
  opacity: 0.85;
}
.frm-ed-tab:hover {
  color: var(--text);
}
.frm-ed-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--fw-semibold);
}
.frm-ed-tab.active .mi,
.frm-ed-tab.active .frm-ico {
  opacity: 1;
}
.frm-ed-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-radius: var(--r1);
}

/* ── pane body ── */
.frm-ed-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}
.frm-ed-pane {
  display: none;
  height: 100%;
}
.frm-ed-pane.active {
  display: block;
}

@media (max-width: 720px) {
  .frm-ed-topbar {
    flex-wrap: wrap;
    row-gap: var(--s2);
    padding: var(--s3) var(--s4);
  }
  /* let the name drop onto its own full-width line below the status pill so
     the form title isn't clipped beside the badge on a phone */
  .frm-ed-title-wrap {
    flex-wrap: wrap;
  }
  .frm-ed-name-input {
    flex: 1 1 100%;
    order: 3;
    font-size: var(--fz-lg);
  }
  .frm-ed-actions {
    flex-wrap: wrap;
  }
  .frm-ed-tabs {
    padding: 0 var(--s4);
  }
  .frm-ed-body {
    padding: var(--s4);
  }
  /* labels hide on the narrowest actions so the icons + Publish stay reachable */
  .frm-ed-action-btn[data-action='preview'] span,
  .frm-ed-action-btn[data-action='settings'] span,
  .frm-ed-action-btn[data-action='share'] span {
    display: none;
  }
}
