/* ════════════════════════════════════════════════════════════════════
   AI ROADMAP — product mocks (hero shot + step media), pure CSS/JSX.
   Built from the DecidrOS visual vocabulary. Exposes on window.
   ════════════════════════════════════════════════════════════════════ */

/* ── clean panel header (proper section, not a browser tab) ── */
function Panel({ icon, title, badge, children }) {
  return (
    <div style={{ background: "#fff", borderRadius: "inherit", overflow: "hidden",
      display: "flex", flexDirection: "column", height: "100%" }}>
      <div style={{ display: "flex", alignItems: "center", gap: 11, padding: "15px 18px",
        borderBottom: "1px solid var(--line)", flex: "none" }}>
        <span style={{ width: 28, height: 28, borderRadius: 8, flex: "none", display: "flex",
          alignItems: "center", justifyContent: "center", background: "var(--accent-soft)", color: "var(--accent-700)" }}>
          <i className={`ph ph-${icon}`} style={{ fontSize: 16 }} /></span>
        <span style={{ fontFamily: "var(--font-display)", fontSize: 14.5, fontWeight: 500,
          letterSpacing: "-.01em", color: "var(--ink)", whiteSpace: "nowrap" }}>{title}</span>
        {badge && <span style={{ marginLeft: "auto", fontSize: 11, fontWeight: 500, color: "var(--ink-4)", whiteSpace: "nowrap" }}>{badge}</span>}
      </div>
      <div style={{ flex: 1, minHeight: 0 }}>{children}</div>
    </div>
  );
}

function GradMark({ s = 26, r = 8 }) {
  return <span style={{ width: s, height: s, borderRadius: r, flex: "none",
    background: "radial-gradient(at 70% 30%, var(--orange-400) 0%, transparent 60%), radial-gradient(at 20% 80%, var(--purple-300) 0%, transparent 60%), var(--accent)" }} />;
}

