// ── Form, FAQ, Final CTA, Footer ────────────────────────────

// Safe fallback for process.env in pure client-side environment
if (typeof process === 'undefined') {
  window.process = { env: {} };
}

// Format BR mobile WhatsApp number progressively: (11) 99999-9999
function maskWhats(v) {
  const d = (v || "").replace(/\D/g, "").slice(0, 11);
  if (d.length <= 2) return d;
  if (d.length <= 6) return `(${d.slice(0,2)}) ${d.slice(2)}`;
  if (d.length <= 10) return `(${d.slice(0,2)}) ${d.slice(2,6)}-${d.slice(6)}`;
  return `(${d.slice(0,2)}) ${d.slice(2,7)}-${d.slice(7)}`;
}
function digitsOnly(v) { return (v || "").replace(/\D/g, ""); }

function LeadForm({ innerRef }) {
  const [data, setData] = React.useState({ nome: "", whats: "", email: "" });
  const [countryCode, setCountryCode] = React.useState("+55");
  const [touched, setTouched] = React.useState({});
  const [focus, setFocus] = React.useState(null);
  const [done, setDone] = React.useState(false);
  const [modal, setModal] = React.useState(false);
  const [tilt, setTilt] = React.useState({ rx: 0, ry: 0, active: false });

  const handleTiltMove = (e) => {
    const rect = e.currentTarget.getBoundingClientRect();
    const x = (e.clientX - rect.left) / rect.width - 0.5;
    const y = (e.clientY - rect.top) / rect.height - 0.5;
    setTilt({ rx: -y * 22, ry: x * 22, active: true });
  };
  const handleTiltLeave = () => {
    setTilt({ rx: 0, ry: 0, active: false });
  };

  const errors = {
    nome: data.nome.trim().length < 3 ? "Digite seu nome completo." : null,
    whats: (countryCode === "+55" ? digitsOnly(data.whats).length < 10 : digitsOnly(data.whats).length < 7) ? "Informe um WhatsApp válido." : null,
    email: !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email) ? "Informe um e-mail válido." : null,
  };
  const valid = !errors.nome && !errors.whats && !errors.email;

  const fields = [
    { k: "nome", ph: "Nome completo", type: "text", autocomplete: "name", inputmode: "text" },
    { k: "whats", ph: "WhatsApp (com DDD)", type: "tel", autocomplete: "tel", inputmode: "tel", mask: maskWhats },
    { k: "email", ph: "E-mail", type: "email", autocomplete: "email", inputmode: "email" },
  ];

  // Submit flow: validate → mark inline form as done → open checkout modal
  const submit = async (e) => {
    if (e) e.preventDefault();
    setTouched({ nome: true, whats: true, email: true });
    if (!valid) return;

    // Formatar WhatsApp final: remove espaços, hífens e parênteses (e.g. +5511999999999)
    const rawWhats = data.whats.replace(/[\s\-\(\)]/g, '');
    const formData = {
      name: data.nome,
      phone: `${countryCode}${rawWhats}`,
      email: data.email
    };

    console.log('[Frontend] Enviando dados do formulário para /api/webhook:', formData);

    try {
      const response = await fetch('/api/webhook', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify(formData),
      });

      const result = await response.json();
      console.log('[Frontend] Resposta da API interna:', result);

      if (!response.ok) {
        console.error('[Frontend] Falha ao registrar lead na API interna:', result.error || response.statusText);
      } else {
        console.log('[Frontend] Lead registrado com sucesso!');
      }
    } catch (error) {
      console.error('[Frontend] Erro na requisição para /api/webhook:', error);
    }

    setDone(true);
    setModal(true);
  };
  // Replace this with the real Stripe / Hotmart / Eduzz / Asaas checkout URL
  // when the brand team provides it. Fires in a new tab so the page stays.
  const CHECKOUT_URL = "https://pay.minhaprimeiraimportacao.com.br/checkout";
  const goToCheckout = () => { window.open(CHECKOUT_URL, "_blank", "noopener,noreferrer"); };

  // Lock body scroll while modal is open
  React.useEffect(() => {
    const prev = document.body.style.overflow;
    if (modal) { document.body.style.overflow = "hidden"; }
    else { document.body.style.overflow = prev || ""; }
    return () => { document.body.style.overflow = prev || ""; };
  }, [modal]);
  // Esc to close
  React.useEffect(() => {
    if (!modal) return;
    const h = (e) => { if (e.key === "Escape") setModal(false); };
    window.addEventListener("keydown", h);
    return () => window.removeEventListener("keydown", h);
  }, [modal]);
  return (
    <Section glow bgChar="定" style={{ scrollMarginTop: "0" }}>
      <div ref={innerRef} style={{ position: "absolute", top: "-80px" }} />
      <div className="pf-form-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "48px", alignItems: "center" }}>
        <Reveal>
          <SectionHead n="08" tag="Inscrição Dupla" title="Sua vaga garante<br />acesso em dobro" />
          <p style={{ fontFamily: "var(--f-body)", fontSize: "1.05rem", lineHeight: 1.65, color: "var(--txt-body)", marginBottom: "32px" }}>O encontro é presencial no dia <strong style={{ color: "var(--cream)" }}>21 de Junho</strong>. Ao garantir a sua inscrição, você recebe automaticamente <strong style={{ color: "var(--cream)" }}>duas credenciais de acesso</strong>. Leve um sócio, parceiro ou acompanhante com você para a sala na <strong style={{ color: "var(--cream)" }}>Alameda Tocantins, 956</strong>.</p>
          <div className="pf-vip-ticket pf-ticket-wrap" onMouseMove={handleTiltMove} onMouseLeave={handleTiltLeave}
            style={{ position: "relative", maxWidth: "440px", marginTop: "8px", cursor: "pointer" }}>
            <div style={{ position: "absolute", inset: "-20px -10px -10px", background: "radial-gradient(ellipse at 50% 70%, rgba(245,158,11,0.28), transparent 65%)", filter: "blur(8px)", pointerEvents: "none" }} />
            <img src="assets/ticket-vip.png" alt="Credencial VIP: Minha Primeira Importação" loading="lazy"
              style={{
                position: "relative",
                width: "100%",
                height: "auto",
                display: "block",
                transform: tilt.active
                  ? `perspective(1000px) rotateX(${tilt.rx}deg) rotateY(${tilt.ry}deg) scale(1.05) translateY(-8px)`
                  : "perspective(1000px) rotateX(0deg) rotateY(0deg) rotate(-3.5deg)",
                filter: tilt.active
                  ? "drop-shadow(0 32px 50px rgba(0,0,0,0.65)) drop-shadow(0 0 28px rgba(245,158,11,0.32))"
                  : "drop-shadow(0 22px 38px rgba(0,0,0,0.55)) drop-shadow(0 0 22px rgba(245,158,11,0.18))",
                transition: tilt.active
                  ? "transform 0.08s ease-out, filter 0.08s ease-out"
                  : "transform 0.5s var(--ease-out), filter 0.5s var(--ease-out)",
              }} />
            <div style={{ marginTop: "20px", display: "flex", alignItems: "center", gap: "12px", fontFamily: "var(--f-body)", fontWeight: 600, fontSize: ".66rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--bronze)" }}>
              <span style={{ width: "26px", height: "1px", background: "var(--bronze)" }} />
              Acesso VIP duplo: inclui 1 acompanhante grátis
            </div>
          </div>
        </Reveal>
        <Reveal delay={0.1}>
          <form className="pf-form-card" noValidate onSubmit={submit}
            style={{ background: "linear-gradient(165deg, #151210 0%, #0A0907 100%)", border: "1px solid rgba(176,124,37,0.25)", borderRadius: "16px", padding: "32px", boxShadow: "0 28px 60px -28px rgba(0,0,0,0.85), inset 0 1px 0 rgba(245,158,11,0.06)" }}>
            {done ? (
              <div style={{ textAlign: "center", padding: "20px 10px" }}>
                <div style={{ width: "56px", height: "56px", borderRadius: "50%", background: "linear-gradient(135deg, var(--go-4), var(--go))", display: "inline-flex", alignItems: "center", justifyContent: "center", marginBottom: "16px", boxShadow: "0 8px 24px rgba(245,158,11,0.35)" }}>
                  <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="#0A0907" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12" /></svg>
                </div>
                <div style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontStyle: "italic", fontSize: "1.5rem", color: "var(--cream)", marginBottom: "10px" }}>Dados confirmados!</div>
                <div style={{ fontFamily: "var(--f-body)", color: "var(--txt-body)", lineHeight: 1.6, marginBottom: "20px" }}>Falta apenas finalizar o pagamento do seu ingresso para garantir a credencial VIP.</div>
                <Button variant="primary" size="md" shimmer onClick={() => setModal(true)} style={{ justifyContent: "center" }}>Abrir checkout →</Button>
              </div>
            ) : (
              <>
                <div style={{ fontFamily: "var(--f-body)", fontWeight: 600, fontSize: ".66rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--champagne)", marginBottom: "20px" }}>Garanta sua vaga</div>
                <div style={{ display: "flex", flexDirection: "column", gap: "14px" }}>
                  {fields.map((f) => {
                    const showErr = touched[f.k] && errors[f.k];
                    if (f.k === "whats") {
                      return (
                        <div key={f.k} style={{ display: "flex", flexDirection: "column", gap: "6px" }}>
                          <label htmlFor={`pf-${f.k}`} style={{ position: "absolute", left: "-9999px" }}>{f.ph}</label>
                          <div style={{
                            display: "flex",
                            alignItems: "center",
                            borderRadius: "10px",
                            background: "var(--deep)",
                            border: `1px solid ${showErr ? "var(--rd)" : (focus === f.k ? "var(--go-4)" : "rgba(176,124,37,0.20)")}`,
                            boxShadow: focus === f.k ? "0 0 0 3px rgba(245,158,11,0.15)" : "none",
                            transition: "all .25s var(--ease-out)",
                            padding: "0 16px 0 12px"
                          }}>
                            <select 
                              value={countryCode} 
                              onChange={(e) => {
                                setCountryCode(e.target.value);
                                setData(prev => ({ ...prev, whats: "" }));
                              }}
                              style={{
                                fontFamily: "var(--f-body)",
                                fontSize: "0.95rem",
                                background: "transparent",
                                color: "var(--txt-white)",
                                border: "none",
                                outline: "none",
                                marginRight: "8px",
                                cursor: "pointer",
                                padding: "14px 0",
                                width: "70px",
                                WebkitAppearance: "none",
                                MozAppearance: "none",
                                appearance: "none",
                                backgroundImage: "url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23e2e8f0\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"></polyline></svg>')",
                                backgroundRepeat: "no-repeat",
                                backgroundPosition: "right 4px center",
                                paddingRight: "16px"
                              }}
                            >
                              <option value="+55" style={{ background: "#151210", color: "#e2e8f0" }}>🇧🇷 +55</option>
                              <option value="+351" style={{ background: "#151210", color: "#e2e8f0" }}>🇵🇹 +351</option>
                              <option value="+1" style={{ background: "#151210", color: "#e2e8f0" }}>🇺🇸 +1</option>
                              <option value="+34" style={{ background: "#151210", color: "#e2e8f0" }}>🇪🇸 +34</option>
                              <option value="+244" style={{ background: "#151210", color: "#e2e8f0" }}>🇦🇴 +244</option>
                              <option value="+258" style={{ background: "#151210", color: "#e2e8f0" }}>🇲🇿 +258</option>
                            </select>
                            <div style={{ width: "1px", height: "24px", background: "rgba(176,124,37,0.25)", marginRight: "12px" }} />
                            <input id={`pf-${f.k}`} placeholder={f.ph} value={data[f.k]}
                              type={f.type} autoComplete={f.autocomplete} inputMode={f.inputmode}
                              aria-invalid={showErr ? "true" : "false"}
                              aria-describedby={showErr ? `pf-${f.k}-err` : undefined}
                              onChange={(e) => {
                                const val = e.target.value;
                                const masked = (countryCode === "+55" && f.mask) ? f.mask(val) : val;
                                setData({ ...data, [f.k]: masked });
                              }}
                              onFocus={() => setFocus(f.k)}
                              onBlur={() => { setFocus(null); setTouched((t) => ({ ...t, [f.k]: true })); }}
                              style={{
                                fontFamily: "var(--f-body)",
                                fontSize: "1rem",
                                background: "transparent",
                                color: "var(--txt-white)",
                                outline: "none",
                                border: "none",
                                padding: "14px 0",
                                width: "100%",
                                WebkitAppearance: "none",
                              }} />
                          </div>
                          {showErr && <span id={`pf-${f.k}-err`} role="alert" style={{ fontFamily: "var(--f-body)", fontSize: ".74rem", color: "var(--rd-4)", marginLeft: "2px" }}>{errors[f.k]}</span>}
                        </div>
                      );
                    }
                    return (
                      <div key={f.k} style={{ display: "flex", flexDirection: "column", gap: "6px" }}>
                        <label htmlFor={`pf-${f.k}`} style={{ position: "absolute", left: "-9999px" }}>{f.ph}</label>
                        <input id={`pf-${f.k}`} placeholder={f.ph} value={data[f.k]}
                          type={f.type} autoComplete={f.autocomplete} inputMode={f.inputmode}
                          aria-invalid={showErr ? "true" : "false"}
                          aria-describedby={showErr ? `pf-${f.k}-err` : undefined}
                          onChange={(e) => setData({ ...data, [f.k]: f.mask ? f.mask(e.target.value) : e.target.value })}
                          onFocus={() => setFocus(f.k)}
                          onBlur={() => { setFocus(null); setTouched((t) => ({ ...t, [f.k]: true })); }}
                          style={{ fontFamily: "var(--f-body)", fontSize: "1rem", padding: "14px 16px", borderRadius: "10px", background: "var(--deep)", color: "var(--txt-white)", outline: "none",
                            border: `1px solid ${showErr ? "var(--rd)" : (focus === f.k ? "var(--go-4)" : "rgba(176,124,37,0.20)")}`,
                            boxShadow: focus === f.k ? "0 0 0 3px rgba(245,158,11,0.15)" : "none",
                            transition: "all .25s var(--ease-out)",
                            WebkitAppearance: "none",
                          }} />
                        {showErr && <span id={`pf-${f.k}-err`} role="alert" style={{ fontFamily: "var(--f-body)", fontSize: ".74rem", color: "var(--rd-4)", marginLeft: "2px" }}>{errors[f.k]}</span>}
                      </div>
                    );
                  })}
                </div>
                <div style={{ marginTop: "18px" }}>
                  <Button variant="primary" size="md" shimmer onClick={submit} style={{ width: "100%", justifyContent: "center" }}>Garantir minha vaga →</Button>
                </div>
                <div style={{ fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".62rem", letterSpacing: ".18em", textTransform: "uppercase", color: "var(--bronze)", textAlign: "center", marginTop: "16px" }}>Seus dados estão seguros · só o que importa sobre o evento</div>
              </>
            )}
          </form>
        </Reveal>
      </div>
      {modal && <CheckoutModal data={data} onClose={() => setModal(false)} onCheckout={goToCheckout} />}
    </Section>
  );
}

