/* Canvas-first workflow editor (n8n / FME style). Applies only while editing. */

/* App navigation shrinks to an icon rail; the page header gives its row to the canvas. */
body.workspace-shell.wf-canvas-mode { grid-template-columns: 60px minmax(0,1fr); }
body.wf-canvas-mode .workspace-sidebar { padding: 12px 6px; overflow-x: hidden; }
body.wf-canvas-mode .workspace-sidebar > :not(.portal-view-tabs) { display: none; }
body.wf-canvas-mode .workspace-shell .portal-nav-tab, body.wf-canvas-mode .portal-nav-tab { font-size: 0; justify-content: center; padding: 10px 0; min-height: 42px; gap: 0; }
body.wf-canvas-mode .portal-nav-tab .tab-icon { font-size: 14px; }
body.wf-canvas-mode .workspace-context { display: none; }
body.wf-canvas-mode.workspace-shell > .portal-view-section { grid-row: 2 / 4; overflow: hidden; }
body.wf-canvas-mode #viewFlow { display: flex; flex-direction: column; height: 100%; }
body.wf-canvas-mode #viewFlow > .workflow-mode-bar,
body.wf-canvas-mode #viewFlow > .workspace-import-handoff:not(:empty) ~ .workflow-mode-bar { display: none; }

/* The editor host fills the view: bar, canvas, dock. */
.wfs-host:not([hidden]) { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; position: relative; }
.wfs-frame { display: grid !important; grid-template-rows: auto minmax(0,1fr) auto; flex: 1; min-height: 0; height: 100%; position: relative; }
body:not(.wf-canvas-mode) .wfs-host, body:not(.wf-canvas-mode) .wfs-frame { height: auto; }

.wfs-bar { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; padding: 6px 12px !important; min-height: 48px; border-bottom: 1px solid var(--olf-line); background: var(--olf-paper-raised); }
.wfs-bar > div:first-of-type { min-width: 0; flex: 1; }
.wfs-bar .workflow-eyebrow, .wfs-bar #prepPreviewEndpoint { display: none; }
.wfs-bar h2 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfs-bar input[aria-label="Workflow name"] { font-size: 15px; font-weight: 600; border: 1px solid transparent; background: transparent; padding: 4px 6px; min-width: 0; width: 100%; max-width: 420px; }
.wfs-bar input[aria-label="Workflow name"]:hover, .wfs-bar input[aria-label="Workflow name"]:focus { border-color: var(--olf-line); background: var(--olf-paper); }
.wfs-bar .workflow-top-actions, .wfs-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.wfs-bar .btn { min-height: 34px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.wfs-bar a[href*="workspace=features"], .wfs-host a[href*="workspace="][class*="btn"] { display: none !important; }
.wfs-back { border: 0; background: transparent; color: var(--olf-ink-secondary); font-size: 13px; padding: 6px 8px; cursor: pointer; white-space: nowrap; }
.wfs-back:hover { color: var(--olf-accent); }
.wfs-guided { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--olf-ink-secondary); white-space: nowrap; cursor: pointer; }
.wfs-more { min-width: 36px; min-height: 34px; border: 1px solid var(--olf-line); border-radius: 6px; background: var(--olf-paper); font-size: 18px; line-height: 1; cursor: pointer; }

/* The canvas takes every remaining pixel. */
.wfs-editor { display: flex !important; flex-direction: column; position: relative; height: auto !important; min-height: 0 !important; overflow: hidden; grid-template-columns: none !important; }
.wfs-editor > .workflow-stage { position: relative; flex: 1 1 auto; min-height: 0; height: auto !important; display: flex !important; flex-direction: column; }
.wfs-editor > .workflow-stage > div:not(.workflow-canvas-caption):not(.workflow-canvas-footnote):not(.workflow-step-navigator) { flex: 1 1 auto; height: auto !important; min-height: 0 !important; }
/* Notices get their own row above the canvas instead of covering steps. */
.wfs-notices { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--olf-line); background: var(--olf-paper); }
.wfs-notices:not(:has(> :not(:empty):not([hidden]))) { display: none; }
.wfs-notices > * { max-width: 960px; }
.wfs-notices > :empty, .wfs-notices > [hidden] { display: none !important; }
.wfs-notices > p, .wfs-notices > [role="status"]:not(:empty) { margin: 0; padding: 0; background: none; border: 0; font-size: 13px; }