/* ══ HERO SHOT — DecidrOS workspace showing the roadmap ══ */
function HeroShot() {
  const nav = [["squares-four","Workspace",0],["map-trifold","Roadmap",1],["robot","Agents",0],["tree-structure","Knowledge",0],["chart-line-up","Metrics",0]];
  const phases = [
    { p:"Phase 1", t:"Define & migrate", d:"0–90 days", on:true, items:["Agent platform","Reporting GPT","Compliance agent"] },
    { p:"Phase 2", t:"Build & automate", d:"90–180 days", on:false, items:["Proposal generator","ICP qualifier","Outreach"] },
    { p:"Phase 3", t:"Scale & evolve", d:"180–365 days", on:false, items:["Client health","Competitive watch","Self-tuning"] },
  ];
  return (
    <div className="shot-frame" style={{ borderRadius: "var(--r-frame)", border: "1px solid var(--line)",
      boxShadow: "var(--sh-lg)", overflow: "hidden", background: "#fff" }}>
        <div style={{ display: "grid", gridTemplateColumns: "188px 1fr", height: "100%", minHeight: 408 }}>
          {/* rail */}
          <aside style={{ borderRight: "1px solid var(--line)", padding: "16px 12px",
            display: "flex", flexDirection: "column", gap: 4, background: "#fff" }}>
            <div style={{ display: "flex", alignItems: "center", gap: 9, padding: "2px 6px 14px" }}>
              <GradMark s={24} />
              <b style={{ fontFamily: "var(--font-display)", fontSize: 17, fontWeight: 500, letterSpacing: "-.03em", color: "var(--ink)" }}>Decidr</b>
            </div>
            {nav.map(([ic,l,on]) => (
              <span key={l} style={{ display:"flex", alignItems:"center", gap:10, padding:"8px 9px",
                borderRadius:8, fontSize:13.5, fontWeight: on?500:400,
                color: on?"var(--accent-700)":"var(--ink-3)", background: on?"var(--accent-soft)":"transparent" }}>
                <i className={`ph ph-${ic}`} style={{ fontSize:17 }} />{l}
              </span>
            ))}
            <div style={{ marginTop:"auto", padding:"11px 12px", borderRadius:12,
              background:"var(--gradient-aurora, var(--soft))", fontSize:11.5 }}>
              <div style={{ fontWeight:500, color:"var(--ink-2)", marginBottom:3 }}>DecidrOS</div>
              <div style={{ color:"var(--ink-4)" }}>Realising the unimaginable.</div>
            </div>
          </aside>
          {/* main */}
          <main style={{ padding: "20px 22px", background: "var(--soft)", overflow: "hidden" }}>
            <div style={{ display:"flex", alignItems:"center", gap:12, marginBottom:18 }}>
              <div>
                <div style={{ fontFamily:"var(--font-display)", fontSize:20, fontWeight:500, letterSpacing:"-.02em", color:"var(--ink)" }}>AI Roadmap</div>
                <div style={{ fontSize:12.5, color:"var(--ink-4)", marginTop:2 }}>12 months · 3 phases · sequenced</div>
              </div>
              <span style={{ marginLeft:"auto", display:"inline-flex", alignItems:"center", gap:6, fontSize:12,
                fontWeight:500, color:"var(--green-700)", background:"var(--green-100)", padding:"5px 11px", borderRadius:999 }}>
                <i className="ph-fill ph-circle" style={{ fontSize:8 }} />Phase 1 live in 90 days
              </span>
            </div>
            <div style={{ display:"grid", gridTemplateColumns:"repeat(3,1fr)", gap:12 }}>
              {phases.map((ph) => (
                <div key={ph.p} style={{ background:"#fff", border:`1px solid ${ph.on?"var(--accent)":"var(--line)"}`,
                  borderRadius:14, padding:"14px 14px 12px", boxShadow: ph.on?"var(--sh-md)":"none", position:"relative" }}>
                  {ph.on && <span style={{ position:"absolute", top:12, right:12, width:7, height:7, borderRadius:999, background:"var(--accent)" }} />}
                  <div style={{ fontSize:11, fontWeight:600, letterSpacing:".06em", textTransform:"uppercase", color: ph.on?"var(--accent-700)":"var(--ink-4)" }}>{ph.p}</div>
                  <div style={{ fontFamily:"var(--font-display)", fontSize:15.5, fontWeight:500, color:"var(--ink)", margin:"5px 0 2px", letterSpacing:"-.01em" }}>{ph.t}</div>
                  <div style={{ fontSize:11.5, color:"var(--ink-4)", marginBottom:11 }}>{ph.d}</div>
                  <div style={{ display:"flex", flexDirection:"column", gap:6 }}>
                    {ph.items.map((it,i) => (
                      <div key={it} style={{ display:"flex", alignItems:"center", gap:7, fontSize:12, color:"var(--ink-2)" }}>
                        <i className={ph.on ? "ph-fill ph-check-circle" : "ph ph-circle"} style={{ fontSize:13, color: ph.on?"var(--green-500)":"var(--line-2)" }} />{it}
                      </div>
                    ))}
                  </div>
                </div>
              ))}
            </div>
            {/* compliance strip */}
            <div style={{ marginTop:14, background:"#fff", border:"1px solid var(--line)", borderRadius:14, padding:"14px 16px",
              display:"flex", alignItems:"center", gap:16 }}>
              <span style={{ width:34, height:34, borderRadius:9, flex:"none", display:"flex", alignItems:"center", justifyContent:"center",
                background:"var(--accent-soft)", color:"var(--accent-700)" }}><i className="ph ph-shield-check" style={{ fontSize:18 }} /></span>
              <div style={{ flex:1, minWidth:0 }}>
                <div style={{ fontSize:13, fontWeight:500, color:"var(--ink)" }}>Workflow compliance agent</div>
                <div style={{ fontSize:11.5, color:"var(--ink-4)" }}>Monitoring 7 checkpoints · 0 open deviations</div>
              </div>
              <div style={{ display:"flex", gap:18, textAlign:"right" }}>
                <div><div style={{ fontFamily:"var(--font-display)", fontSize:19, fontWeight:500, color:"var(--ink)" }}>100%</div><div style={{ fontSize:10.5, color:"var(--ink-4)" }}>on sequence</div></div>
                <div><div style={{ fontFamily:"var(--font-display)", fontSize:19, fontWeight:500, color:"var(--ink)" }}>2m</div><div style={{ fontSize:10.5, color:"var(--ink-4)" }}>alert latency</div></div>
              </div>
            </div>
          </main>
        </div>
    </div>
  );
}

/* ══ STEP 1 — discovery findings (five friction points) ══ */
function MockDiscovery() {
  const rows = [
    ["Workflow compliance","Deviation from defined steps","High"],
    ["Manual reporting","Reports built by hand","High"],
    ["Document generation","SoW and ToS drafted manually","Medium"],
    ["Capacity modelling","Works, but disconnected","Medium"],
    ["Sentiment tracking","Weekly scores unreliable","Low"],
  ];
  const tone = { High:["var(--orange-400)","var(--orange-50)","var(--orange-700)"], Medium:["var(--yellow-500)","var(--yellow-50)","var(--yellow-800)"], Low:["var(--grey-400)","var(--grey-100)","var(--grey-700)"] };
  return (
    <div style={{ height:"100%" }}><Panel icon="magnifying-glass" title="Discovery findings">
      <div style={{ padding:"18px 20px" }}>
        <div style={{ fontSize:12, color:"var(--ink-3)", marginBottom:14 }}>Five points found · same root cause</div>
        <div style={{ display:"flex", flexDirection:"column" }}>
          {rows.map(([t,d,sev],i) => { const c = tone[sev]; return (
            <div key={t} style={{ display:"flex", alignItems:"center", gap:13, padding:"12px 2px",
              borderTop: i===0 ? "none" : "1px solid var(--line)" }}>
              <span style={{ width:24, height:24, borderRadius:7, flex:"none", display:"flex", alignItems:"center", justifyContent:"center",
                background:"var(--soft)", color:"var(--ink-3)", fontFamily:"var(--font-display)", fontSize:12.5, fontWeight:500 }}>{i+1}</span>
              <div style={{ flex:1, minWidth:0 }}>
                <div style={{ fontSize:13.5, fontWeight:500, color:"var(--ink)" }}>{t}</div>
                <div style={{ fontSize:12, color:"var(--ink-3)" }}>{d}</div>
              </div>
              <span style={{ fontSize:11, fontWeight:500, color:c[2], background:c[1], padding:"4px 10px", borderRadius:999 }}>{sev}</span>
            </div>
          ); })}
        </div>
      </div>
    </Panel></div>
  );
}

