/* global React, T: globalT, M8Logo, Icon, Avatar, AvatarStack, SectionLabel, useT, ThemeContext, makeTheme */
// =====================================================================
// Four sidebar variations. Each is a self-contained component that
// renders a column with explicit width, full-height, white background.
//
// All four share:
//   - The dark active treatment (brand-700 fill, white text)
//   - Sentence-case nav labels (per README microcopy rules)
//   - Inter weights 400/500/600
//   - Theme via React Context — pass dark=true to flip to a slate-night
//     palette without touching internals.
//
// They differ in what's promoted to nav: pinned items, workspace
// switcher, command palette, or live workflow timeline.
// =====================================================================

/* ---------- Shared building blocks for the sidebars ---------- */

function NavRow({ icon, label, count, active, live, indent = 0, sub, trailing, badge, muted }) {
  const T = window.useT();
  // Single nav item. Dark fill + white text when active.
  const bg = active ? T.brand700 : "transparent";
  const fg = active ? "#fff"     : muted ? T.text3 : T.text2;
  const iconFg = active ? "#fff" : T.text3;
  return (
    <div style={{
      display: "grid",
      gridTemplateColumns: `${20 + indent}px 1fr auto`,
      alignItems: "center",
      gap: 10, height: 36,
      padding: `0 ${active ? 10 : 12}px 0 ${10 + indent}px`,
      borderRadius: 8,
      background: bg, color: fg,
      cursor: "pointer",
      transition: "background .12s",
      position: "relative",
    }}>
      <span style={{ display: "grid", placeItems: "center", color: iconFg }}>{icon}</span>
      <span style={{ display: "flex", flexDirection: "column", minWidth: 0 }}>
        <span style={{ font: `${active ? 600 : 500} 13px/16px Inter`, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
          {label}
        </span>
        {sub && (
          <span style={{ font: "400 11px/14px Inter", color: active ? "rgba(255,255,255,0.7)" : T.text3, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
            {sub}
          </span>
        )}
      </span>
      <span style={{ display: "inline-flex", alignItems: "center", gap: 6 }}>
        {live && (
          <span title="Live workshop in progress" style={{ display: "inline-flex", alignItems: "center", gap: 4 }}>
            <span style={{
              width: 7, height: 7, borderRadius: 999,
              background: active ? "#67e8a4" : T.green500,
              boxShadow: active ? "0 0 0 3px rgba(103,232,164,.25)" : `0 0 0 3px rgba(23,178,106,.18)`,
            }}/>
          </span>
        )}
        {badge}
        {count !== undefined && (
          <span style={{
            font: "500 11px/14px Inter",
            color: active ? "rgba(255,255,255,0.85)" : T.text3,
            fontVariantNumeric: "tabular-nums",
            minWidth: 16, textAlign: "right",
          }}>{count}</span>
        )}
        {trailing}
      </span>
    </div>
  );
}

function UserChip({ initials = "C", name = "Completer Mensah", sub = "completer@onwardsanalytics.com.au", status = "online", role, compact }) {
  const T = window.useT();
  const dark = T.dark;
  return (
    <div style={{
      display: "grid",
      gridTemplateColumns: "32px 1fr auto",
      alignItems: "center", gap: 10,
      padding: "10px 10px", borderRadius: 10,
      background: dark ? "rgba(255,255,255,0.05)" : "#f9fafb",
      border: dark ? "1px solid rgba(255,255,255,0.1)" : `1px solid ${T.borderSoft}`,
      cursor: "pointer",
    }}>
      <span style={{ position: "relative", width: 32, height: 32 }}>
        <span style={{
          width: 32, height: 32, borderRadius: 999,
          background: dark ? "rgba(255,255,255,0.12)" : "#d6e7ff",
          color: dark ? "#fff" : "#175cd3",
          display: "grid", placeItems: "center",
          font: "600 13px/1 Inter",
        }}>{initials}</span>
        <span style={{
          position: "absolute", right: -1, bottom: -1,
          width: 10, height: 10, borderRadius: 999,
          background: status === "online" ? "#17b26a" : "#f79009",
          boxShadow: `0 0 0 2px ${dark ? "#0d121c" : "#fff"}`,
        }}/>
      </span>
      <span style={{ minWidth: 0 }}>
        <span style={{ display: "flex", alignItems: "center", gap: 6 }}>
          <span style={{ font: "600 13px/16px Inter", color: dark ? "#fff" : "#101828", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{name}</span>
          {role && (
            <span style={{
              font: "500 10px/12px Inter",
              padding: "1px 5px", borderRadius: 4,
              background: dark ? "rgba(255,255,255,0.12)" : "#fff8ec",
              color: dark ? "#fde68a" : "#b54708",
              border: dark ? "none" : "1px solid #fde2a3",
              letterSpacing: 0.3,
            }}>{role}</span>
          )}
        </span>
        {!compact && (
          <span style={{ display: "block", font: "400 11px/14px Inter", color: dark ? "rgba(255,255,255,0.6)" : "#667085", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
            {sub}
          </span>
        )}
      </span>
      <span style={{ color: dark ? "rgba(255,255,255,0.6)" : "#98a2b3", padding: 4 }}>
        <Icon.kebab/>
      </span>
    </div>
  );
}

function Sidebar({ width, children, dark = false, style }) {
  const themed = window.makeTheme(dark);
  return (
    <window.ThemeContext.Provider value={themed}>
      <aside style={{
        width, flex: "none",
        display: "flex", flexDirection: "column",
        background: dark ? themed.bgPanel : "#fff",
        borderRight: dark ? "none" : `1px solid ${themed.border}`,
        color: dark ? "#fff" : themed.text,
        ...style,
      }}>
        {children}
      </aside>
    </window.ThemeContext.Provider>
  );
}

/* =====================================================================
   V1 — REFINED FLOOR
   Same shape as today, but every weakness fixed:
   - Workspace badge under the wordmark (white-label feel)
   - Compact search with ⌘K hint
   - Nav has inline counts + live-workshop dot
   - Pinned items (programme + open assessment)
   - User chip restructured to not truncate, shows role badge
   ===================================================================== */
function SidebarV1({ dark = false }) {
  const T = window.makeTheme(dark);
  return (
    <Sidebar width={248} dark={dark}>
      {/* Brand block */}
      <div style={{ padding: "16px 14px 12px", display: "flex", alignItems: "center", gap: 10 }}>
        <M8Logo size={26}/>
        <div style={{ display: "flex", flexDirection: "column", minWidth: 0 }}>
          <span style={{ font: "700 16px/18px Inter", color: T.text }}>Method8</span>
          <span style={{ font: "500 10px/13px Inter", color: T.text3, letterSpacing: 0.2 }}>Onwards Analytics</span>
        </div>
        <span style={{ marginLeft: "auto", padding: 4, borderRadius: 6, color: T.text4 }}>
          <Icon.panel size={16}/>
        </span>
      </div>

      {/* Search */}
      <div style={{ padding: "0 12px 10px" }}>
        <div style={{
          display: "flex", alignItems: "center", gap: 8,
          height: 34, padding: "0 10px",
          background: T.bgSubtle, border: `1px solid ${T.border}`,
          borderRadius: 8,
          color: T.text4,
        }}>
          <Icon.search size={14}/>
          <span style={{ font: "400 12px/16px Inter", color: T.text4 }}>Search Method8</span>
          <span style={{ marginLeft: "auto", display: "inline-flex", gap: 2, font: "500 10px/14px ui-sans-serif", color: T.text4 }}>
            <kbd style={{ padding: "1px 5px", borderRadius: 4, background: dark ? T.bgHover : "#fff", border: `1px solid ${T.border}`, color: T.text3 }}>⌘</kbd>
            <kbd style={{ padding: "1px 5px", borderRadius: 4, background: dark ? T.bgHover : "#fff", border: `1px solid ${T.border}`, color: T.text3 }}>K</kbd>
          </span>
        </div>
      </div>

      {/* Primary nav */}
      <div style={{ padding: "0 8px", display: "flex", flexDirection: "column", gap: 2 }}>
        <NavRow icon={<Icon.dashboard/>} label="Dashboard"/>
        <NavRow icon={<Icon.assessments/>} label="Assessments" count={12}/>
        <NavRow icon={<Icon.modules/>} label="Deployed modules" count={3} live active/>
        <NavRow icon={<Icon.actions/>} label="Actions" count={18} badge={
          <span style={{ padding: "1px 6px", borderRadius: 999, background: "#fef3f2", color: T.red600, font: "600 10px/14px Inter" }}>3 due</span>
        }/>
      </div>

      {/* Pinned */}
      <SectionLabel right={<Icon.plus size={12}/>}>Pinned</SectionLabel>
      <div style={{ padding: "0 8px", display: "flex", flexDirection: "column", gap: 2 }}>
        <NavRow icon={<span style={{ width: 14, height: 14, borderRadius: 4, background: T.sky500, display: "inline-block" }}/>} label="Gold Fields" sub="Programme · 12 assessments"/>
        <NavRow icon={<span style={{ width: 14, height: 14, borderRadius: 4, background: T.violet600, display: "inline-block" }}/>} label="Safety Standard Gap" sub="80% complete"/>
        <NavRow icon={<span style={{ width: 14, height: 14, borderRadius: 4, background: T.amber500, display: "inline-block" }}/>} label="ISO 9001 audit" sub="Draft"/>
      </div>

      <div style={{ flex: 1 }}/>

      {/* User chip */}
      <div style={{ padding: "10px 10px 12px", borderTop: `1px solid ${T.borderSoft}` }}>
        <UserChip role="COMPLETER" name="Completer Mensah" sub="completer@onwardsanalytics.com.au" initials="C"/>
      </div>
    </Sidebar>
  );
}

/* =====================================================================
   V2 — PROGRAMME-SCOPED TWO-TIER
   The big idea: make explicit that "Assessments / Modules / Actions" are
   always scoped to a programme. So programme switcher comes FIRST, and
   the nav is grouped under "Programme" beneath it. Cleaner than
   inheriting context from a breadcrumb.
   ===================================================================== */
function SidebarV2({ dark = false }) {
  const T = window.makeTheme(dark);
  return (
    <Sidebar width={264} dark={dark}>
      {/* Brand + workspace */}
      <div style={{ padding: "14px 14px 0", display: "flex", alignItems: "center", gap: 10 }}>
        <M8Logo size={22}/>
        <span style={{ font: "700 15px/18px Inter", color: T.text }}>Method8</span>
        <span style={{ marginLeft: "auto", color: T.text4 }}>
          <Icon.panel size={16}/>
        </span>
      </div>

      {/* Workspace switcher */}
      <div style={{ padding: "12px 12px 8px" }}>
        <div style={{
          display: "flex", alignItems: "center", gap: 10,
          padding: "8px 10px", borderRadius: 8,
          border: `1px solid ${T.border}`,
          cursor: "pointer", background: dark ? T.bgHover : "#fff",
        }}>
          <span style={{ width: 22, height: 22, borderRadius: 6, background: dark ? "rgba(255,255,255,0.12)" : "#0d121c", color: "#fff", display: "grid", placeItems: "center", font: "700 10px/1 Inter" }}>OA</span>
          <span style={{ display: "flex", flexDirection: "column", minWidth: 0, flex: 1 }}>
            <span style={{ font: "600 12px/15px Inter", color: T.text }}>Onwards Analytics</span>
            <span style={{ font: "400 10px/13px Inter", color: T.text3 }}>Workspace</span>
          </span>
          <Icon.caretUpDn size={14}/>
        </div>
      </div>

      {/* Programme switcher — bigger, with progress */}
      <div style={{ padding: "0 12px 10px" }}>
        <div style={{
          padding: "10px 12px", borderRadius: 10,
          background: dark
            ? "linear-gradient(180deg, rgba(46,144,250,0.10), rgba(46,144,250,0))"
            : "linear-gradient(180deg, #f6f9fe, #fff)",
          border: `1px solid ${dark ? "rgba(46,144,250,0.25)" : "#d6e4f5"}`,
          cursor: "pointer",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 6 }}>
            <span style={{ font: "600 9px/12px Inter", color: T.text4, letterSpacing: 0.6, textTransform: "uppercase" }}>Active programme</span>
            <span style={{ marginLeft: "auto", color: T.text4 }}><Icon.caretUpDn size={14}/></span>
          </div>
          <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 8 }}>
            <span style={{ width: 22, height: 22, borderRadius: 6, background: T.sky500, color: "#fff", display: "grid", placeItems: "center", font: "700 11px/1 Inter" }}>GF</span>
            <span style={{ font: "600 14px/18px Inter", color: T.text }}>Gold Fields</span>
          </div>
          <div style={{ height: 5, background: T.bgHover, borderRadius: 999, overflow: "hidden" }}>
            <div style={{ width: "62%", height: "100%", background: T.green500 }}/>
          </div>
          <div style={{ display: "flex", justifyContent: "space-between", marginTop: 5, font: "500 10px/14px Inter", color: T.text3 }}>
            <span>7 of 12 assessments</span>
            <span style={{ color: T.text2 }}>62%</span>
          </div>
        </div>
      </div>

      {/* Workspace-level nav */}
      <SectionLabel>Workspace</SectionLabel>
      <div style={{ padding: "0 8px", display: "flex", flexDirection: "column", gap: 2 }}>
        <NavRow icon={<Icon.dashboard/>} label="Dashboard"/>
        <NavRow icon={<Icon.inbox/>} label="Inbox" count={4} badge={
          <span style={{ width: 7, height: 7, borderRadius: 999, background: T.blue700 }}/>
        }/>
      </div>

      {/* Programme-level nav */}
      <SectionLabel>In Gold Fields</SectionLabel>
      <div style={{ padding: "0 8px", display: "flex", flexDirection: "column", gap: 2 }}>
        <NavRow icon={<Icon.assessments/>} label="Assessments" count={12}/>
        <NavRow icon={<Icon.modules/>} label="Deployed modules" count={3} live active/>
        <NavRow icon={<Icon.actions/>} label="Actions" count={18}/>
      </div>

      {/* Recently opened */}
      <SectionLabel>Recent</SectionLabel>
      <div style={{ padding: "0 12px", display: "flex", flexDirection: "column", gap: 4 }}>
        {[
          { dot: T.violet600, label: "Safety Standard Gap", sub: "2m ago" },
          { dot: T.sky500,    label: "Tailings Compliance", sub: "Yesterday" },
          { dot: T.amber500,  label: "ISO 9001 audit",      sub: "Mon" },
        ].map(r => (
          <div key={r.label} style={{ display: "flex", alignItems: "center", gap: 8, padding: "4px 6px", cursor: "pointer", borderRadius: 6 }}>
            <span style={{ width: 8, height: 8, borderRadius: 999, background: r.dot }}/>
            <span style={{ flex: 1, font: "500 12px/16px Inter", color: T.text2, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
              {r.label}
            </span>
            <span style={{ font: "400 10px/14px Inter", color: T.text4 }}>{r.sub}</span>
          </div>
        ))}
      </div>

      <div style={{ flex: 1 }}/>

      {/* User chip */}
      <div style={{ padding: "10px 10px 12px", borderTop: `1px solid ${T.borderSoft}` }}>
        <UserChip role="COMPLETER" name="Completer Mensah" sub="completer@onwardsanalytics.com.au" initials="C"/>
      </div>
    </Sidebar>
  );
}

/* =====================================================================
   V3 — COMMAND-FIRST RAIL
   The primary affordance is a big command palette at the top — every
   navigation is one keystroke away. The 4 nav items become small + dense
   underneath. Below: a live-workshop "carrier card" promoting the
   active session, and a + Create floating action at the bottom.
   This is the boldest day-to-day UX bet: keyboard-first, in-progress
   work surfaced as a first-class object, classic nav demoted.
   ===================================================================== */
function SidebarV3({ dark = false }) {
  const T = window.makeTheme(dark);
  return (
    <Sidebar width={280} dark={dark}>
      {/* Top: logo + workspace inline */}
      <div style={{ padding: "14px 14px 10px", display: "flex", alignItems: "center", gap: 10, borderBottom: `1px solid ${T.borderSoft}` }}>
        <M8Logo size={22}/>
        <span style={{ font: "700 15px/18px Inter", color: T.text }}>Method8</span>
        <span style={{
          marginLeft: "auto",
          padding: "2px 7px", borderRadius: 6,
          font: "600 10px/14px Inter", color: T.text3,
          background: T.bgSubtle, border: `1px solid ${T.border}`,
        }}>
          OA
        </span>
      </div>

      {/* Big command palette */}
      <div style={{ padding: "12px 12px 10px" }}>
        <div style={{
          display: "flex", alignItems: "center", gap: 10,
          padding: "10px 12px",
          borderRadius: 10,
          background: dark ? T.bgHover : "#fff",
          border: `1px solid ${T.border}`,
          boxShadow: dark ? "none" : "0 1px 2px rgba(16,24,40,0.04)",
          cursor: "text",
        }}>
          <Icon.search size={16}/>
          <span style={{ font: "400 13px/16px Inter", color: T.text3 }}>Jump to anything…</span>
          <span style={{ marginLeft: "auto", display: "inline-flex", gap: 2 }}>
            <kbd style={{ padding: "1px 5px", borderRadius: 4, background: T.bgSubtle, border: `1px solid ${T.border}`, font: "500 10px/14px ui-sans-serif", color: T.text3 }}>⌘</kbd>
            <kbd style={{ padding: "1px 5px", borderRadius: 4, background: T.bgSubtle, border: `1px solid ${T.border}`, font: "500 10px/14px ui-sans-serif", color: T.text3 }}>K</kbd>
          </span>
        </div>
        <div style={{ display: "flex", gap: 6, marginTop: 8 }}>
          <button style={{
            flex: 1, height: 30, borderRadius: 8,
            background: T.brand700, color: "#fff", border: "none",
            font: "600 12px/16px Inter", cursor: "pointer",
            display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 6,
          }}>
            <Icon.plus size={14}/> New
          </button>
          <button style={{
            width: 36, height: 30, borderRadius: 8,
            background: dark ? T.bgHover : "#fff", color: T.text2, border: `1px solid ${T.border}`,
            cursor: "pointer", display: "inline-flex", alignItems: "center", justifyContent: "center",
          }}>
            <Icon.bell size={14}/>
          </button>
          <button style={{
            width: 36, height: 30, borderRadius: 8,
            background: dark ? T.bgHover : "#fff", color: T.text2, border: `1px solid ${T.border}`,
            cursor: "pointer", display: "inline-flex", alignItems: "center", justifyContent: "center",
          }}>
            <Icon.panel size={14}/>
          </button>
        </div>
      </div>

      {/* Tight nav */}
      <div style={{ padding: "4px 8px 4px", display: "flex", flexDirection: "column", gap: 1 }}>
        <NavRow icon={<Icon.dashboard size={16}/>} label="Dashboard"/>
        <NavRow icon={<Icon.assessments size={16}/>} label="Assessments" count={12}/>
        <NavRow icon={<Icon.modules size={16}/>} label="Deployed modules" count={3} live active/>
        <NavRow icon={<Icon.actions size={16}/>} label="Actions" count={18}/>
      </div>

      {/* Active workshop "carrier card" */}
      <SectionLabel right={<span style={{ font: "500 10px/14px Inter", color: T.green600, display: "inline-flex", alignItems: "center", gap: 4, textTransform: "none", letterSpacing: 0 }}>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: T.green500 }}/>Live
      </span>}>Active workshop</SectionLabel>
      <div style={{ padding: "0 12px 6px" }}>
        <div style={{
          padding: "12px",
          borderRadius: 12,
          background: dark
            ? "linear-gradient(160deg, rgba(122,90,248,0.18) 0%, rgba(122,90,248,0.02) 60%)"
            : "linear-gradient(160deg, #f4f3ff 0%, #fff 60%)",
          border: `1px solid ${dark ? "rgba(167,139,250,0.35)" : "#d6cdfe"}`,
          cursor: "pointer",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
            {/* Progress ring */}
            <svg width="38" height="38" viewBox="0 0 38 38">
              <circle cx="19" cy="19" r="15" fill="none" stroke={T.violet50} strokeWidth="4"/>
              <circle cx="19" cy="19" r="15" fill="none" stroke={T.violet600} strokeWidth="4"
                strokeDasharray={`${2*Math.PI*15*0.8} ${2*Math.PI*15}`}
                strokeDashoffset={2*Math.PI*15*0.25}
                strokeLinecap="round"
                transform="rotate(-90 19 19)"/>
              <text x="19" y="22" textAnchor="middle" fontSize="10" fontFamily="Inter" fontWeight="600" fill={T.violet700}>80%</text>
            </svg>
            <div style={{ minWidth: 0, flex: 1 }}>
              <div style={{ font: "600 13px/16px Inter", color: T.text, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
                Safety Standard Gap
              </div>
              <div style={{ font: "500 11px/14px Inter", color: T.violet700, marginTop: 2 }}>
                You're completer
              </div>
            </div>
          </div>
          <div style={{ display: "flex", alignItems: "center", gap: 10, marginTop: 10, paddingTop: 10, borderTop: `1px solid rgba(105,56,239,0.12)` }}>
            <AvatarStack srcs={["avatars/av-marcus.svg","avatars/av-priya.svg","avatars/av-sarah.svg"]} size={20}/>
            <span style={{ font: "500 11px/14px Inter", color: T.text3 }}>3 here</span>
            <span style={{ marginLeft: "auto", font: "600 11px/14px Inter", color: T.violet700 }}>Join →</span>
          </div>
        </div>
      </div>

      <div style={{ flex: 1 }}/>

      {/* User row */}
      <div style={{ padding: "10px 10px 12px", borderTop: `1px solid ${T.borderSoft}` }}>
        <UserChip role="COMPLETER" name="Completer Mensah" sub="completer@onwardsanalytics.com.au" initials="C" compact/>
      </div>
    </Sidebar>
  );
}

/* =====================================================================
   V4 — LIVE TIMELINE NAV
   The most radical re-frame: instead of nav-as-feature-tree, nav reads
   like a feed of work. "Now / Today / Browse". The classic 4 items get
   demoted to a small Browse strip at the bottom. Promotes what's
   happening over what's possible.
   ===================================================================== */
function SidebarV4({ dark = false }) {
  const T = window.makeTheme(dark);
  return (
    <Sidebar width={276} dark={dark}>
      {/* Brand */}
      <div style={{ padding: "14px 14px 8px", display: "flex", alignItems: "center", gap: 10 }}>
        <M8Logo size={22}/>
        <span style={{ font: "700 15px/18px Inter", color: T.text }}>Method8</span>
        <span style={{ marginLeft: "auto", display: "inline-flex", gap: 4 }}>
          <span style={{ padding: 5, borderRadius: 6, color: T.text3, cursor: "pointer" }}><Icon.search size={15}/></span>
          <span style={{ padding: 5, borderRadius: 6, color: T.text3, cursor: "pointer", position: "relative" }}>
            <Icon.bell size={15}/>
            <span style={{ position: "absolute", top: 3, right: 3, width: 7, height: 7, borderRadius: 999, background: T.red600, boxShadow: "0 0 0 2px #fff" }}/>
          </span>
        </span>
      </div>

      {/* Workspace + programme inline pill */}
      <div style={{ padding: "0 12px 12px" }}>
        <div style={{
          display: "flex", alignItems: "center", gap: 8,
          padding: "6px 10px", borderRadius: 8,
          background: T.bgSubtle, border: `1px solid ${T.borderSoft}`,
          cursor: "pointer",
        }}>
          <span style={{ width: 18, height: 18, borderRadius: 4, background: "#0d121c", color: "#fff", display: "grid", placeItems: "center", font: "700 9px/1 Inter" }}>OA</span>
          <span style={{ font: "500 11px/14px Inter", color: T.text3 }}>Onwards</span>
          <span style={{ color: T.text4 }}>/</span>
          <span style={{ font: "600 12px/15px Inter", color: T.text }}>Gold Fields</span>
          <span style={{ marginLeft: "auto", color: T.text4 }}><Icon.caretUpDn size={12}/></span>
        </div>
      </div>

      {/* NOW */}
      <SectionLabel right={<span style={{ display: "inline-flex", alignItems: "center", gap: 4, font: "500 10px/14px Inter", color: T.green600, textTransform: "none", letterSpacing: 0 }}>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: T.green500, boxShadow: "0 0 0 3px rgba(23,178,106,0.18)" }}/>
        Live
      </span>}>Now</SectionLabel>
      <div style={{ padding: "0 8px" }}>
        {/* Live workshop card — primary "active" affordance */}
        <div style={{
          background: T.brand700, color: "#fff",
          padding: "12px 12px", borderRadius: 10,
          cursor: "pointer", position: "relative", overflow: "hidden",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <span style={{
              padding: "1px 6px", borderRadius: 4,
              background: "#ef6820", color: "#fff",
              font: "700 9px/12px Inter", letterSpacing: 0.5,
            }}>WORKSHOP</span>
            <span style={{ font: "500 10px/14px Inter", color: "rgba(255,255,255,0.7)" }}>4 people</span>
            <span style={{ marginLeft: "auto", font: "600 10px/14px Inter", color: "#abefc6", display: "inline-flex", alignItems: "center", gap: 4 }}>
              <span style={{ width: 5, height: 5, borderRadius: 999, background: T.green500 }}/>
              80%
            </span>
          </div>
          <div style={{ font: "600 13px/17px Inter", marginTop: 8, marginBottom: 6 }}>
            Safety Standard Gap Assessment
          </div>
          <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <AvatarStack srcs={["avatars/av-me.svg","avatars/av-marcus.svg","avatars/av-priya.svg","avatars/av-sarah.svg"]} size={18} ring={T.brand700}/>
            <span style={{ font: "500 11px/14px Inter", color: "rgba(255,255,255,0.85)" }}>You're completer</span>
          </div>
        </div>
      </div>

      {/* TODAY */}
      <SectionLabel right={<span style={{ font: "500 10px/14px Inter", color: T.text4, textTransform: "none", letterSpacing: 0 }}>May 17</span>}>Today</SectionLabel>
      <div style={{ padding: "0 8px", display: "flex", flexDirection: "column", gap: 2 }}>
        <div style={{ display: "flex", alignItems: "center", gap: 10, padding: "8px 10px", borderRadius: 8, cursor: "pointer" }}>
          <span style={{ width: 22, height: 22, borderRadius: 6, background: "#fef3f2", color: T.red600, display: "grid", placeItems: "center" }}>
            <Icon.flame size={12}/>
          </span>
          <span style={{ flex: 1, font: "500 12px/16px Inter", color: T.text2 }}>3 actions due today</span>
          <Icon.chev size={12}/>
        </div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, padding: "8px 10px", borderRadius: 8, cursor: "pointer" }}>
          <span style={{ width: 22, height: 22, borderRadius: 6, background: T.bgHover, color: T.amber700, display: "grid", placeItems: "center" }}>
            <Icon.clock size={12}/>
          </span>
          <span style={{ flex: 1, font: "500 12px/16px Inter", color: T.text2 }}>Submission deadline · 5pm</span>
          <Icon.chev size={12}/>
        </div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, padding: "8px 10px", borderRadius: 8, cursor: "pointer" }}>
          <span style={{ width: 22, height: 22, borderRadius: 6, background: T.violet50, color: T.violet600, display: "grid", placeItems: "center" }}>
            <Icon.inbox size={12}/>
          </span>
          <span style={{ flex: 1, font: "500 12px/16px Inter", color: T.text2 }}>2 review requests</span>
          <Icon.chev size={12}/>
        </div>
      </div>

      <div style={{ flex: 1 }}/>

      {/* BROWSE — demoted classic nav */}
      <SectionLabel>Browse</SectionLabel>
      <div style={{ padding: "0 8px 10px", display: "flex", flexDirection: "column", gap: 1 }}>
        <NavRow icon={<Icon.dashboard size={15}/>} label="Dashboard" muted/>
        <NavRow icon={<Icon.assessments size={15}/>} label="Assessments" muted count={12}/>
        <NavRow icon={<Icon.modules size={15}/>} label="Deployed modules" muted count={3}/>
        <NavRow icon={<Icon.actions size={15}/>} label="Actions" muted count={18}/>
      </div>

      <div style={{ padding: "8px 10px 12px", borderTop: `1px solid ${T.borderSoft}` }}>
        <UserChip role="COMPLETER" name="Completer Mensah" sub="completer@onwardsanalytics.com.au" initials="C"/>
      </div>
    </Sidebar>
  );
}

Object.assign(window, {
  NavRow, UserChip, Sidebar,
  SidebarV1, SidebarV2, SidebarV3, SidebarV4,
});
