/* ============================================================
   Workflow View — module styles (scoped under .wfv)
   Drop-in read-only diagram view for the SOP Builder.
   All selectors are namespaced so nothing leaks into the host app.
   ============================================================ */
.wfv{
  --wfv-ink:#E7E9ED; --wfv-label:#9CA3AF;
  --wfv-canvas:#121212; --wfv-card-bg:#1A1A1A; --wfv-card-border:rgba(55,65,81,.72);
  --wfv-spine:#AEB5C1; --wfv-branch:#565E6B;
  font-family:"Figtree","Helvetica Neue",Helvetica,Arial,sans-serif;
  color:var(--wfv-ink); -webkit-font-smoothing:antialiased; position:relative;
}
.wfv *{box-sizing:border-box;}

/* sticky header: title-dropdown + role filter (stays put on long workflows) */
.wfv-header{position:sticky;top:0;z-index:40;margin:0 -8px;padding:10px 8px 8px;
  background:var(--wfv-canvas,#121212);
  border-radius:0 0 14px 14px;}
.wfv-titlebar{position:relative;display:flex;justify-content:center;margin:2px 0 6px;}
.wfv-titlebtn{display:inline-flex;align-items:center;gap:11px;max-width:100%;cursor:pointer;font-family:inherit;
  background:#1A1E27;border:1px solid var(--wfv-card-border);border-radius:12px;padding:9px 18px;
  color:#F4F6FA;font-size:22px;font-weight:600;letter-spacing:-.01em;line-height:1.2;}
.wfv-titlebtn:hover{border-color:#3a4150;}
.wfv-titlebtn.wfv-single{cursor:default;background:transparent;border-color:transparent;padding:9px 4px;}
.wfv-titletext{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.wfv-chev{font-size:13px;color:var(--wfv-label);flex:none;transition:transform .15s;}
.wfv-titlebtn[aria-expanded="true"] .wfv-chev{transform:rotate(180deg);}
.wfv-menu{position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);z-index:50;margin:0;list-style:none;
  background:#161A22;border:1px solid var(--wfv-card-border);border-radius:12px;box-shadow:0 16px 44px rgba(0,0,0,.6);
  padding:6px;min-width:300px;max-width:min(560px,90vw);max-height:50vh;overflow:auto;}
.wfv-menu li{padding:9px 13px;border-radius:8px;font-size:14px;color:#C9D1DC;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.wfv-menu li:hover{background:#1d2433;color:#fff;}
.wfv-menu li[aria-selected="true"]{background:#1d2433;color:#fff;font-weight:600;}
.wfv-sub{display:none;}

.wfv-filter{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;
  margin:0 auto;padding:10px 14px;max-width:960px;
  background:rgba(255,255,255,.02);border:1px solid var(--wfv-card-border);border-radius:12px;}
.wfv-filter .wfv-flabel{font-size:12px;color:var(--wfv-label);margin-right:4px;font-weight:500;}
.wfv-role{display:inline-flex;align-items:center;gap:6px;padding:5px 12px;min-height:28px;border-radius:9999px;
  font-weight:600;font-size:12px;line-height:16px;white-space:nowrap;color:#F4F6FA;cursor:pointer;user-select:none;
  background:var(--wfv-r);
  border:1px solid rgba(255,255,255,.16);transition:opacity .12s,outline-color .12s;
  outline:2px solid transparent;outline-offset:1px;}
.wfv-role:hover{opacity:.92;}
.wfv-role[aria-pressed="true"]{outline-color:rgba(255,255,255,.82);}
.wfv-filter.wfv-active .wfv-role:not([aria-pressed="true"]){opacity:.45;}
.wfv-clear{font-size:12px;font-weight:600;color:var(--wfv-ink);background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.16);border-radius:8px;cursor:pointer;text-decoration:none;padding:5px 12px;min-height:28px;}
.wfv-clear:hover{background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.30);}

/* zoom controls — pinned top-right of the sticky header */
.wfv-zoom{position:absolute;top:10px;right:12px;z-index:42;display:flex;align-items:center;gap:2px;
  background:#1A1E27;border:1px solid var(--wfv-card-border);border-radius:10px;padding:3px;}
.wfv-zbtn{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;
  font-size:18px;line-height:1;color:var(--wfv-ink);background:transparent;border:0;border-radius:7px;cursor:pointer;font-family:inherit;}
.wfv-zbtn:hover:not(:disabled){background:rgba(255,255,255,.08);}
.wfv-zbtn:disabled{opacity:.35;cursor:default;}
.wfv-zlabel{min-width:46px;height:28px;font-size:12px;font-weight:600;color:var(--wfv-label);background:transparent;border:0;cursor:pointer;font-family:inherit;}
.wfv-zlabel:hover{color:var(--wfv-ink);}
.wfv-zfit{height:28px;padding:0 11px;margin-left:2px;font-size:12px;font-weight:600;color:var(--wfv-ink);
  background:rgba(255,255,255,.04);border:1px solid var(--wfv-card-border);border-radius:7px;cursor:pointer;font-family:inherit;}
.wfv-zfit:hover{background:rgba(255,255,255,.08);border-color:#3a4150;}
/* phones: the centred title fills the width, so drop the zoom cluster into its own
   centred row instead of overlapping the title in the top-right corner. */
@media(max-width:720px){
  .wfv-zoom{position:static;margin:2px auto 8px;width:max-content;}
}

/* scalable stage */
.wfv-sizer{position:relative;}
.wfv-viewport{position:relative;width:100%;}
.wfv-stage{position:relative;transform-origin:top left;will-change:transform;}
.wfv-stage svg.wfv-wires{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:0;}

/* card */
.wfv-card{position:absolute;z-index:1;display:flex;flex-direction:column;justify-content:center;min-height:112px;
  background:var(--wfv-card-bg);border:2px solid var(--wfv-card-border);border-radius:14px;overflow:hidden;
  transition:opacity .12s,filter .12s;}
/* box outline carries the step-type identity colour (passed from the legend). Brightened toward
   light on the dark canvas so it reads; print uses the raw colour on white (see app.css). */
.wfv-card{border-color:color-mix(in srgb, var(--wfv-t, var(--wfv-card-border)) 72%, #aeb5c1);}
/* role-coloured rail down the left edge — prominent, using the assigned role's legend colour */
.wfv-card .wfv-rail{position:absolute;left:0;top:0;bottom:0;width:7px;background:color-mix(in srgb, var(--wfv-r) 88%, #c4cad4);}
/* step number — small, muted, in the bottom-left corner so each box stays referenceable (1, 2, 11.a)
   without pushing the role/type/icon head down; absolute so it stays out of the card's flex flow. */
.wfv-card>.wfv-stepno{position:absolute;left:13px;bottom:9px;z-index:2;
  font-size:11px;font-weight:700;line-height:1;letter-spacing:.01em;white-space:nowrap;color:#6F7884;}
.wfv-card.wfv-terminal>.wfv-stepno{left:16px;}
.wfv-card.wfv-dim{opacity:.26;filter:grayscale(.7);}
/* header: role left · step-type centre · icons right */
/* align-items:start keeps the role chip + step-type pill at the TOP (level with the first icon
   row) even when the icons wrap to a second row — only the icons drop, not the role/type. */
.wfv-card .wfv-head{display:grid;grid-template-columns:1fr auto 1fr;align-items:start;column-gap:10px;padding:17px 20px 0 20px;}
.wfv-card .wfv-head>.wfv-role-chip{justify-self:start;}
.wfv-card .wfv-head>.wfv-step{justify-self:center;}
.wfv-card .wfv-head>.wfv-icons{justify-self:end;}
/* icons stack two-per-row, right-aligned, growing DOWNWARD — capped width so they never widen
   the right column and push the centred step-type/role out of place (3 icons → 2 + 1 below). */
.wfv-card .wfv-icons{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;row-gap:6px;max-width:80px;flex:none;}
.wfv-card .wfv-body{padding:12px 24px 22px 24px;font-size:13.5px;line-height:1.5;color:var(--wfv-ink);text-align:center;}
.wfv-card.wfv-terminal{border-radius:20px;background:#1A1A1A;}
.wfv-card.wfv-decision .wfv-body{font-weight:500;}

/* role chip */
.wfv-role-chip{display:inline-flex;align-items:center;justify-content:center;padding:5px 11px;min-height:28px;border-radius:9999px;
  font-weight:600;font-size:12px;line-height:16px;white-space:nowrap;color:#F4F6FA;
  background:var(--wfv-r);
  border:1px solid rgba(255,255,255,.16);}
/* step-type chip (step-type colour distinction) */
.wfv-step{display:inline-flex;align-items:center;min-height:28px;padding:5px 11px;border-radius:9999px;
  font-size:12px;font-weight:600;line-height:16px;border:1px solid rgba(255,255,255,.14);white-space:nowrap;}
.wfv-step.start{background:rgba(47,74,67,.46);color:#D9EFE5;border-color:rgba(123,170,150,.55);}
.wfv-step.process{background:rgba(24,37,64,.50);color:#DCE5F5;border-color:rgba(91,113,152,.58);}
.wfv-step.decision{background:rgba(89,75,42,.52);color:#F1E4BE;border-color:rgba(197,179,88,.62);}
.wfv-step.end{background:rgba(90,56,56,.48);color:#F2CACA;border-color:rgba(190,116,110,.55);}
.wfv-step.document{background:rgba(64,57,85,.48);color:#E5DFF5;border-color:rgba(160,146,190,.55);}
/* icon chip */
.wfv-icon{display:inline-flex;width:36px;height:36px;min-width:36px;align-items:center;justify-content:center;border-radius:8px;
  color:var(--wfv-p);background:rgba(255,255,255,.06);border:1px solid color-mix(in srgb,var(--wfv-p) 62%,transparent);}
.wfv-icon svg{width:22px;height:22px;display:block;}
/* in-card note */
.wfv-card .wfv-note{margin:4px 22px 12px 22px;padding:10px 13px;border-radius:8px;background:#15181F;
  border:1px dashed rgba(82,94,114,.78);color:#C4CAD4;font-size:11.5px;line-height:1.5;text-align:left;white-space:pre-line;}
.wfv-card .wfv-note .wfv-note-t{display:block;font-weight:700;color:#D7DBE2;margin-bottom:3px;}
/* the last note must clear the bottom-left step-number badge (absolute, bottom:9px) so they never touch */
.wfv-card .wfv-note:last-child{margin-bottom:28px;}
/* wire label */
.wfv-wlabel{position:absolute;z-index:2;font-size:11.5px;font-weight:700;letter-spacing:.07em;color:#C9D1DC;
  background:var(--wfv-canvas);padding:1px 6px;border-radius:4px;transform:translate(-50%,-50%);}
