/* Extras: brand Lockup, animated Counters trust strip, and 2-step QuoteWizard modal. */

/* ─────────────────────────────────────────────────────────────────
   LOCKUP — wordmark + subtitle in a stacked or inline layout.
   Renders the same shape as the PNG but vector so it scales perfectly.
   ───────────────────────────────────────────────────────────────── */
function Lockup({ size = "md", color, subColor, inline = false, withAccentDot = true, mode = "svg" }) {
  // ── SVG image mode (default — nav, etc.) ──────────────────────────
  if (mode === "svg") {
    const heightMap = { sm: 30, md: 38, lg: 52, xl: 78 };
    const h = heightMap[size] || 38;
    const c = (color || "").toString().toLowerCase();
    let variant = "black";
    if (c.includes("white") || c.includes("#fff") || c.includes("255,255,255")) variant = "white";
    else if (c.includes("accent") || c.includes("#f97") || c.includes("orange")) variant = "orange";
    return (
      <img
        src={`images/logo-${variant}.svg`}
        alt="Axious Creative Studio"
        height={h}
        style={{ height: h, width: "auto", display: "block", maxWidth: "none" }}
        draggable={false}
      />
    );
  }

  // ── Text mode — CSS-rendered wordmark, supports any color ─────────
  const map = {
    sm: { word: 18, sub: 8, gap: 1 },
    md: { word: 22, sub: 9, gap: 1 },
    lg: { word: 30, sub: 11, gap: 2 },
    xl: { word: 52, sub: 16, gap: 3 },
  };
  const s = map[size] || map.md;
  const fg = color || "var(--text)";
  const sub = subColor || "var(--text-muted, #888)";

  return (
    <span style={{ display: "inline-flex", flexDirection: inline ? "row" : "column", alignItems: inline ? "baseline" : "flex-start", lineHeight: 1, gap: inline ? 8 : s.gap }}>
      <span style={{
        fontFamily: "'Archivo Black', 'Inter', system-ui, sans-serif",
        fontWeight: 900,
        fontSize: s.word,
        letterSpacing: "-0.045em",
        color: fg,
        lineHeight: 0.9,
      }}>
        axious{withAccentDot && <span style={{ color: fg, opacity: 0.6 }}>.</span>}
      </span>
      <span style={{
        fontFamily: "'Roboto Mono', monospace",
        fontWeight: 500,
        fontSize: s.sub,
        letterSpacing: inline ? "0.18em" : "0.34em",
        textTransform: "uppercase",
        color: sub,
        marginLeft: inline ? 0 : 2,
      }}>
        Creative Studio
      </span>
    </span>
  );
}

/* ─────────────────────────────────────────────────────────────────
   AnimatedCount — counts from 0 → value when in view.
   ───────────────────────────────────────────────────────────────── */
function AnimatedCount({ to = 100, duration = 1500, prefix = "", suffix = "", decimals = 0 }) {
  const [v, setV] = useState(0);
  const [ref, shown] = useReveal();
  useEffect(() => {
    if (!shown) return;
    if (prefersReducedMotion()) { setV(to); return; }
    const start = performance.now();
    let raf;
    const tick = (now) => {
      const t = Math.min(1, (now - start) / duration);
      const eased = 1 - Math.pow(1 - t, 3);  // ease-out cubic
      setV(to * eased);
      if (t < 1) raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, [shown, to, duration]);
  const display = decimals ? v.toFixed(decimals) : Math.round(v).toLocaleString();
  return <span ref={ref}>{prefix}{display}{suffix}</span>;
}

/* ─────────────────────────────────────────────────────────────────
   StatsStrip — three big numbers under the hero CTA cluster.
   ───────────────────────────────────────────────────────────────── */
function StatsStrip() {
  const stats = [
    { value: 14, suffix: "+", label: "Sites launched" },
    { value: 5.0, suffix: "★", label: "Google rating", decimals: 1 },
    { value: 100, suffix: "%", label: "Hand-coded" },
  ];
  return (
    <div
      className="mt-14 mx-auto grid grid-cols-3 gap-px overflow-hidden"
      style={{
        maxWidth: 720,
        background: "var(--border)",
        borderRadius: 18,
        border: "1px solid var(--border)",
      }}
    >
        {stats.map((s, i) => (
          <SpringReveal key={s.label} delay={1.6 + i * 0.12}>
          <div className="px-4 py-6 text-center" style={{ background: "var(--bg-card, var(--bg))" }}>
            <div style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: "clamp(2rem, 3.6vw, 3rem)", lineHeight: 1, letterSpacing: "-0.02em" }}>
              <AnimatedCount to={s.value} suffix={s.suffix} decimals={s.decimals || 0} />
            </div>
            <div className="mt-2" style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 10.5, letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--text-muted)" }}>
              <ScrambleText text={s.label} delay={1.8 + i * 0.15} speed={38} />
            </div>
          </div>
          </SpringReveal>
        ))}
      </div>
  );
}