// Premium checkout modal — full-screen backdrop with blur, centered card
// with gold edge, hero gold seal, the user's confirmed contact echoed
// back as proof of receipt, and a single dominant CTA to the checkout.
function CheckoutModal({ data, onClose, onCheckout }) {
  // Trap focus on first focusable on open
  const closeRef = React.useRef(null);
  React.useEffect(() => { closeRef.current && closeRef.current.focus(); }, []);
  return ReactDOM.createPortal(
    <div onClick={onClose} role="dialog" aria-modal="true" aria-labelledby="pf-checkout-title"
      style={{ position: "fixed", inset: 0, zIndex: 10000, background: "rgba(3, 5, 13, 0.78)", backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)", display: "flex", alignItems: "center", justifyContent: "center", padding: "16px", animation: "pfModalFade .35s var(--ease-out) both", overflowY: "auto" }}>
      <div onClick={(e) => e.stopPropagation()} className="pf-modal-card"
        style={{ position: "relative", width: "100%", maxWidth: "520px", background: "linear-gradient(165deg, #1A1610 0%, #0A0907 100%)", borderRadius: "20px", border: "1px solid rgba(176,124,37,0.4)", boxShadow: "0 40px 90px -20px rgba(0,0,0,0.9), inset 0 1px 0 rgba(245,158,11,0.10)", padding: "44px 40px 40px", overflow: "hidden", animation: "pfModalPop .45s var(--ease-out) both" }}>
        <span style={{ position: "absolute", top: 0, left: 0, right: 0, height: "2px", background: "linear-gradient(90deg, transparent, var(--go-4), transparent)" }} />
        <span aria-hidden="true" style={{ position: "absolute", inset: 0, background: "radial-gradient(ellipse at 50% 0%, rgba(245,158,11,0.12), transparent 60%)", pointerEvents: "none" }} />
        <button ref={closeRef} onClick={onClose} aria-label="Fechar"
          style={{ position: "absolute", top: "12px", right: "12px", width: "36px", height: "36px", borderRadius: "50%", border: "1px solid rgba(176,124,37,0.30)", background: "rgba(255,255,255,0.04)", color: "var(--champagne)", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", transition: "all .2s var(--ease-out)" }}
          onMouseEnter={(e) => { e.currentTarget.style.background = "rgba(245,158,11,0.10)"; e.currentTarget.style.borderColor = "var(--go-4)"; e.currentTarget.style.color = "var(--go-4)"; }}
          onMouseLeave={(e) => { e.currentTarget.style.background = "rgba(255,255,255,0.04)"; e.currentTarget.style.borderColor = "rgba(176,124,37,0.30)"; e.currentTarget.style.color = "var(--champagne)"; }}>
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>
        </button>

        <div style={{ position: "relative", textAlign: "center" }}>
          <div style={{ width: "72px", height: "72px", borderRadius: "50%", margin: "0 auto 20px", background: "radial-gradient(circle at 30% 30%, var(--go-4), var(--go) 55%, var(--go-deep) 100%)", display: "inline-flex", alignItems: "center", justifyContent: "center", boxShadow: "0 0 0 6px rgba(245,158,11,0.10), 0 14px 30px rgba(0,0,0,0.5)" }}>
            <svg width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="#0A0907" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12" /></svg>
          </div>
          <div style={{ fontFamily: "var(--f-body)", fontWeight: 600, fontSize: ".66rem", letterSpacing: ".28em", textTransform: "uppercase", color: "var(--champagne)", marginBottom: "12px" }}>Pré-reserva recebida</div>
          <h3 id="pf-checkout-title" style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "clamp(1.4rem, 4.4vw, 1.75rem)", lineHeight: 1.15, letterSpacing: "-0.015em", color: "var(--cream)", margin: "0 0 14px" }}>
            Falta um passo,<br /><span style={{ fontStyle: "italic", color: "var(--go-4)" }}>{data.nome ? data.nome.split(" ")[0] : "futuro importador"}</span>.
          </h3>
          <p style={{ fontFamily: "var(--f-body)", fontSize: "1rem", lineHeight: 1.6, color: "var(--txt-soft)", margin: "0 0 24px", textWrap: "pretty" }}>
            Pra garantir seu acesso duplo (duas credenciais) no encontro de <strong style={{ color: "var(--cream)" }}>21 de Junho</strong> em Alphaville, finalize a compra do ingresso agora. A vaga é confirmada na hora.
          </p>

          <div className="pf-modal-summary" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "0", border: "1px solid rgba(176,124,37,0.22)", borderRadius: "12px", marginBottom: "28px", overflow: "hidden" }}>
            <div style={{ padding: "14px 16px", borderRight: "1px solid rgba(176,124,37,0.18)", textAlign: "left" }}>
              <div style={{ fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".58rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--bronze)", marginBottom: "4px" }}>Evento</div>
              <div style={{ fontFamily: "var(--f-display)", fontStyle: "italic", fontSize: ".98rem", color: "var(--cream)" }}>Minha Primeira Importação</div>
            </div>
            <div style={{ padding: "14px 16px", textAlign: "left" }}>
              <div style={{ fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".58rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--bronze)", marginBottom: "4px" }}>Data · Local</div>
              <div style={{ fontFamily: "var(--f-display)", fontStyle: "italic", fontSize: ".98rem", color: "var(--cream)" }}>21 Jun · 14h às 19h</div>
            </div>
          </div>

          <Button variant="primary" size="lg" shimmer onClick={onCheckout} style={{ width: "100%", justifyContent: "center" }}>
            Comprar ingresso agora →
          </Button>
          <div style={{ display: "flex", justifyContent: "center", alignItems: "center", gap: "18px", marginTop: "18px", flexWrap: "wrap", fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".62rem", letterSpacing: ".18em", textTransform: "uppercase", color: "var(--bronze)" }}>
            <span style={{ display: "inline-flex", alignItems: "center", gap: "6px" }}>
              <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><rect x="3" y="11" width="18" height="11" rx="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" /></svg>
              Pagamento seguro
            </span>
            <span style={{ width: "1px", height: "10px", background: "rgba(176,124,37,0.4)" }} />
            <span style={{ display: "inline-flex", alignItems: "center", gap: "6px" }}>
              <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" /></svg>
              Vaga garantida
            </span>
          </div>
          <button onClick={onClose} style={{ marginTop: "22px", background: "none", border: "none", cursor: "pointer", fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".74rem", letterSpacing: ".18em", textTransform: "uppercase", color: "var(--txt-dim)", padding: "8px 12px" }}>
            Comprar mais tarde
          </button>
        </div>
      </div>
    </div>,
    document.body
  );
}