/* Panels that slide in over the canvas. */
.wfs-palette, .wfs-drawer { position: absolute; top: 0; bottom: 0; z-index: 8; width: min(360px, 90%); overflow: auto; background: var(--olf-paper-raised); box-shadow: 0 6px 24px rgba(0,0,0,.16); transform: translateX(-105%); transition: transform .16s ease; visibility: hidden; }
.wfs-palette { left: 0; border-right: 1px solid var(--olf-line); padding: 12px !important; }
.wfs-drawer { right: 0; left: auto; width: min(460px, 94%); transform: translateX(105%); border-left: 1px solid var(--olf-line); padding: 12px 16px; }
.wfs-palette-open .wfs-palette, .wfs-drawer-open .wfs-drawer { transform: none; visibility: visible; }
.wfs-drawer > * + * { margin-top: 10px; }
.wfs-drawer .workflow-document-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; border: 0; background: none; }
.wfs-drawer .workflow-document-bar > span { flex-basis: 100%; }
.wfs-panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wfs-panel-head strong { font-size: 15px; }
.wfs-panel-head .wfs-hint { color: var(--olf-ink-muted); font-size: 12px; }
.wfs-panel-head .wfs-close { margin-left: auto; }
.wfs-close { border: 1px solid var(--olf-line); background: var(--olf-paper); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; }