/* ─────────────────────────────────────────────────────────────────
   QuoteWizard — 2-step modal that estimates a price.
   Opens via window event 'open-quote' or click on data-quote-trigger.
   ───────────────────────────────────────────────────────────────── */
const INDUSTRIES = [
  { id: "restaurant", label: "Restaurant", desc: "Menu, online ordering, bookings" },
  { id: "salon", label: "Salon / Spa", desc: "Bookings, deposits, portfolio" },
  { id: "fitness", label: "Fitness / Gym", desc: "Classes, memberships, trainers" },
  { id: "professional", label: "Professional services", desc: "Lawyers, accountants, agents" },
  { id: "retail", label: "Retail / E-commerce", desc: "Products, cart, payments" },
  { id: "other", label: "Something else", desc: "Tell us what you do" },
];
const FEATURES = [
  { id: "ai", label: "AI chatbot", price: 1500 },
  { id: "ecom", label: "E-commerce (Yoco / PayFast)", price: 4000 },
  { id: "booking", label: "Booking system", price: 1200 },
  { id: "portal", label: "Client portal", price: 3500 },
  { id: "pos", label: "POS integration", price: 5000 },
  { id: "seo", label: "Advanced SEO + monthly report", price: 800 },
];

function QuoteWizard({ open, onClose }) {
  const [step, setStep] = useState(1);
  const [industry, setIndustry] = useState(null);
  const [pages, setPages] = useState(8);
  const [features, setFeatures] = useState([]);
  const [name, setName] = useState("");
  const [email, setEmail] = useState("");
  const [phone, setPhone] = useState("");
  const [submitting, setSubmitting] = useState(false);
  const [quoteRef, setQuoteRef] = useState("");
  const [showEFT, setShowEFT] = useState(false);
  const [yocoLoading, setYocoLoading] = useState(false);

  useEffect(() => {
    if (!open) return;
    const onKey = (e) => { if (e.key === "Escape") onClose(); };
    document.addEventListener("keydown", onKey);
    document.body.style.overflow = "hidden";
    return () => { document.removeEventListener("keydown", onKey); document.body.style.overflow = ""; };
  }, [open, onClose]);

  useEffect(() => {
    if (open) {
      setStep(1); setIndustry(null); setPages(8); setFeatures([]);
      setName(""); setEmail(""); setPhone("");
      setSubmitting(false); setQuoteRef(""); setShowEFT(false); setYocoLoading(false);
    }
  }, [open]);

  const basePrice = pages <= 5 ? 2499 : pages <= 8 ? 5999 : 9999;
  const addons = features.reduce((sum, id) => sum + (FEATURES.find((f) => f.id === id)?.price || 0), 0);
  const total = basePrice + addons;
  const deposit = Math.ceil(total / 2);

  const toggleFeature = (id) => setFeatures((f) => f.includes(id) ? f.filter((x) => x !== id) : [...f, id]);

  async function handleSubmit() {
    if (!name.trim() || !email.trim()) return;
    setSubmitting(true);
    const ref = "EST-" + Date.now().toString(36).toUpperCase();
    const pkgName = pages <= 5 ? "Basic Website Package" : pages <= 8 ? "Business Website Package" : "Premium Website Package";
    const selectedAddons = features.map(id => { const f = FEATURES.find(x => x.id === id); return f ? { name: f.label, price: f.price } : null; }).filter(Boolean);
    try {
      const res = await fetch('/api/quote-request', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          quoteData: {
            name: name.trim(), email: email.trim(), phone: phone.trim(),
            businessType: industry || '', description: '',
            package: pkgName, packagePrice: basePrice,
            selectedAddons, paymentMethod: 'wizard',
          },
          total, deposit, quoteRef: ref, paymentMethod: 'wizard',
        }),
      });
      const data = await res.json();
      if (!res.ok) throw new Error(data.error || 'Submission failed');
      setQuoteRef(ref);
      setStep(4);
    } catch (err) {
      alert("Something went wrong: " + err.message + "\n\nWhatsApp us: 062 379 0118");
    } finally {
      setSubmitting(false);
    }
  }

  async function handleYocoPayment() {
    setYocoLoading(true);
    const pkgLabel = pages <= 5 ? "Basic" : pages <= 8 ? "Business" : "Premium";
    try {
      const res = await fetch('/api/public/yoco-checkout', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          amount: deposit,
          description: `${quoteRef} — 50% Deposit for ${pkgLabel} Website Package`,
        }),
      });
      const data = await res.json();
      if (!res.ok || !data.checkoutUrl) throw new Error(data.error || 'Payment gateway error');
      window.location.href = data.checkoutUrl;
    } catch (err) {
      setYocoLoading(false);
      alert('Card payment unavailable: ' + err.message + '\n\nPlease use EFT instead.');
    }
  }

  if (!open) return null;

  const canSubmit = !submitting && name.trim() && email.trim();

  return (
    <div role="dialog" aria-modal="true" aria-labelledby="qw-title"
      style={{ position: "fixed", inset: 0, zIndex: 100, display: "grid", placeItems: "center", padding: 20 }}>
      <div onClick={step < 4 ? onClose : undefined} aria-hidden
        style={{ position: "absolute", inset: 0, background: "rgba(0,0,0,0.55)", backdropFilter: "blur(8px)", animation: `qw-fade 0.4s ${EASE_OUT}` }} />
      <div style={{ position: "relative", width: "100%", maxWidth: 720, background: "var(--bg-card, #fff)", color: "var(--text)", borderRadius: 24, border: "1px solid var(--border)", boxShadow: "0 60px 120px -40px rgba(0,0,0,0.5)", animation: `qw-rise 0.55s ${EASE_OUT}`, maxHeight: "90vh", display: "flex", flexDirection: "column" }}>

        {/* Header */}
        <div className="flex items-center justify-between px-6 py-5" style={{ borderBottom: "1px solid var(--border)" }}>
          <div>
            <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 10.5, letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--text-muted)" }}>
              {step < 4 ? `Quote wizard / step ${step} of 3` : "Quote confirmed"}
            </div>
            <div id="qw-title" className="mt-1.5" style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: 24, letterSpacing: "-0.02em" }}>
              {step === 1 && "What kind of business are you?"}
              {step === 2 && "What do you need it to do?"}
              {step === 3 && "Here's your estimate."}
              {step === 4 && "You're all set!"}
            </div>
          </div>
          <button onClick={onClose} aria-label="Close" className="inline-flex w-9 h-9 items-center justify-center rounded-full"
            style={{ background: "rgba(0,0,0,0.04)", border: "1px solid var(--border)", color: "var(--text)" }}>
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M6 6l12 12M18 6l-12 12" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round"/></svg>
          </button>
        </div>

        {/* Progress */}
        <div style={{ position: "relative", height: 3, background: "var(--border)" }}>
          <div style={{ position: "absolute", top: 0, left: 0, height: 3, width: step >= 4 ? "100%" : `${(step / 3) * 100}%`, background: "linear-gradient(90deg, var(--accent), #ea580c)", transition: `width 0.6s ${EASE_OUT}` }} />
        </div>

        {/* Body */}
        <div className="px-6 py-6 overflow-y-auto" style={{ minHeight: 320 }}>
          {step === 1 && (
            <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
              {INDUSTRIES.map((i) => (
                <button key={i.id} onClick={() => { setIndustry(i.id); setStep(2); }} className="text-left p-4"
                  style={{ border: `1.5px solid ${industry === i.id ? "var(--accent)" : "var(--border)"}`, borderRadius: 14, background: industry === i.id ? "var(--accent-dim)" : "transparent", transition: `all 0.3s ${EASE_OUT}`, cursor: "pointer" }}
                  onMouseEnter={(e) => { if (industry !== i.id) e.currentTarget.style.borderColor = "rgba(249,115,22,0.4)"; }}
                  onMouseLeave={(e) => { if (industry !== i.id) e.currentTarget.style.borderColor = "var(--border)"; }}>
                  <div style={{ fontWeight: 600, fontSize: 15 }}>{i.label}</div>
                  <div className="mt-1" style={{ fontSize: 13, color: "var(--text-secondary)" }}>{i.desc}</div>
                </button>
              ))}
            </div>
          )}

          {step === 2 && (
            <div>
              <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 11, letterSpacing: "0.14em", textTransform: "uppercase", color: "var(--text-muted)", marginBottom: 12 }}>How many pages?</div>
              <div className="flex gap-2 flex-wrap">
                {[5, 8, 12].map((n) => (
                  <button key={n} onClick={() => setPages(n)} className="px-4 py-2.5 rounded-full text-sm font-medium"
                    style={{ border: `1.5px solid ${pages === n ? "var(--accent)" : "var(--border)"}`, background: pages === n ? "var(--accent)" : "transparent", color: pages === n ? "#fff" : "var(--text)", transition: `all 0.25s ${EASE_OUT}`, cursor: "pointer" }}>
                    {n} pages {n === 5 ? "· Basic" : n === 8 ? "· Business" : "· Premium"}
                  </button>
                ))}
              </div>
              <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 11, letterSpacing: "0.14em", textTransform: "uppercase", color: "var(--text-muted)", margin: "24px 0 12px" }}>Add features</div>
              <div className="grid grid-cols-1 sm:grid-cols-2 gap-2.5">
                {FEATURES.map((f) => {
                  const on = features.includes(f.id);
                  return (
                    <button key={f.id} onClick={() => toggleFeature(f.id)} className="flex items-center justify-between px-4 py-3 text-left"
                      style={{ border: `1.5px solid ${on ? "var(--accent)" : "var(--border)"}`, borderRadius: 12, background: on ? "var(--accent-dim)" : "transparent", transition: `all 0.25s ${EASE_OUT}`, cursor: "pointer" }}>
                      <span className="flex items-center gap-2.5">
                        <span aria-hidden style={{ width: 18, height: 18, borderRadius: 5, border: `1.5px solid ${on ? "var(--accent)" : "rgba(0,0,0,0.18)"}`, background: on ? "var(--accent)" : "transparent", display: "grid", placeItems: "center", transition: `all 0.25s ${EASE_OUT}` }}>
                          {on && <svg width="10" height="10" viewBox="0 0 24 24" fill="none"><path d="M5 12l4 4 10-10" stroke="#fff" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"/></svg>}
                        </span>
                        <span style={{ fontSize: 14, fontWeight: 500 }}>{f.label}</span>
                      </span>
                      <span style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 12, color: "var(--text-muted)" }}>+R{f.price.toLocaleString()}</span>
                    </button>
                  );
                })}
              </div>
            </div>
          )}

          {step === 3 && (
            <div>
              <div className="text-center py-2">
                <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 11, letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--text-muted)" }}>Your estimate</div>
                <div className="my-3" style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: "clamp(3rem, 8vw, 5rem)", lineHeight: 1, letterSpacing: "-0.025em", color: "var(--accent)" }}>
                  R<AnimatedCount to={total} duration={900} />
                </div>
                <div style={{ fontSize: 13, color: "var(--text-secondary)" }}>Once-off · 50% on signature · 50% on launch</div>
              </div>
              <ul className="mt-6 space-y-2 text-sm" style={{ color: "var(--text-secondary)" }}>
                <li className="flex justify-between"><span>{pages}-page hand-coded site</span><span>R{basePrice.toLocaleString()}</span></li>
                {features.map((id) => { const f = FEATURES.find((x) => x.id === id); return <li key={id} className="flex justify-between"><span>{f.label}</span><span>+R{f.price.toLocaleString()}</span></li>; })}
                <li className="flex justify-between pt-3" style={{ borderTop: "1px solid var(--border)", fontWeight: 600, color: "var(--text)" }}><span>Total</span><span>R{total.toLocaleString()}</span></li>
              </ul>
              <div className="grid grid-cols-1 sm:grid-cols-2 gap-3 mt-6">
                <input type="text" placeholder="Your name *" value={name} onChange={(e) => setName(e.target.value)}
                  className="px-4 py-3 text-sm" style={{ background: "var(--bg)", border: "1.5px solid var(--border)", borderRadius: 10, color: "var(--text)" }} />
                <input type="email" placeholder="Email address *" value={email} onChange={(e) => setEmail(e.target.value)}
                  className="px-4 py-3 text-sm" style={{ background: "var(--bg)", border: "1.5px solid var(--border)", borderRadius: 10, color: "var(--text)" }} />
                <input type="tel" placeholder="WhatsApp / Phone" value={phone} onChange={(e) => setPhone(e.target.value)}
                  className="px-4 py-3 text-sm sm:col-span-2" style={{ background: "var(--bg)", border: "1.5px solid var(--border)", borderRadius: 10, color: "var(--text)" }} />
              </div>
            </div>
          )}

          {step === 4 && (
            <div>
              <div className="text-center py-4">
                <div style={{ width: 52, height: 52, borderRadius: "50%", background: "rgba(22,163,74,0.1)", border: "2px solid #16A34A", display: "grid", placeItems: "center", margin: "0 auto 16px" }}>
                  <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M5 12l4 4 10-10" stroke="#16A34A" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/></svg>
                </div>
                <div style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: 22, letterSpacing: "-0.01em" }}>Quote sent! We'll be in touch within the hour.</div>
                <div className="mt-2" style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 11, letterSpacing: "0.12em", color: "var(--text-muted)" }}>REF: {quoteRef}</div>
              </div>

              <div className="mt-4 p-5 rounded-2xl" style={{ background: "var(--accent-dim)", border: "1px solid rgba(249,115,22,0.2)" }}>
                <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 11, letterSpacing: "0.12em", textTransform: "uppercase", color: "var(--accent)" }}>Lock in your start date</div>
                <div className="mt-1" style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: 26, color: "var(--text)" }}>
                  Pay R{deposit.toLocaleString()} deposit now
                  <span style={{ fontSize: 13, color: "var(--text-muted)", fontFamily: "'DM Sans', sans-serif", marginLeft: 8 }}>50% of R{total.toLocaleString()}</span>
                </div>
                <div className="mt-4 flex flex-col gap-3">
                  <button onClick={handleYocoPayment} disabled={yocoLoading}
                    className="inline-flex items-center justify-center gap-2 rounded-full px-5 py-3 text-[12.5px] tracking-[0.08em] uppercase font-bold text-white w-full"
                    style={{ background: yocoLoading ? "rgba(0,0,0,0.2)" : "var(--accent)", border: "none", cursor: yocoLoading ? "not-allowed" : "pointer", boxShadow: "0 12px 30px -12px rgba(249,115,22,0.6)" }}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="1" y="4" width="22" height="16" rx="2"/><line x1="1" y1="10" x2="23" y2="10"/></svg>
                    {yocoLoading ? "Connecting to Yoco..." : "Pay by Card — Secure via Yoco"}
                  </button>
                  <button onClick={() => setShowEFT(!showEFT)}
                    className="inline-flex items-center justify-center gap-2 rounded-full px-5 py-3 text-[12.5px] tracking-[0.08em] uppercase font-bold w-full"
                    style={{ background: "transparent", border: "1.5px solid var(--border)", color: "var(--text)", cursor: "pointer" }}>
                    EFT / Bank Transfer {showEFT ? "▲" : "▼"}
                  </button>
                  {showEFT && (
                    <div className="p-4 rounded-xl" style={{ background: "var(--bg)", border: "1px solid var(--border)" }}>
                      {[["Bank","Capitec Entrepreneur"],["Account Holder","Axious Creative Studio"],["Account Number","248650558"],["Reference", (name.split(" ")[0] || "axious").toLowerCase() + ".co.za"],["Amount (50% deposit)","R" + deposit.toLocaleString()]].map(([label, val]) => (
                        <div key={label} className="flex justify-between py-2" style={{ borderBottom: "1px solid var(--border)", fontSize: 13 }}>
                          <span style={{ color: "var(--text-muted)" }}>{label}</span>
                          <span style={{ fontWeight: 600 }}>{val}</span>
                        </div>
                      ))}
                      <div className="mt-3" style={{ fontSize: 12, color: "var(--text-muted)" }}>Email proof of payment to design@axiouscreativestudio.co.za</div>
                    </div>
                  )}
                </div>
              </div>
              <div className="mt-4 text-center" style={{ fontSize: 13, color: "var(--text-muted)" }}>
                Not ready to pay? No worries — we'll send an invoice to {email || "your email"}.
              </div>
            </div>
          )}
        </div>

        {/* Footer */}
        <div className="flex items-center justify-between gap-3 px-6 py-4" style={{ borderTop: "1px solid var(--border)", background: "var(--bg-light-alt, transparent)" }}>
          {step < 4 ? (
            <>
              <button onClick={() => step > 1 ? setStep(step - 1) : onClose()} className="text-sm font-medium"
                style={{ background: "transparent", border: "none", color: "var(--text-secondary)", cursor: "pointer" }}>
                ← {step === 1 ? "Cancel" : "Back"}
              </button>
              <div className="flex items-center gap-3">
                {step >= 2 && (
                  <div className="hidden sm:block text-right">
                    <div style={{ fontFamily: "'Roboto Mono', monospace", fontSize: 10, letterSpacing: "0.12em", textTransform: "uppercase", color: "var(--text-muted)" }}>Running total</div>
                    <div style={{ fontFamily: "'Crimson Text', Georgia, serif", fontSize: 22, color: "var(--accent)" }}>R{total.toLocaleString()}</div>
                  </div>
                )}
                {step < 3 ? (
                  <button onClick={() => { if (step === 1 && !industry) return; setStep(step + 1); }} disabled={step === 1 && !industry}
                    className="inline-flex items-center gap-2 rounded-full px-5 py-3 text-[12.5px] tracking-[0.08em] uppercase font-bold text-white"
                    style={{ background: step === 1 && !industry ? "rgba(0,0,0,0.2)" : "var(--accent)", cursor: step === 1 && !industry ? "not-allowed" : "pointer", border: "none", transition: "all 0.25s ease" }}>
                    Next
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M5 12h14M13 5l7 7-7 7" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/></svg>
                  </button>
                ) : (
                  <button onClick={handleSubmit} disabled={!canSubmit}
                    className="inline-flex items-center gap-2 rounded-full px-5 py-3 text-[12.5px] tracking-[0.08em] uppercase font-bold text-white"
                    style={{ background: !canSubmit ? "rgba(0,0,0,0.2)" : "var(--accent)", cursor: !canSubmit ? "not-allowed" : "pointer", border: "none", boxShadow: "0 12px 30px -12px rgba(249,115,22,0.6)" }}>
                    {submitting ? "Sending..." : "Send to Elvis"}
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M5 12h14M13 5l7 7-7 7" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/></svg>
                  </button>
                )}
              </div>
            </>
          ) : (
            <>
              <button onClick={onClose} className="text-sm font-medium"
                style={{ background: "transparent", border: "none", color: "var(--text-secondary)", cursor: "pointer" }}>
                Close
              </button>
              <a href="https://wa.me/27623790118" target="_blank" rel="noopener noreferrer"
                className="inline-flex items-center gap-2 rounded-full px-5 py-3 text-[12.5px] tracking-[0.08em] uppercase font-bold text-white"
                style={{ background: "#25D366", textDecoration: "none" }}>
                <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/></svg>
                Chat on WhatsApp
              </a>
            </>
          )}
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { Lockup, AnimatedCount, StatsStrip, QuoteWizard });