// ── FAQ ──
const FAQS = [
  { q: "Preciso já ter um negócio pra participar?", a: "Não. O evento é pra quem quer fazer a primeira importação, com ou sem empresa montada." },
  { q: "Isso é promessa de ficar rico importando?", a: "Não, e fugimos disso de propósito. Importação é um caminho com método e trabalho. O evento te dá o passo a passo, e o resultado depende de você executar." },
  { q: "As vagas são limitadas mesmo?", a: "Sim. O que limita é o espaço físico da sala em Alphaville. Quando lota, encerra, por isso as vagas acabam." },
  { q: "Vou sair sabendo importar de verdade?", a: "Você sai com o passo a passo completo das 5 etapas: produto, fornecedor, pedido, custo e logística. O caminho fica claro." },
  { q: "E se eu nunca importei nada na vida?", a: "Melhor ainda. O evento foi desenhado pra primeira importação. Começamos do zero." },
];
function FAQ() {
  const [open, setOpen] = React.useState(0);
  return (
    <Section bgChar="问">
      <SectionHead n="09" tag="Dúvidas" title="Antes de você perguntar." />
      <div style={{ marginTop: "40px", maxWidth: "780px" }}>
        {FAQS.map((f, i) => {
          const isOpen = open === i;
          return (
            <div key={i} style={{ borderBottom: "1px solid rgba(176,124,37,0.18)" }}>
              <button onClick={() => setOpen(isOpen ? -1 : i)}
                aria-expanded={isOpen}
                aria-controls={`pf-faq-a-${i}`}
                style={{ width: "100%", display: "flex", justifyContent: "space-between", alignItems: "center", gap: "16px", background: "none", border: "none", cursor: "pointer", padding: "22px 0", textAlign: "left", color: "inherit" }}>
                <span style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "1.1rem", color: isOpen ? "var(--cream)" : "var(--txt-head)", letterSpacing: "-0.005em", lineHeight: 1.3 }}>{f.q}</span>
                <span aria-hidden="true" style={{ flexShrink: 0, color: "var(--go-4)", fontFamily: "var(--f-display)", fontSize: "1.6rem", lineHeight: 1, transform: isOpen ? "rotate(45deg)" : "none", transition: "transform .3s var(--ease-out)" }}>+</span>
              </button>
              <div id={`pf-faq-a-${i}`} role="region" style={{ display: "grid", gridTemplateRows: isOpen ? "1fr" : "0fr", transition: "grid-template-rows .4s var(--ease-out)" }}>
                <div style={{ overflow: "hidden", minHeight: 0 }}>
                  <p style={{ fontFamily: "var(--f-body)", fontSize: "1rem", lineHeight: 1.65, color: "var(--txt-soft)", margin: "0 0 22px" }}>{f.a}</p>
                </div>
              </div>
            </div>
          );
        })}
      </div>
    </Section>
  );
}