/* ══ STEP 2 — three themes, twelve months ══ */
function MockThemes() {
  const themes = [
    ["map-pin-line","Operational","Monitor, detect and enforce compliance in near real time"],
    ["briefcase","Commercial","First-draft reports, SoWs and proposals from your records"],
    ["chart-donut","Business","Track client health and connect the blocks model to pipeline"],
  ];
  return (
    <div style={{ height:"100%" }}><Panel icon="stack" title="Strategic framework">
      <div style={{ padding:"18px 20px" }}>
        <div style={{ fontSize:12, color:"var(--ink-3)", marginBottom:14 }}>Three themes · one operating system</div>
        <div style={{ display:"flex", flexDirection:"column" }}>
          {themes.map(([ic,t,d],i) => (
            <div key={t} style={{ display:"flex", gap:13, padding:"15px 2px", alignItems:"center",
              borderTop: i===0 ? "none" : "1px solid var(--line)" }}>
              <span style={{ width:38, height:38, borderRadius:10, flex:"none", display:"flex", alignItems:"center", justifyContent:"center",
                background:"var(--soft-2)", color:"var(--ink-4)" }}><i className={`ph ph-${ic}`} style={{ fontSize:20 }} /></span>
              <div>
                <div style={{ fontFamily:"var(--font-display)", fontSize:15, fontWeight:500, color:"var(--ink)", letterSpacing:"-.01em" }}>{t} intelligence</div>
                <div style={{ fontSize:12.5, color:"var(--ink-3)", lineHeight:1.45, marginTop:2 }}>{d}</div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </Panel></div>
  );
}

/* ══ STEP 3 — deterministic, inspectable agent run ══ */
function MockFlow() {
  const steps = [
    ["Read canonical record","Golden Record · client #4192","done"],
    ["Apply ICP criteria","12 rules · deterministic","done"],
    ["Draft proposal","From service catalogue","done"],
    ["Write back decision","Versioned · 14:02 AEST","run"],
  ];
  return (
    <div style={{ height:"100%" }}><Panel icon="shield-check" title="Agent run">
      <div style={{ padding:"18px 20px" }}>
        <div style={{ display:"flex", alignItems:"center", gap:8, marginBottom:16 }}>
          <span style={{ fontSize:12.5, fontWeight:500, color:"var(--ink)" }}>Proposal generator</span>
          <span style={{ fontSize:11, fontWeight:500, color:"var(--green-700)", background:"var(--green-100)", padding:"3px 9px", borderRadius:999 }}>Deterministic</span>
        </div>
        <div style={{ position:"relative", display:"flex", flexDirection:"column", gap:2 }}>
          {steps.map(([t,d,st],i) => (
            <div key={t} style={{ display:"flex", gap:13, padding:"4px 0" }}>
              <div style={{ display:"flex", flexDirection:"column", alignItems:"center" }}>
                <span style={{ width:22, height:22, borderRadius:999, flex:"none", display:"flex", alignItems:"center", justifyContent:"center",
                  background: st==="run"?"var(--accent)":"var(--green-500)", color:"#fff" }}>
                  <i className={st==="run"?"ph ph-arrow-clockwise":"ph-bold ph-check"} style={{ fontSize:12 }} /></span>
                {i<steps.length-1 && <span style={{ width:2, flex:1, minHeight:18, background:"var(--line-2)", marginTop:2 }} />}
              </div>
              <div style={{ paddingBottom:10 }}>
                <div style={{ fontSize:13.5, fontWeight:500, color:"var(--ink)" }}>{t}</div>
                <div style={{ fontSize:12, color:"var(--ink-4)", fontFamily:"var(--font-mono)" }}>{d}</div>
              </div>
            </div>
          ))}
        </div>
      </div>
    </Panel></div>
  );
}

Object.assign(window, { HeroShot, MockDiscovery, MockThemes, MockFlow });
