// eSignature module page, extends the generic ModulePage template
// with two custom sections: "Configure your way" + contract-touch spectrum.

// ─── Section 1: Native eSignature ────────────────────────────────────────────

function SignatureNativeAnimation() {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setTick((t) => (t + 1) % 9), 1100);
    return () => clearInterval(id);
  }, []);
  const show = (n) => tick >= n;

  const signers = [
    { name: "Linnea Andersson", role: "CFO · Volantis AB", signed: tick >= 3 },
    { name: "Erik Hagberg",     role: "CEO · Volantis AB", signed: tick >= 5 },
    { name: "Maya Karlsson",    role: "GC · Velora",       signed: tick >= 7 },
  ];

  const signedCount = signers.filter(s => s.signed).length;

  return (
    <div style={{ position: "relative", paddingBottom: 24 }}>

      {/* Device ping, slides in at tick 1 */}
      <div style={{
        position: "absolute", top: -20, right: 0,
        opacity: show(1) && !show(4) ? 1 : 0,
        transform: show(1) && !show(4) ? "translateY(0) scale(1)" : "translateY(-8px) scale(0.94)",
        transition: "all 360ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--bg-elevated)",
        border: "1px solid var(--line)",
        borderRadius: 10,
        boxShadow: "0 8px 24px -8px rgba(14,14,16,0.14)",
        padding: "7px 12px",
        display: "flex", alignItems: "center", gap: 8,
        fontSize: 11.5, zIndex: 4, whiteSpace: "nowrap",
      }}>
        {/* Phone icon */}
        <span style={{ color: "var(--accent)", display: "grid", placeItems: "center" }}>
          <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
            <rect x="5" y="2" width="14" height="20" rx="2"/>
            <line x1="12" y1="18" x2="12" y2="18.01"/>
          </svg>
        </span>
        <span style={{ color: "var(--ink-2)" }}>Signature request received <strong style={{ color: "var(--ink-1)" }}>· any device</strong></span>
      </div>

      {/* Main panel */}
      <div style={{
        background: "var(--bg-elevated)",
        border: "1px solid var(--line)",
        borderRadius: 16,
        overflow: "hidden",
        boxShadow: "0 30px 60px -20px rgba(14,14,16,0.10), 0 4px 12px -4px rgba(14,14,16,0.04)",
      }}>
        {/* Header */}
        <div style={{
          padding: "13px 18px",
          borderBottom: "1px solid var(--line)",
          display: "flex", alignItems: "center", justifyContent: "space-between",
          background: tick >= 7 ? "rgba(31,138,76,0.04)" : "var(--bg-elevated)",
          transition: "background 600ms ease",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <span style={{ color: "var(--accent)" }}>
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
                <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
                <polyline points="14 2 14 8 20 8"/>
              </svg>
            </span>
            <span style={{ fontSize: 12, fontWeight: 500, color: "var(--ink-1)" }}>MSA_Velora_v4-final.pdf</span>
          </div>
          <span style={{
            fontSize: 10.5, fontFamily: "var(--font-mono)", padding: "2px 8px",
            borderRadius: 99,
            background: tick >= 7 ? "rgba(31,138,76,0.10)" : "var(--bg-soft)",
            color: tick >= 7 ? "var(--success)" : "var(--ink-4)",
            transition: "all 500ms ease",
          }}>
            {tick >= 7 ? "COMPLETE" : `${signedCount} / ${signers.length} SIGNED`}
          </span>
        </div>

        {/* Progress bar */}
        <div style={{ height: 3, background: "var(--bg-soft)" }}>
          <div style={{
            height: "100%",
            width: (signedCount / signers.length * 100) + "%",
            background: tick >= 7 ? "var(--success)" : "var(--accent)",
            transition: "width 600ms cubic-bezier(.4,0,.2,1), background 400ms ease",
          }} />
        </div>

        {/* Signers */}
        <div style={{ padding: "14px 18px" }}>
          {signers.map((s, i) => (
            <div key={i} style={{
              display: "flex", alignItems: "center", gap: 10,
              padding: "9px 0",
              borderBottom: i < signers.length - 1 ? "1px solid var(--line)" : "none",
            }}>
              <span style={{
                width: 26, height: 26, borderRadius: "50%", flexShrink: 0,
                background: s.signed ? "#10B981" : "var(--bg-soft)",
                display: "grid", placeItems: "center",
                color: s.signed ? "white" : "var(--ink-5)",
                transition: "background 500ms ease",
                boxShadow: s.signed ? "0 2px 8px rgba(16,185,129,0.30)" : "none",
              }}>
                {s.signed
                  ? <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3"><polyline points="20 6 9 17 4 12"/></svg>
                  : <span style={{ fontSize: 9, fontFamily: "var(--font-mono)" }}>{i + 1}</span>
                }
              </span>
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ fontSize: 12.5, fontWeight: 500, color: "var(--ink-1)" }}>{s.name}</div>
                <div style={{ fontSize: 11, color: "var(--ink-4)" }}>{s.role}</div>
              </div>
              <span style={{
                fontSize: 10.5, fontFamily: "var(--font-mono)", letterSpacing: "0.04em",
                color: s.signed ? "var(--success)" : "var(--ink-5)",
                transition: "color 400ms ease",
              }}>
                {s.signed ? "SIGNED" : "PENDING"}
              </span>
            </div>
          ))}
        </div>

        {/* eIDAS badge row */}
        <div style={{
          padding: "10px 18px",
          borderTop: "1px solid var(--line)",
          background: "var(--bg-soft)",
          display: "flex", alignItems: "center", justifyContent: "space-between",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
            <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2">
              <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
            </svg>
            <span style={{ fontSize: 11, color: "var(--ink-3)", fontFamily: "var(--font-mono)" }}>eIDAS AES · Tamper-evident</span>
          </div>
          {/* Device icons */}
          <div style={{ display: "flex", gap: 8, alignItems: "center" }}>
            {[
              // Desktop
              <svg key="d" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>,
              // Tablet
              <svg key="t" width="11" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8"><rect x="4" y="2" width="16" height="20" rx="2"/><line x1="12" y1="18" x2="12" y2="18.01"/></svg>,
              // Phone
              <svg key="p" width="10" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8"><rect x="5" y="2" width="14" height="20" rx="2"/><line x1="12" y1="18" x2="12" y2="18.01"/></svg>,
            ].map((icon, i) => (
              <span key={i} style={{ color: "var(--ink-4)", display: "grid", placeItems: "center" }}>{icon}</span>
            ))}
          </div>
        </div>
      </div>

      {/* Repository chip, floats up when complete */}
      <div style={{
        position: "absolute", bottom: 0, left: "50%",
        transform: show(7) ? "translateX(-50%) translateY(0) scale(1)" : "translateX(-50%) translateY(8px) scale(0.94)",
        opacity: show(7) ? 1 : 0,
        transition: "all 400ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--ink-1)",
        color: "white",
        borderRadius: 999,
        padding: "5px 14px",
        fontSize: 11.5, fontWeight: 500,
        display: "flex", alignItems: "center", gap: 6,
        whiteSpace: "nowrap",
        zIndex: 4,
      }}>
        <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
          <polyline points="20 6 9 17 4 12"/>
        </svg>
        Saved to Repository
      </div>
    </div>
  );
}

function SignatureNativeSection() {
  const bullets = [
    {
      icon: "sign",
      title: "Legally binding, everywhere",
      text: "Collect eIDAS-grade electronic signatures on any device, desktop, tablet, or mobile. No app download required.",
    },
    {
      icon: "analytics",
      title: "Real-time signing progress",
      text: "Monitor document status and signer activity as it happens. Know exactly where each contract stands at any moment.",
    },
    {
      icon: "repository",
      title: "Auto-saved to your Repository",
      text: "Every signed contract is automatically filed, indexed, and searchable in ContractControl's Repository, no manual upload.",
    },
  ];

  return (
    <section className="section" style={{ background: "var(--bg-soft)", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div className="feat-grid">
          {/* Left: copy */}
          <div>
            <span className="eyebrow">Native eSignature</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              No more hunting<br/><em>paper signatures</em>.
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              ContractControl's native digital signature solution is a faster, more secure, and efficient way to collect signatures, without bolting on a separate tool.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 24 }}>
              {bullets.map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </span>
                  <p style={{ fontSize: 14.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b.text}</p>
                </div>
              ))}
            </div>
          </div>

          {/* Right: animation */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureNativeAnimation />
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Section 2: Contract-touch spectrum ──────────────────────────────────────

function SignatureTouchSection() {
  const tiers = [
    {
      key: "high",
      label: "High-touch",
      tagStyle: { background: "rgba(181,101,29,0.08)", color: "var(--warning)", borderColor: "rgba(181,101,29,0.22)" },
      dotColor: "var(--warning)",
      headline: "Back-and-forth, handled.",
      desc: "Redlined contracts that need multiple rounds of negotiation before both sides are ready to sign. ContractControl keeps every version, comment, and redline in one place, so signing is a natural last step, not a fresh export.",
      bullets: [
        "Full negotiation history visible at signing",
        "Ordered or parallel signing workflows",
        "Reminder cadence per signer, per deadline",
      ],
    },
    {
      key: "low",
      label: "Low-touch",
      tagStyle: { background: "var(--accent-soft)", color: "var(--accent-ink)", borderColor: "rgba(110,86,207,0.20)" },
      dotColor: "var(--accent)",
      headline: "Configured once, signed fast.",
      desc: "Self-service agreements with moderate customisation, order forms, SOWs, contractor agreements. Teams fill a short intake form, the contract auto-populates, and a signature request goes out without legal lifting a finger.",
      bullets: [
        "Template-driven with variable fields",
        "Auto-route to the right signatory",
        "Click-accept or eSignature, your call",
      ],
    },
  ];

  return (
    <section className="section" style={{ background: "var(--bg-soft)", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        {/* Header */}
        <div className="cc-section-header" style={{ textAlign: "center", maxWidth: 720, margin: "0 auto 56px" }}>
          <span className="eyebrow">Every contract, the right flow</span>
          <h2 className="h-section" style={{ marginTop: 16 }}>
            High-touch or <em>low-touch</em>.
          </h2>
          <p className="lede" style={{ margin: "18px auto 0", textAlign: "center" }}>
            Not every contract needs the same signing experience. ContractControl adapts to the complexity of the deal, from redlined enterprise paper to templated self-service agreements.
          </p>
        </div>

        {/* Spectrum bar */}
        <div style={{
          display: "flex",
          alignItems: "center",
          gap: 0,
          marginBottom: 40,
          borderRadius: 999,
          overflow: "hidden",
          height: 6,
          background: "var(--bg-mute)",
        }}>
          <div style={{ flex: 1, height: "100%", background: "var(--warning)", opacity: 0.6 }} />
          <div style={{ flex: 1, height: "100%", background: "var(--accent)", opacity: 0.7 }} />
        </div>

        {/* Cards */}
        <div className="grid grid-2" style={{ gap: 20 }}>
          {tiers.map((t) => (
            <div key={t.key} className="card" style={{ padding: 28, display: "flex", flexDirection: "column", gap: 16 }}>
              <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
                <span style={{ width: 10, height: 10, borderRadius: "50%", background: t.dotColor, flexShrink: 0 }} />
                <span className="tag" style={{ ...t.tagStyle }}>{t.label}</span>
              </div>
              <div>
                <h3 className="h-card" style={{ marginBottom: 10 }}>{t.headline}</h3>
                <p style={{ fontSize: 13.5, color: "var(--ink-3)", lineHeight: 1.6, margin: 0 }}>{t.desc}</p>
              </div>
              <ul style={{ listStyle: "none", padding: 0, margin: "4px 0 0", display: "flex", flexDirection: "column", gap: 8 }}>
                {t.bullets.map((b, i) => (
                  <li key={i} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontSize: 13, color: "var(--ink-2)", lineHeight: 1.5 }}>
                    <span style={{ flex: "0 0 14px", marginTop: 4, color: t.dotColor }}>
                      <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4">
                        <polyline points="20 6 9 17 4 12"/>
                      </svg>
                    </span>
                    <span>{b}</span>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── Section: Secure & compliant ─────────────────────────────────────────────

function SignatureSecurityMockup() {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setTick((t) => (t + 1) % 8), 1100);
    return () => clearInterval(id);
  }, []);
  const show = (n) => tick >= n;

  const logs = [
    { action: "Document opened",        who: "Linnea Andersson", time: "09:41", show: 2 },
    { action: "OTP verified",           who: "Linnea Andersson", time: "09:42", show: 3 },
    { action: "Signature placed",       who: "Linnea Andersson", time: "09:43", show: 4 },
    { action: "Document opened",        who: "Erik Hagberg",     time: "10:02", show: 5 },
    { action: "OTP verified",           who: "Erik Hagberg",     time: "10:03", show: 6 },
  ];

  return (
    <div style={{
      background: "var(--bg-elevated)",
      border: "1px solid var(--line)",
      borderRadius: 16,
      overflow: "hidden",
      boxShadow: "0 30px 60px -20px rgba(14,14,16,0.10), 0 4px 12px -4px rgba(14,14,16,0.04)",
    }}>
      {/* Header */}
      <div style={{
        padding: "13px 18px",
        borderBottom: "1px solid var(--line)",
        display: "flex", alignItems: "center", gap: 8,
      }}>
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2">
          <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
        </svg>
        <span style={{ fontSize: 11, fontWeight: 500, letterSpacing: "0.14em", textTransform: "uppercase", color: "var(--ink-4)" }}>
          Security · MSA_Velora_v4-final.pdf
        </span>
      </div>

      <div style={{ padding: 18 }}>
        {/* Link expiry */}
        <div style={{
          padding: "10px 12px",
          borderRadius: 10,
          border: "1px solid var(--line)",
          background: "var(--bg-soft)",
          marginBottom: 12,
          display: "flex", alignItems: "center", justifyContent: "space-between",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--ink-3)" strokeWidth="1.8">
              <circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>
            </svg>
            <span style={{ fontSize: 12, color: "var(--ink-2)" }}>Link expires</span>
          </div>
          <span style={{ fontSize: 12, fontFamily: "var(--font-mono)", color: "var(--accent)", fontWeight: 500 }}>
            2026-05-31 · 23:59
          </span>
        </div>

        {/* OTP verification */}
        <div style={{
          padding: "10px 12px",
          borderRadius: 10,
          border: "1px solid " + (show(3) ? "rgba(31,138,76,0.25)" : "var(--line)"),
          background: show(3) ? "rgba(31,138,76,0.04)" : "var(--bg-soft)",
          marginBottom: 14,
          display: "flex", alignItems: "center", justifyContent: "space-between",
          transition: "all 400ms ease",
        }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke={show(3) ? "var(--success)" : "var(--ink-3)"} strokeWidth="1.8" style={{ transition: "stroke 400ms ease" }}>
              <rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>
            </svg>
            <span style={{ fontSize: 12, color: "var(--ink-2)" }}>OTP verification</span>
          </div>
          <span style={{
            fontSize: 10.5, fontFamily: "var(--font-mono)", letterSpacing: "0.04em",
            color: show(3) ? "var(--success)" : "var(--ink-4)",
            transition: "color 400ms ease",
          }}>
            {show(3) ? "VERIFIED" : "REQUIRED"}
          </span>
        </div>

        {/* Activity log */}
        <div style={{ fontSize: 11, fontWeight: 500, letterSpacing: "0.12em", textTransform: "uppercase", color: "var(--ink-4)", marginBottom: 10 }}>
          Activity log
        </div>
        <div style={{ display: "flex", flexDirection: "column" }}>
          {logs.map((e, i) => (
            <div key={i} style={{
              display: "flex", alignItems: "center", gap: 10,
              padding: "7px 0",
              borderBottom: i < logs.length - 1 ? "1px solid var(--line)" : "none",
              opacity: show(e.show) ? 1 : 0,
              transform: show(e.show) ? "translateY(0)" : "translateY(4px)",
              transition: "all 350ms cubic-bezier(.2,.8,.2,1)",
            }}>
              <span style={{ width: 6, height: 6, borderRadius: "50%", background: "var(--accent)", flexShrink: 0, opacity: 0.7 }} />
              <span style={{ flex: 1, fontSize: 12, color: "var(--ink-2)" }}>{e.action} · <span style={{ color: "var(--ink-4)" }}>{e.who}</span></span>
              <span style={{ fontSize: 11, color: "var(--ink-5)", fontFamily: "var(--font-mono)" }}>{e.time}</span>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

function SignatureSecuritySection() {
  const bullets = [
    { text: "Set expiration dates on contract links to control who can access them and when" },
    { text: "Verify signer identity with one-time passwords and unique IDs at every step" },
    { text: "Track every action on contracts with detailed, tamper-proof activity logs" },
  ];

  return (
    <section className="section">
      <div className="container">
        <div className="feat-grid">
          {/* Left: mockup */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureSecurityMockup />
          </div>

          {/* Right: copy */}
          <div>
            <span className="eyebrow">Security & compliance</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              Secure and globally <em>compliant</em>.
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              ContractControl Sign safeguards your data with industry-leading encryption and authentication, and ensures global compliance standards are met throughout the signing process.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
              {bullets.map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </span>
                  <p style={{ fontSize: 13.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b.text}</p>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Section: Collect anywhere ───────────────────────────────────────────────

function SignatureAnywhereAnimation() {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setTick((t) => (t + 1) % 8), 1100);
    return () => clearInterval(id);
  }, []);
  const show = (n) => tick >= n;

  return (
    <div style={{ position: "relative", minHeight: 340, display: "flex", alignItems: "center", justifyContent: "center" }}>

      {/* Phone silhouette */}
      <div style={{
        width: 160, height: 300,
        borderRadius: 24,
        border: "2px solid var(--line-strong)",
        background: "var(--bg-soft)",
        position: "relative",
        boxShadow: "0 20px 48px -12px rgba(14,14,16,0.12)",
      }}>
        {/* Screen content */}
        <div style={{ padding: "32px 12px 12px", height: "100%", display: "flex", flexDirection: "column", gap: 6 }}>
          {["", "", "", "", ""].map((_, i) => (
            <div key={i} style={{ height: 8, borderRadius: 4, background: "var(--bg-mute)", width: i === 0 ? "80%" : i === 2 ? "60%" : "90%" }} />
          ))}
          {/* Signature field */}
          <div style={{
            marginTop: 12,
            border: "1px dashed var(--line-strong)",
            borderRadius: 8,
            height: 48,
            display: "flex", alignItems: "center", justifyContent: "center",
            background: show(3) ? "rgba(110,86,207,0.04)" : "transparent",
            transition: "background 400ms ease",
          }}>
            {show(3) && (
              <svg width="80" height="20" viewBox="0 0 80 20" fill="none" style={{ overflow: "visible" }}>
                <path
                  d="M4 14 C8 6, 12 3, 16 10 C20 16, 22 3, 28 11 C32 17, 36 7, 42 12 C48 17, 50 6, 56 10"
                  stroke="var(--ink-2)" strokeWidth="1.6" strokeLinecap="round" fill="none"
                  style={{
                    strokeDasharray: 110,
                    strokeDashoffset: show(3) ? 0 : 110,
                    transition: "stroke-dashoffset 800ms cubic-bezier(.4,0,.2,1)",
                  }}
                />
              </svg>
            )}
          </div>
          {/* Confirm button */}
          <div style={{
            marginTop: 6,
            height: 28, borderRadius: 999,
            background: show(4) ? "var(--accent)" : "var(--bg-mute)",
            transition: "background 400ms ease",
            display: "flex", alignItems: "center", justifyContent: "center",
          }}>
            <span style={{ fontSize: 10, fontWeight: 500, color: show(4) ? "white" : "var(--ink-5)", transition: "color 400ms ease" }}>
              {show(4) ? "Signed ✓" : "Confirm"}
            </span>
          </div>
        </div>
        {/* Notch */}
        <div style={{ position: "absolute", top: 10, left: "50%", transform: "translateX(-50%)", width: 40, height: 6, borderRadius: 3, background: "var(--line-strong)" }} />
      </div>

      {/* Floating: email notification */}
      <div style={{
        position: "absolute", top: 20, left: -20,
        opacity: show(1) ? 1 : 0,
        transform: show(1) ? "translateY(0) scale(1)" : "translateY(-10px) scale(0.94)",
        transition: "all 380ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--bg-elevated)",
        border: "1px solid var(--line)",
        borderRadius: 12,
        boxShadow: "0 8px 24px -6px rgba(14,14,16,0.14)",
        padding: "10px 14px",
        minWidth: 210,
      }}>
        <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 4 }}>
          <span style={{ width: 18, height: 18, borderRadius: 4, background: "var(--accent-soft)", display: "grid", placeItems: "center", color: "var(--accent)" }}>
            <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
              <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/>
              <polyline points="22,6 12,13 2,6"/>
            </svg>
          </span>
          <span style={{ fontSize: 11.5, fontWeight: 500, color: "var(--ink-1)" }}>You have a contract to sign</span>
        </div>
        <div style={{ fontSize: 11, color: "var(--ink-4)", paddingLeft: 26 }}>MSA_Velora · via ContractControl</div>
      </div>

      {/* Floating: Slack alert */}
      <div style={{
        position: "absolute", bottom: 40, left: -30,
        opacity: show(2) ? 1 : 0,
        transform: show(2) ? "translateY(0) scale(1)" : "translateY(8px) scale(0.94)",
        transition: "all 380ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--bg-elevated)",
        border: "1px solid var(--line)",
        borderRadius: 12,
        boxShadow: "0 8px 24px -6px rgba(14,14,16,0.14)",
        padding: "10px 14px",
        minWidth: 190,
      }}>
        <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 4 }}>
          <span style={{ width: 18, height: 18, borderRadius: 4, background: "var(--bg-soft)", display: "grid", placeItems: "center", color: "var(--ink-3)" }}>
            <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
              <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
            </svg>
          </span>
          <span style={{ fontSize: 11.5, fontWeight: 500, color: "var(--ink-1)" }}>SMS · Reminder · signature pending</span>
        </div>
        <div style={{ fontSize: 11, color: "var(--ink-4)", paddingLeft: 26 }}>Erik Hagberg hasn't signed yet</div>
      </div>

      {/* Floating: confirmed chip */}
      <div style={{
        position: "absolute", top: 30, right: -20,
        opacity: show(5) ? 1 : 0,
        transform: show(5) ? "translateY(0) scale(1)" : "translateY(-8px) scale(0.94)",
        transition: "all 400ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--success)",
        color: "white",
        borderRadius: 999,
        padding: "6px 14px",
        fontSize: 11.5, fontWeight: 500,
        display: "flex", alignItems: "center", gap: 6,
        whiteSpace: "nowrap",
        boxShadow: "0 4px 14px -2px rgba(31,138,76,0.35)",
      }}>
        <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3">
          <polyline points="20 6 9 17 4 12"/>
        </svg>
        All signed · link expired
      </div>
    </div>
  );
}

function SignatureAnywhereSection() {
  const bullets = [
    { text: "Sign and request signatures from anywhere, on any device, laptop, phone, or tablet" },
    { text: "Get instant alerts and automated reminders via ContractControl, SMS, and email" },
    { text: "Request signatures via a shareable link, no account needed for the signer" },
  ];

  return (
    <section className="section">
      <div className="container">
        <div className="feat-grid feat-grid--flip">
          {/* Left: animation */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureAnywhereAnimation />
          </div>

          {/* Right: copy */}
          <div>
            <span className="eyebrow">Any device, any format</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              Collect signatures <em>effortlessly</em>, anywhere.
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              Accelerate your signing process with flexible options for collecting signatures across devices and formats, and keep everyone in the loop with timely notifications.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
              {bullets.map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </span>
                  <p style={{ fontSize: 14.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b.text}</p>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Full eSignature page ─────────────────────────────────────────────────────

function ESignaturePage() {
  const data = window.ccModuleData["signature"];
  return (
    <div>
      <ModuleHero {...data.hero} />

      {/* 3-column feature section (Precisely style) */}
      <section style={{ padding: "48px 0 24px", background: "transparent" }}>
        <div className="container">
          <div className="grid grid-3" style={{ gap: "40px" }}>
            <div>
              <p style={{ fontSize: "14.5px", lineHeight: "1.6", color: "var(--ink-2)", margin: 0 }}>
                <strong style={{ fontWeight: 600, color: "var(--ink-1)" }}>Native sign-off</strong> keeps signers on your platform. No redirects, no emails, no external vendor logins required to place a signature.
              </p>
            </div>
            <div>
              <p style={{ fontSize: "14.5px", lineHeight: "1.6", color: "var(--ink-2)", margin: 0 }}>
                <strong style={{ fontWeight: 600, color: "var(--ink-1)" }}>Qualified Electronic Signatures (QES)</strong> meet strict eIDAS requirements. Verify identity with local bank IDs before sealing documents.
              </p>
            </div>
            <div>
              <p style={{ fontSize: "14.5px", lineHeight: "1.6", color: "var(--ink-2)", margin: 0 }}>
                <strong style={{ fontWeight: 600, color: "var(--ink-1)" }}>Cryptographic sealing</strong> guarantees document integrity. Any modification after signature immediately invalidates the certificate.
              </p>
            </div>
          </div>
        </div>
      </section>

      <LogoStrip />
      <ModuleMetrics {...data.metrics} />
      <SignatureNativeSection />
      <SignatureSecuritySection />
      <SignatureTouchSection />
      <SignatureAnywhereSection />
      <ModuleFeatures name={data.featuresName || data.name.toLowerCase()} features={data.features} />
      <ModuleQuote {...data.quote} />
      <SignatureWorkflowSection />
      <SignatureRemindersSection />
      <SignatureAutoFiledSection />
      <SignatureEidSection />
      <DepartmentShowcase />
      <ModuleCTA {...data.cta} />
      <SignatureFAQSection />
    </div>
  );
}

// ─── Section: Signing workflows ──────────────────────────────────────────────

function SignatureWorkflowMockup() {
  const rules = [
    { condition: "Contract value", op: ">", value: "€50,000", route: "CFO sign-off" },
    { condition: "Contract type", op: "=", value: "DPA / Data",  route: "DPO review first" },
    { condition: "Counterparty region", op: "=", value: "Outside EU", route: "Legal approval" },
  ];

  const signers = [
    { name: "Erik Hagberg",  role: "CEO",  status: "required", color: "var(--accent)" },
    { name: "Linnea A.",     role: "CFO",  status: "if >€50k", color: "#E8B339" },
    { name: "Maya Karlsson", role: "GC",   status: "cc only",  color: "var(--ink-4)" },
  ];

  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
      {/* Rule builder */}
      <div style={{ background: "var(--bg-elevated)", border: "1px solid var(--line)", borderRadius: 14, overflow: "hidden" }}>
        <div style={{ padding: "11px 16px", background: "var(--bg-soft)", borderBottom: "1px solid var(--line)", display: "flex", alignItems: "center", gap: 8 }}>
          <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2"><path d="M22 3H2l8 9.46V19l4 2v-8.54L22 3z"/></svg>
          <span style={{ fontSize: 11.5, fontWeight: 500, color: "var(--ink-2)" }}>Signing rules · MSA template</span>
        </div>
        <div style={{ padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }}>
          {rules.map((r, i) => (
            <div key={i}
              style={{
                display: "flex", alignItems: "center", gap: 8, padding: "9px 12px",
                borderRadius: 9, border: "1px solid var(--line)",
                background: "var(--bg-soft)",
                cursor: "default",
              }}>
              <span style={{ fontSize: 11.5, color: "var(--ink-4)", minWidth: 120 }}>{r.condition}</span>
              <span style={{ fontSize: 11, fontFamily: "var(--font-mono)", background: "var(--bg-mute)", padding: "2px 7px", borderRadius: 5, color: "var(--ink-3)" }}>{r.op}</span>
              <span style={{ fontSize: 12, fontWeight: 600, color: "var(--ink-1)", fontFamily: "var(--font-mono)", flex: 1 }}>{r.value}</span>
              <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--ink-4)" strokeWidth="2"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>
              <span style={{ fontSize: 12, fontWeight: 500, color: "var(--ink-2)" }}>{r.route}</span>
            </div>
          ))}
        </div>
      </div>

      {/* Signing order */}
      <div style={{ background: "var(--bg-elevated)", border: "1px solid var(--line)", borderRadius: 14, overflow: "hidden" }}>
        <div style={{ padding: "11px 16px", background: "var(--bg-soft)", borderBottom: "1px solid var(--line)" }}>
          <span style={{ fontSize: 11.5, fontWeight: 500, color: "var(--ink-2)" }}>Signing order · auto-configured</span>
        </div>
        <div style={{ padding: "12px 16px", display: "flex", flexDirection: "column", gap: 0 }}>
          {signers.map((s, i) => (
            <div key={i} style={{ display: "flex", alignItems: "center", gap: 12, padding: "9px 0", borderBottom: i < signers.length - 1 ? "1px solid var(--line)" : "none" }}>
              {/* Step number with connector */}
              <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 0 }}>
                <div style={{ width: 24, height: 24, borderRadius: "50%", background: s.color, display: "grid", placeItems: "center", flexShrink: 0 }}>
                  <span style={{ fontSize: 10, fontWeight: 700, color: s.color === "var(--ink-4)" ? "white" : "white" }}>{i + 1}</span>
                </div>
              </div>
              <div style={{ flex: 1 }}>
                <span style={{ fontSize: 13, fontWeight: 500, color: "var(--ink-1)" }}>{s.name}</span>
                <span style={{ fontSize: 11.5, color: "var(--ink-4)", marginLeft: 8 }}>{s.role}</span>
              </div>
              <span style={{ fontSize: 11, padding: "2px 9px", borderRadius: 99, fontWeight: 500,
                background: s.status === "required" ? "rgba(110,86,207,0.08)" : s.status === "cc only" ? "var(--bg-soft)" : "rgba(232,179,57,0.10)",
                color: s.status === "required" ? "var(--accent)" : s.status === "cc only" ? "var(--ink-4)" : "#B8860B",
                border: "1px solid " + (s.status === "required" ? "rgba(110,86,207,0.18)" : s.status === "cc only" ? "var(--line)" : "rgba(232,179,57,0.25)"),
              }}>{s.status}</span>
            </div>
          ))}
        </div>
        <div style={{ padding: "10px 16px", borderTop: "1px solid var(--line)", background: "var(--bg-soft)", display: "flex", alignItems: "center", gap: 6 }}>
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5"><polyline points="20 6 9 17 4 12"/></svg>
          <span style={{ fontSize: 11.5, color: "var(--ink-3)" }}>Order auto-adjusts when rules match at submission</span>
        </div>
      </div>
    </div>
  );
}

function SignatureWorkflowSection() {
  return (
    <section className="section" style={{ background: "var(--bg-soft)", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div className="feat-grid">
          {/* Left: mockup */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureWorkflowMockup />
          </div>

          {/* Right: copy */}
          <div>
            <span className="eyebrow">Smart signing workflows</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              Route to the right signers, <em>automatically</em>.
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              Set up rules once and ContractControl handles the rest, routing contracts to the right signatories based on deal value, contract type, or counterparty region. No manual coordination, no missed sign-offs.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
              {[
                { text: "Define signing order, sequential, parallel, or conditional" },
                { text: "Rules trigger automatically at submission, no manual step needed" },
                { text: "Escalate or reassign at any point without breaking the audit trail" },
              ].map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </span>
                  <p style={{ fontSize: 14.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b.text}</p>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Section: Automatic reminders ───────────────────────────────────────────

function SignatureRemindersMockup() {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setTick((t) => (t + 1) % 5), 1400);
    return () => clearInterval(id);
  }, []);
  const show = (n) => tick >= n;

  const rules = [
    { label: "Not opened after sending", days: "3 days", date: "Nov 1", active: true },
    { label: "Document not yet signed", days: "7 days", date: "Nov 5", active: true },
    { label: "Expiry date approaching", days: "30 days", date: "Mar 1", active: false },
  ];

  // Animated notification chip
  const notifVisible = tick === 2 || tick === 4;

  return (
    <div style={{ position: "relative" }}>
      {/* Floating notification */}
      <div style={{
        position: "absolute", top: -20, right: 0,
        opacity: notifVisible ? 1 : 0,
        transform: notifVisible ? "translateY(0) scale(1)" : "translateY(-10px) scale(0.94)",
        transition: "all 380ms cubic-bezier(.2,.8,.2,1)",
        background: "var(--bg-elevated)", border: "1px solid var(--line)",
        borderRadius: 10, boxShadow: "0 8px 24px -8px rgba(14,14,16,0.14)",
        padding: "7px 12px", display: "flex", alignItems: "center", gap: 8,
        fontSize: 11.5, zIndex: 4, whiteSpace: "nowrap",
      }}>
        <span style={{ width: 20, height: 20, borderRadius: 6, background: "rgba(110,86,207,0.12)", display: "grid", placeItems: "center" }}>
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2.2">
            <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>
          </svg>
        </span>
        <span style={{ color: "var(--ink-2)" }}>Reminder sent to <strong style={{ color: "var(--ink-1)" }}>Erik Hagberg</strong></span>
      </div>

      <div style={{
        background: "var(--bg-elevated)", border: "1px solid var(--line)",
        borderRadius: 16, overflow: "hidden",
        boxShadow: "0 30px 60px -20px rgba(14,14,16,0.10), 0 4px 12px -4px rgba(14,14,16,0.04)",
      }}>
        {/* Header */}
        <div style={{ padding: "12px 16px", borderBottom: "1px solid var(--line)", background: "var(--bg-soft)", display: "flex", alignItems: "center", gap: 8 }}>
          <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2">
            <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>
          </svg>
          <span style={{ fontSize: 12, fontWeight: 500, color: "var(--ink-1)" }}>Automatic reminders · MSA v4-final.pdf</span>
          {/* Toggle */}
          <div style={{ marginLeft: "auto", display: "flex", alignItems: "center", gap: 6 }}>
            <div style={{ width: 28, height: 16, borderRadius: 99, background: "var(--accent)", position: "relative", cursor: "default" }}>
              <div style={{ position: "absolute", right: 2, top: 2, width: 12, height: 12, borderRadius: "50%", background: "#fff" }} />
            </div>
            <span style={{ fontSize: 11, color: "var(--ink-3)" }}>on</span>
          </div>
        </div>

        {/* Reminder rules */}
        <div style={{ padding: "12px 16px", display: "flex", flexDirection: "column", gap: 6 }}>
          {rules.map((r, i) => (
            <div key={i} style={{
              display: "flex", alignItems: "center", gap: 10,
              padding: "10px 12px", borderRadius: 9,
              border: "1px solid " + (r.active ? "var(--line)" : "rgba(14,14,16,0.05)"),
              background: r.active ? "var(--bg)" : "var(--bg-soft)",
              opacity: show(i) ? 1 : 0.3,
              transition: "opacity 360ms",
            }}>
              <div style={{ flex: 1 }}>
                <div style={{ fontSize: 12.5, fontWeight: 500, color: r.active ? "var(--ink-1)" : "var(--ink-4)", marginBottom: 2 }}>{r.label}</div>
              </div>
              <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
                <span style={{ fontSize: 11.5, fontFamily: "var(--font-mono)", padding: "3px 9px", borderRadius: 6, background: r.active ? "rgba(110,86,207,0.08)" : "var(--bg-soft)", color: r.active ? "var(--accent-deep)" : "var(--ink-5)", border: "1px solid " + (r.active ? "rgba(110,86,207,0.16)" : "var(--line)") }}>
                  {r.days}
                </span>
                <span style={{ fontSize: 11, color: "var(--ink-5)", fontFamily: "var(--font-mono)" }}>{r.date}</span>
              </div>
              {/* Active dot */}
              <div style={{ width: 6, height: 6, borderRadius: "50%", background: r.active ? "#4DBA6E" : "var(--ink-5)", flexShrink: 0 }} />
            </div>
          ))}
        </div>

        {/* Footer status */}
        <div style={{ padding: "10px 16px", borderTop: "1px solid var(--line)", background: "var(--bg-soft)", display: "flex", alignItems: "center", gap: 6 }}>
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="var(--success)" strokeWidth="2.5"><polyline points="20 6 9 17 4 12"/></svg>
          <span style={{ fontSize: 11.5, color: "var(--ink-3)" }}>2 reminders active · 1 sent this week</span>
        </div>
      </div>
    </div>
  );
}

function SignatureRemindersSection() {
  return (
    <section className="section">
      <div className="container">
        <div className="feat-grid">
          {/* Left: copy */}
          <div>
            <span className="eyebrow">Automatic reminders</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              Stop chasing. <em>Let it run.</em>
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              Set reminder rules once and ContractControl handles the follow-up, automatically nudging signers when a document hasn't been opened, hasn't been signed, or is nearing expiry.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
              {[
                { text: "Trigger reminders when documents go unread or unsigned past your threshold" },
                { text: "Expiry reminders sent before contracts lapse, no renewals missed" },
                { text: "Every reminder logged in the audit trail, with timestamps" },
              ].map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
                      <polyline points="20 6 9 17 4 12"/>
                    </svg>
                  </span>
                  <p style={{ fontSize: 14.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b.text}</p>
                </div>
              ))}
            </div>
          </div>
          {/* Right: mockup */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureRemindersMockup />
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Section: Auto-filed signatures ─────────────────────────────────────────

function SignatureInboxMockup() {
  const requests = [
    { name: "MSA · Velora Industries",  from: "Sent by Legal · Anna Sjöberg", due: "Due today",    urgent: true,  active: true  },
    { name: "Order Form · Kvist Group", from: "Sent by Sales · Erik Lund",     due: "Due in 2 days", urgent: false, active: false },
    { name: "NDA · Brevia",             from: "Sent by Legal · Anna Sjöberg",  due: "Due in 5 days", urgent: false, active: false },
  ];
  return (
    <div style={{ background: "var(--bg-elevated)", border: "1px solid var(--line)", borderRadius: 16, overflow: "hidden", boxShadow: "0 30px 60px -20px rgba(14,14,16,0.10), 0 4px 12px -4px rgba(14,14,16,0.04)" }}>
      {/* Header */}
      <div style={{ padding: "12px 16px", borderBottom: "1px solid var(--line)", display: "flex", alignItems: "center", gap: 8, background: "var(--bg-soft)" }}>
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
        <span style={{ fontSize: 12, fontWeight: 500, color: "var(--ink-1)" }}>Awaiting your signature</span>
        <span style={{ marginLeft: "auto", fontSize: 10.5, padding: "2px 8px", borderRadius: 99, background: "rgba(232,90,57,0.08)", color: "#C0391B", border: "1px solid rgba(232,90,57,0.2)", fontWeight: 600 }}>3 pending</span>
      </div>
      {/* Request list */}
      {requests.map((r, i) => (
        <div key={i} style={{
          padding: "12px 16px",
          borderBottom: i < requests.length - 1 ? "1px solid var(--line)" : "none",
          background: r.active ? "var(--accent-soft)" : "transparent",
          borderLeft: r.active ? "3px solid var(--accent)" : "3px solid transparent",
        }}>
          <div style={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 12 }}>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 12.5, fontWeight: 500, color: r.active ? "var(--accent)" : "var(--ink-1)" }}>{r.name}</div>
              <div style={{ fontSize: 11, color: "var(--ink-4)", marginTop: 2 }}>{r.from}</div>
            </div>
            <span style={{ fontSize: 10.5, padding: "2px 7px", borderRadius: 99, fontWeight: 600, flexShrink: 0,
              background: r.urgent ? "rgba(232,90,57,0.08)" : "var(--bg-soft)",
              color: r.urgent ? "#C0391B" : "var(--ink-4)",
              border: r.urgent ? "1px solid rgba(232,90,57,0.2)" : "1px solid var(--line)",
            }}>{r.due}</span>
          </div>
          {r.active && (
            <div style={{ marginTop: 10, display: "flex", gap: 8 }}>
              <button style={{ fontSize: 11.5, padding: "5px 14px", borderRadius: 7, background: "var(--accent)", color: "#fff", border: "none", cursor: "pointer", fontWeight: 500 }}>
                Review &amp; sign
              </button>
              <button style={{ fontSize: 11.5, padding: "5px 12px", borderRadius: 7, background: "transparent", color: "var(--ink-3)", border: "1px solid var(--line)", cursor: "pointer" }}>
                View contract
              </button>
            </div>
          )}
        </div>
      ))}
    </div>
  );
}

function SignatureAutoFiledSection() {
  return (
    <section className="section" style={{ borderTop: "1px solid var(--line)" }}>
      <div className="container">
        <div className="feat-grid feat-grid--flip">
          {/* Left: copy */}
          <div>
            <span className="eyebrow">Signature inbox</span>
            <h2 className="h-section" style={{ marginTop: 16, marginBottom: 20 }}>
              Your signature requests, <em>right here</em>.
            </h2>
            <p className="lede" style={{ marginBottom: 40 }}>
              When a contract needs your signature, it shows up directly in ContractControl, not buried in your inbox. See what's waiting, review the full contract, and sign without switching tools.
            </p>
            <div style={{ display: "flex", flexDirection: "column", gap: 20 }}>
              {[
                "All pending requests in one place, no inbox hunting",
                "Review the full contract before you sign",
                "Deadlines visible at a glance so nothing slips",
              ].map((b, i) => (
                <div key={i} style={{ display: "flex", gap: 14, alignItems: "flex-start" }}>
                  <span style={{ flex: "0 0 16px", marginTop: 3, color: "var(--accent)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><polyline points="20 6 9 17 4 12"/></svg>
                  </span>
                  <p style={{ fontSize: 14.5, color: "var(--ink-2)", lineHeight: 1.55, margin: 0 }}>{b}</p>
                </div>
              ))}
            </div>
          </div>
          {/* Right: mockup */}
          <div className="showcase-panel-mockup" style={{ borderRadius: 16, border: "1px solid var(--line)" }}>
            <SignatureInboxMockup />
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Section: eID integrations ───────────────────────────────────────────────

function SignatureEidSection() {
  const providers = [
    { name: "Swedish BankID",        flag: "🇸🇪", slug: "swedish-bankid" },
    { name: "Denmark MitID",         flag: "🇩🇰", slug: "denmark-mitid" },
    { name: "Norwegian Bank ID",     flag: "🇳🇴", slug: "norwegian-bank-id" },
    { name: "Finnish Trust Network", flag: "🇫🇮", slug: "finnish-trust-network" },
    { name: "Estonian Mobile-ID",    flag: "🇪🇪", slug: "estonian-mobile-id" },
    { name: "Smart-ID",              flag: "🇪🇪", slug: "smart-id" },
    { name: "Itsme",                 flag: "🇧🇪", slug: "itsme" },
    { name: "SPID",                  flag: "🇮🇹", slug: "spid" },
    { name: "D-Trust sign-me",       flag: "🇩🇪", slug: "d-trust-sign-me" },
    { name: "ZealID app",            flag: "🇪🇺", slug: "zealid-app" },
    { name: "Freja eID",             flag: "🇸🇪", slug: "freja-eid" },
  ];

  return (
    <section style={{ background: "var(--ink-1)", padding: "96px 0", borderTop: "1px solid rgba(255,255,255,0.06)" }}>
      <div className="container">
        {/* Centered heading */}
        <div className="cc-section-header" style={{ textAlign: "center", maxWidth: 640, margin: "0 auto 56px" }}>
          <span style={{ fontSize: 11, fontWeight: 600, letterSpacing: "0.1em", textTransform: "uppercase", color: "rgba(255,255,255,0.35)", display: "flex", alignItems: "center", justifyContent: "center", gap: 7, marginBottom: 20 }}>
            <span style={{ width: 5, height: 5, borderRadius: "50%", background: "var(--accent)", display: "inline-block" }} />
            eIDAS · 60+ providers
          </span>
          <h2 style={{ fontFamily: "var(--font-sans)", fontWeight: 500, fontSize: "clamp(32px, 4vw, 52px)", lineHeight: 1.08, letterSpacing: "-0.03em", color: "white", margin: "0 0 20px" }}>
            Your counterparty signs with <em style={{ fontFamily: "var(--font-serif)", fontStyle: "italic", fontWeight: 400 }}>the eID they already have</em>.
          </h2>
          <p style={{ fontSize: 16, color: "rgba(255,255,255,0.5)", lineHeight: 1.6, margin: 0 }}>
            60+ national and pan-European identity providers. No new app. No new account. Just sign.
          </p>
        </div>

        {/* Provider pills, centered, wrapping */}
        <div style={{ display: "flex", flexWrap: "wrap", gap: 10, justifyContent: "center", maxWidth: 780, margin: "0 auto 32px" }}>
          {providers.map(({ name, flag, slug }) => (
            <a key={name} href={`/esignature/eid/${slug}`}
              style={{
                display: "inline-flex", alignItems: "center", gap: 8,
                padding: "8px 16px", borderRadius: 999,
                background: "rgba(255,255,255,0.06)",
                border: "1px solid rgba(255,255,255,0.10)",
                fontSize: 13, fontWeight: 500, color: "rgba(255,255,255,0.75)",
                textDecoration: "none", cursor: "pointer",
                transition: "background 140ms ease, border-color 140ms ease",
              }}
              onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(110,86,207,0.18)"; e.currentTarget.style.borderColor = "rgba(110,86,207,0.45)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.background = "rgba(255,255,255,0.06)"; e.currentTarget.style.borderColor = "rgba(255,255,255,0.10)"; }}
            >
              <span style={{ fontSize: 15, lineHeight: 1 }}>{flag}</span>
              {name}
            </a>
          ))}
          <a href="/esignature/eID-integrations/" style={{
            display: "inline-flex", alignItems: "center", gap: 6,
            padding: "8px 16px", borderRadius: 999,
            background: "var(--accent)", border: "none",
            fontSize: 13, fontWeight: 500, color: "white",
            textDecoration: "none",
          }}>
            + 50 more <Icon name="arrow" size={11} />
          </a>
        </div>

        {/* Region tags */}
        <div style={{ display: "flex", flexWrap: "wrap", gap: 8, justifyContent: "center" }}>
          {["Nordics", "Baltics", "DACH", "Benelux", "UK & Ireland", "Southern Europe", "Eastern Europe", "Americas", "Asia Pacific"].map((r) => (
            <span key={r} style={{
              fontSize: 12, fontWeight: 500, color: "rgba(255,255,255,0.75)",
              border: "1px solid rgba(255,255,255,0.25)",
              borderRadius: 999, padding: "5px 14px",
            }}>{r}</span>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── Departments section ──────────────────────────────────────────────────────

function SignatureDepartmentsSection() {
  const depts = [
    { icon: "negotiation", label: "Sales",        desc: "Close deals faster with contracts sent and signed the same day.",   href: "/solutions/team/sales" },
    { icon: "legal",       label: "Legal",        desc: "Stay in control with full audit trails and eIDAS-grade compliance.", href: "/solutions/team/legal" },
    { icon: "workspace",   label: "HR & People",  desc: "Offer letters, contractor agreements, and NDAs, signed in minutes.", href: "/solutions/team/hr" },
    { icon: "obligations", label: "Procurement",  desc: "Vendor signatures tracked and archived from day one.",               href: "/solutions/team/procurement" },
    { icon: "analytics",   label: "Finance",      desc: "Know exactly which contracts are signed, pending, or blocking revenue, without chasing anyone.",   href: "/solutions/team/finance" },
  ];

  return (
    <section className="section" style={{ background: "var(--bg-soft)", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
      <div className="container">
        <div className="cc-section-header" style={{ textAlign: "center", maxWidth: 640, margin: "0 auto 48px" }}>
          <span className="eyebrow">Built for every team</span>
          <h2 className="h-section" style={{ marginTop: 16 }}>
            Who uses <em>eSignature</em>?
          </h2>
          <p className="lede" style={{ margin: "16px auto 0", textAlign: "center" }}>
            From Sales to HR to Procurement, eSignature fits into every team's workflow without extra tooling.
          </p>
        </div>
        <div className="grid grid-3" style={{ gap: 16 }}>
          {depts.map((d) => (
            <a key={d.label} href={d.href} className="card" style={{
              padding: 24,
              display: "flex", flexDirection: "column", gap: 12,
              transition: "border-color 160ms ease, transform 160ms ease",
              textDecoration: "none",
            }}
              onMouseEnter={(e) => { e.currentTarget.style.borderColor = "var(--ink-5)"; e.currentTarget.style.transform = "translateY(-2px)"; }}
              onMouseLeave={(e) => { e.currentTarget.style.borderColor = "var(--line)"; e.currentTarget.style.transform = "translateY(0)"; }}
            >
              <span style={{
                width: 32, height: 32, borderRadius: 9,
                background: "var(--accent-soft)",
                display: "grid", placeItems: "center",
                color: "var(--accent)",
              }}>
                <Icon name={d.icon} size={15} />
              </span>
              <div>
                <div style={{ fontSize: 15, fontWeight: 500, color: "var(--ink-1)", marginBottom: 6 }}>{d.label}</div>
                <p style={{ fontSize: 13.5, color: "var(--ink-3)", lineHeight: 1.55, margin: 0 }}>{d.desc}</p>
              </div>
              <span style={{ marginTop: "auto", fontSize: 13, fontWeight: 500, color: "var(--accent)", display: "inline-flex", alignItems: "center", gap: 5 }}>
                See how {d.label} uses it <Icon name="arrow" size={12} />
              </span>
            </a>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── FAQ section ─────────────────────────────────────────────────────────────

function SignatureFAQSection() {
  const [open, setOpen] = React.useState(null);
  const faqs = [
    {
      q: "How does ContractControl eSignature simplify contract execution?",
      a: "ContractControl eSignature provides a native digital signing tool built directly into your contract workflow. It allows you to collect legally binding signatures without exporting files to external signing portals.",
    },
    {
      q: "How does integrated signing reduce contract cycle times?",
      a: "By keeping signing inside the contract lifecycle, counterparties sign via a secure web interface, and completed files are instantly filed in the Repository. This eliminates manual file uploads and keeps the audit trail intact.",
    },
    {
      q: "Is ContractControl eSignature compliant with international electronic signature laws?",
      a: "Yes, ContractControl supports eIDAS Advanced Electronic Signatures (AES) and Qualified Electronic Signatures (QES) across more than sixty jurisdictions. Signed documents include cryptographic seals and audit certificates that meet strict legal standards.",
    },
    {
      q: "How does the platform secure agreements during the signing phase?",
      a: "Every signing event is protected by multi-factor authentication, secure links, and tamper-evident PDF encryption. The platform logs all actions to create a court-admissible audit trail.",
    },
    {
      q: "Can counterparties sign contracts on mobile devices or tablets?",
      a: "Yes, counterparties can review and sign documents on any desktop, tablet, or smartphone. Signers do not need to install an app or register for a ContractControl account.",
    },
    {
      q: "How does the platform handle signing status alerts and reminders?",
      a: "The system sends automated email and SMS reminders based on custom follow-up schedules. You can track open rates and signing actions in real time from your dashboard.",
    },
  ];

  const faqSchema = {
    "@context": "https://schema.org",
    "@type": "FAQPage",
    "mainEntity": faqs.map(f => ({
      "@type": "Question",
      "name": f.q,
      "acceptedAnswer": {
        "@type": "Answer",
        "text": f.a
      }
    }))
  };

  return (
    <section className="section">
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(faqSchema) }}
      />
      <div className="container">
        <div style={{ display: "grid", gridTemplateColumns: "0.4fr 1fr", gap: 80, alignItems: "flex-start" }}>
          {/* Left */}
          <div style={{ position: "sticky", top: 88 }}>
            <span className="eyebrow">FAQ</span>
            <h2 className="h-section" style={{ marginTop: 16 }}>
              We're here to help with any questions <em>you have</em>.
            </h2>
          </div>

          {/* Right: accordion */}
          <div>
            {faqs.map((f, i) => (
              <div key={i} style={{ borderBottom: "1px solid var(--line)" }}>
                <button
                  onClick={() => setOpen(open === i ? null : i)}
                  style={{
                    width: "100%", display: "flex", justifyContent: "space-between",
                    alignItems: "center", gap: 16,
                    padding: "20px 0",
                    background: "none", border: "none", cursor: "pointer",
                    textAlign: "left",
                  }}
                >
                  <span style={{
                    fontSize: 16, fontWeight: 400,
                    color: open === i ? "var(--accent)" : "var(--ink-1)",
                    transition: "color 160ms ease",
                    lineHeight: 1.4,
                  }}>
                    {f.q}
                  </span>
                  <span style={{
                    flex: "0 0 20px", height: 20,
                    display: "grid", placeItems: "center",
                    color: open === i ? "var(--accent)" : "var(--ink-4)",
                    transition: "color 160ms ease, transform 200ms ease",
                    transform: open === i ? "rotate(45deg)" : "rotate(0deg)",
                  }}>
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                      <line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
                    </svg>
                  </span>
                </button>
                <div style={{
                  overflow: "hidden",
                  maxHeight: open === i ? 200 : 0,
                  transition: "max-height 280ms cubic-bezier(.4,0,.2,1)",
                }}>
                  <p style={{ fontSize: 14.5, color: "var(--ink-3)", lineHeight: 1.65, paddingBottom: 20, margin: 0 }}>
                    {f.a}
                  </p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { ESignaturePage });