// ── FINAL CTA ──
function FinalCTA({ onCta }) {
  return (
    <Section glow className="pf-section--final" style={{ textAlign: "center", padding: "120px 0" }}>
      <Reveal>
        <h2 className="pf-section-head" style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "clamp(2rem,5vw,4rem)", lineHeight: 1.08, letterSpacing: "-0.015em", color: "var(--cream)", margin: "0 0 22px" }}>A sala tem um limite.<br /><span style={{ color: "var(--go-4)", fontStyle: "italic" }}>A sua decisão, não.</span></h2>
        <p style={{ fontFamily: "var(--f-body)", fontSize: "clamp(1rem,1.4vw,1.15rem)", lineHeight: 1.65, color: "var(--txt-soft)", maxWidth: "620px", margin: "0 auto 36px" }}>Você pode passar mais um ano adiando, com medo de errar. Ou aparecer em São Paulo e sair com o caminho na mão. Garanta seu ingresso, pois o tempo perdido não volta.</p>
        <Button variant="primary" size="lg" onClick={onCta} shimmer>Quero estar na sala →</Button>
      </Reveal>
    </Section>
  );
}

// ── FOOTER ──
function Footer() {
  return (
    <footer style={{ padding: "60px 0", borderTop: "1px solid rgba(176,124,37,0.18)", textAlign: "center", background: "var(--void)" }}>
      <Wrap>
        <img src="assets/logo-mpi.png" alt="Minha Primeira Importação" loading="lazy" style={{ height: "70px", width: "auto", marginBottom: "18px", opacity: 0.95 }} />
        <div style={{ fontFamily: "var(--f-body)", fontWeight: 600, fontSize: ".7rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--champagne)", marginBottom: "8px" }}>Evento presencial · 21 de Junho · com Alexandre Soong</div>
        <address style={{ fontFamily: "var(--f-body)", fontSize: ".78rem", letterSpacing: ".06em", color: "var(--txt-dim)", fontStyle: "normal" }}>Alameda Tocantins, 956 · Alphaville Industrial · Barueri, SP · CEP 06455-020</address>
      </Wrap>
    </footer>
  );
}

Object.assign(window, { LeadForm, CheckoutModal, FAQ, FinalCTA, Footer });