/* Step settings: a panel along the right edge (n8n, Power Automate); the canvas narrows beside it. */
.wfs-step { position: absolute; z-index: 9; top: 0; right: 0; bottom: 0; width: min(460px, 42%); overflow: auto; overscroll-behavior: contain; border-left: 1px solid var(--olf-line); box-shadow: -6px 0 20px rgba(0,0,0,.08); padding: 0 20px 16px; background: var(--olf-paper-raised); display: none; }
.wfs-step-open .wfs-editor > :is(.workflow-stage, .wfs-notices) { margin-right: min(460px, 42%); }
/* The title and close button stay visible while the fields scroll. */
.wfs-step > .wfs-step-head { position: sticky; top: 0; z-index: 1; margin: 0 -20px 8px; padding: 12px 20px; background: var(--olf-paper-raised); border-bottom: 1px solid var(--olf-line); }
/* Proportionate fields inside the window: normal heights and spacing, not the full-width sidebar sizes. */
.wfs-step :is(.workflow-settings, .wfs-borrowed) label { display: block; margin: 10px 0 0; font-size: 13px; font-weight: 600; }
/* :is(#preparationGuide, .wfs-host) lifts this above the editor's own ID-scoped 44 px field rule. */
:is(#preparationGuide, .wfs-host) .wfs-step :is(.workflow-settings, .wfs-borrowed) :is(input:not([type=checkbox]):not([type=radio]):not([type=file]), select, .form-input, .form-select) { display: block; width: 100%; box-sizing: border-box; height: 34px; min-height: 0; margin-top: 4px; padding: 4px 10px; font-size: 14px; border-radius: 6px; }
.wfs-step :is(.workflow-settings, .wfs-borrowed) textarea { margin-top: 4px; font-size: 14px; }
.wfs-step :is(.workflow-settings, .wfs-borrowed) label:has(> input[type=checkbox]) { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.wfs-step :is(.workflow-settings, .wfs-borrowed) p { margin: 6px 0; font-size: 13px; line-height: 1.45; }
.wfs-step details > summary { cursor: pointer; font-weight: 600; margin: 12px 0 4px; }
.wfs-step .btn { min-height: 32px; padding: 5px 12px; font-size: 13px; }
/* Inspecting an output is done from its port on the canvas; the window keeps only step actions. */
.wfs-step .workflow-inspect-port { display: none; }
.wfs-step > .workflow-settings { border: 0; padding: 0; overflow: visible; background: none; }
.wfs-step-open .wfs-step { display: block; }
.wfs-step-borrowing > :not(.wfs-panel-head):not(.wfs-borrowed) { display: none !important; }
.wfs-borrowed h3 { margin: 0 0 10px; font-size: 16px; }

/* Results dock along the bottom, like FME's preview and log. */
.wfs-dock { max-height: 36vh; overflow: auto; border-top: 1px solid var(--olf-line); background: var(--olf-paper-raised); }
.wfs-dock > details[open] { max-height: 36vh; }
.wfs-dock .workflow-dock-summary { position: sticky; top: 0; z-index: 1; background: var(--olf-paper-raised); }

/* Guided off: hints and suggested-next-step strips do not take canvas space. */
body:not(.wf-guided) .wfs-host :is(.workflow-next-step, .workflow-canvas-footnote, .workflow-canvas-hint, .workflow-step-navigator, .workflow-build-bar) { display: none !important; }
body:not(.wf-guided) .wfs-host .workflow-canvas-caption { display: none; }

@media (max-width: 760px) {
  body.workspace-shell.wf-canvas-mode { display: flex; }
  .wfs-bar { flex-wrap: wrap; }
  .wfs-step { position: fixed; top: 8px; right: 8px; bottom: auto; width: calc(100vw - 16px); max-height: calc(100vh - 16px); border-radius: 12px; }
  .wfs-step-open .wfs-editor > :is(.workflow-stage, .wfs-notices) { margin-right: 0; }
}

/* Workflows start screen. */
.wf-home { max-width: 1180px; margin: 0 auto; padding: 22px 26px 40px; }
.wf-home-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.wf-home-top h2 { margin: 0; font-size: 22px; }
.wf-home-db { color: var(--olf-ink-muted); font-size: 14px; }
.wf-home-spacer { flex: 1; }
.wf-home-status:empty { display: none; }
.wf-home-status { margin: 0 0 10px; font-size: 13px; }
.wf-home-ai { border: 1px solid var(--olf-line); border-radius: 12px; background: var(--olf-paper-raised); padding: 16px 18px; }
.wf-home-ai h3, .wf-home-section h3 { margin: 0 0 10px; font-size: 15px; }
.wf-home-ai textarea { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--olf-line); border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 14px; background: var(--olf-paper); color: var(--olf-ink); box-sizing: border-box; }
.wf-home-ai-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.wf-home-mic { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--olf-line); background: var(--olf-paper); font-size: 17px; cursor: pointer; }
.wf-home-mic.is-listening { background: var(--olf-accent); color: #fff; border-color: var(--olf-accent); animation: wf-pulse 1.2s ease-in-out infinite; }
.wf-home-mic:disabled { opacity: .45; cursor: not-allowed; }
@keyframes wf-pulse { 50% { box-shadow: 0 0 0 6px var(--olf-accent-soft); } }
.wf-home-note { color: var(--olf-ink-muted); font-size: 13px; }
.wf-home-section { margin-top: 24px; }
.wf-home-section-head { display: flex; align-items: center; gap: 12px; }
.wf-home-section-head h3 { margin: 0; }
.wf-home-search { margin-left: auto; min-height: 36px; border: 1px solid var(--olf-line); border-radius: 8px; padding: 6px 10px; width: min(280px, 50%); background: var(--olf-paper); color: var(--olf-ink); }
.wf-home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.wf-home-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; border: 1px solid var(--olf-line); border-radius: 10px; background: var(--olf-paper-raised); padding: 12px 14px; cursor: pointer; min-height: 104px; color: var(--olf-ink); }
.wf-home-card:hover { border-color: var(--olf-accent); }
.wf-home-card strong { font-size: 14px; }
.wf-home-card small { color: var(--olf-ink-muted); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wf-home-card-tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--olf-accent); }
.wf-home-more { margin-top: 10px; border: 0; background: none; color: var(--olf-accent); cursor: pointer; font-size: 13px; padding: 4px 0; }
.wf-home-saved { margin-top: 10px; border: 1px solid var(--olf-line); border-radius: 10px; overflow: hidden; }
.wf-home-saved > p { margin: 0; padding: 14px; }
.wf-home-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-bottom: 1px solid var(--olf-line); background: var(--olf-paper-raised); padding: 12px 14px; cursor: pointer; text-align: left; color: var(--olf-ink); }
.wf-home-row:last-child { border-bottom: 0; }
.wf-home-row:hover { background: var(--olf-accent-soft); }
.wf-home-row strong { font-size: 14px; }
.wfs-dock-toggle { position: sticky; top: 0; z-index: 2; display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--olf-line); background: var(--olf-paper-raised); padding: 8px 16px; font-weight: 600; cursor: pointer; }
.wfs-dock-toggle::before { content: "▾ "; }
.wfs-dock-collapsed > .wfs-dock-toggle::before { content: "▸ "; }
.wfs-dock.wfs-dock-collapsed { max-height: 38px; overflow: hidden; }
.wfs-palette-extra { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--olf-line); }
.wfs-palette-extra h4 { margin: 0 0 4px; font-size: 13px; }
.wfs-palette-extra .wfs-hint { margin: 0 0 8px; font-size: 12px; color: var(--olf-ink-muted); }
.wfs-palette-link { display: block; width: 100%; text-align: left; margin-top: 4px; }
/* Panels shown in the step window (AI drafting, template setup) get form styling. */
.wfs-borrowed > details > summary { font-weight: 600; margin-bottom: 8px; cursor: pointer; }
.wfs-borrowed p { margin: 6px 0; line-height: 1.5; color: var(--olf-ink-secondary); font-size: 13px; }
.wfs-borrowed label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; color: var(--olf-ink); }
.wfs-borrowed textarea { display: block; width: 100%; min-height: 96px; box-sizing: border-box; border: 1px solid var(--olf-line); border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 14px; background: var(--olf-paper); color: var(--olf-ink); }
.wfs-borrowed button:not(.btn):not(.wfs-close) { display: inline-flex; align-items: center; min-height: 34px; margin: 6px 6px 0 0; padding: 6px 12px; border: 1px solid var(--olf-line); border-radius: 6px; background: var(--olf-paper); color: var(--olf-ink); font: inherit; font-size: 13px; cursor: pointer; }
.wfs-borrowed button:not(.btn):not(.wfs-close):disabled { opacity: .5; cursor: not-allowed; }
.wfs-borrowed #prepAISources { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 10px; }
.wfs-borrowed #prepAISources label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
