/* global React, C7Logo, useTicker, Sparkline, Reveal, useReveal, Hairline, C7Button, QuoteCalculator */
// Prototype B — Performance / Fluxo
// F1 energy. Liquidez como linhas em movimento. Mais cinético.

const Core7Site = ({ lang = "pt", embedded = false }) => {
  const t = window.C7_COPY[lang];
  const { price: ticker, trend } = useTicker(5.42, 0.005);
  const fmt = (n) => n.toLocaleString("pt-BR", { minimumFractionDigits: 4, maximumFractionDigits: 4 });
  const [modalOpen, setModalOpen] = React.useState(false);
  const [quoteData, setQuoteData] = React.useState(null);

  const goToContact = (data) => {
    // Aceita só objeto de cotação válido (ignora MouseEvent quando o handler vem de onClick={goToContact})
    if (data && typeof data === "object" && "side" in data && "amount" in data) {
      setQuoteData(data);
    }
    const el = document.getElementById("contact");
    if (el) el.scrollIntoView({ behavior: "smooth", block: "start" });
  };

  return (
    <div style={{
      background: "#040405",
      color: "var(--c7-platinum)",
      fontFamily: "var(--c7-font-text)",
      minHeight: embedded ? "auto" : "100vh",
      width: "100%",
      overflow: "hidden",
      position: "relative"
    }}>
      <NavP t={t} ticker={ticker} fmt={fmt} onQuote={goToContact} />
      <HeroP t={t} onQuote={goToContact} />
      <ProcessP t={t} onQuote={goToContact} />
      <AboutP t={t} />
      <TickerStripP />
      <LivePanelSection t={t} ticker={ticker} trend={trend} fmt={fmt} />
      <MetricsP t={t} />
      <FaqP t={t} />
      <ContactP t={t} lang={lang} quoteData={quoteData} />
      <FooterP t={t} />
      <BackToTop />
    </div>);
};

const BackToTop = () => {
  const [show, setShow] = React.useState(false);
  React.useEffect(() => {
    // Encontra o container scrollável (artboard inner ou window)
    const findScrollContainer = () => {
      let el = document.getElementById("contact");
      while (el && el !== document.body) {
        const overflowY = getComputedStyle(el).overflowY;
        if (overflowY === "auto" || overflowY === "scroll") return el;
        el = el.parentElement;
      }
      return window;
    };
    const container = findScrollContainer();
    const onScroll = () => {
      const y = container === window ? window.scrollY : container.scrollTop;
      setShow(y > 400);
    };
    container.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => container.removeEventListener("scroll", onScroll);
  }, []);

  const handleClick = () => {
    let el = document.getElementById("contact");
    let container = null;
    while (el && el !== document.body) {
      const overflowY = getComputedStyle(el).overflowY;
      if (overflowY === "auto" || overflowY === "scroll") {container = el;break;}
      el = el.parentElement;
    }
    if (container) container.scrollTo({ top: 0, behavior: "smooth" });else
    window.scrollTo({ top: 0, behavior: "smooth" });
  };

  return (
    <button
      onClick={handleClick}
      aria-label="Voltar ao topo"
      style={{
        position: "fixed",
        bottom: 32, right: 32,
        width: 52, height: 52,
        borderRadius: "50%",
        background: "rgba(10,10,12,0.85)",
        backdropFilter: "blur(12px)",
        border: "1px solid rgba(255,255,255,0.18)",
        color: "var(--c7-platinum)",
        cursor: "pointer",
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        opacity: show ? 1 : 0,
        transform: show ? "translateY(0)" : "translateY(16px)",
        pointerEvents: show ? "auto" : "none",
        transition: "opacity 0.35s ease, transform 0.35s cubic-bezier(0.22,1,0.36,1), background 0.2s, border-color 0.2s",
        zIndex: 998,
        boxShadow: "0 8px 28px rgba(0,0,0,0.4)"
      }}
      onMouseEnter={(e) => {
        e.currentTarget.style.background = "rgba(20,20,24,0.95)";
        e.currentTarget.style.borderColor = "rgba(255,255,255,0.32)";
      }}
      onMouseLeave={(e) => {
        e.currentTarget.style.background = "rgba(10,10,12,0.85)";
        e.currentTarget.style.borderColor = "rgba(255,255,255,0.18)";
      }}>
      
      <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
        <path d="M8 13V3M8 3L3 8M8 3L13 8" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </button>);

};

const NavP = ({ t, ticker, fmt, onQuote }) => {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 40);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <nav style={{
      position: "sticky",
      top: 0,
      zIndex: 50,
      padding: "8px 40px",
      background: scrolled ? "rgba(4,4,5,0.92)" : "rgba(4,4,5,0.4)",
      backdropFilter: "blur(20px)",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      display: "flex",
      alignItems: "center",
      justifyContent: "space-between"
    }}>
      <C7Logo size={30} />
      <div style={{ display: "flex", alignItems: "center", gap: 4 }}>
        {[
        { label: t.nav.edge, href: "#processo" },
        { label: t.nav.about, href: "#processo" },
        { label: t.nav.pillars, href: "#s0" },
        { label: t.nav.process, href: "#faq" },
        { label: t.nav.contact, href: "#contact" }].
        map((item, i, arr) =>
        <a key={i} href={item.href} style={{
          fontFamily: "var(--c7-font-mono)",

          letterSpacing: "0.16em",
          textTransform: "uppercase",
          color: "var(--c7-silver-2)",
          padding: "10px 18px",
          transition: "color 0.2s",
          borderRight: i < arr.length - 1 ? "1px solid rgba(255,255,255,0.06)" : "none", fontSize: "14px"
        }}>
            {item.label}
          </a>
        )}
      </div>
      <div style={{ display: "flex", alignItems: "center", gap: 16 }}>
        <div style={{
          fontFamily: "var(--c7-font-mono)",
          fontSize: 11,
          color: "var(--c7-platinum)",
          letterSpacing: "0.08em",
          padding: "8px 14px",
          border: "1px solid rgba(255,255,255,0.12)",
          display: "flex",
          alignItems: "center",
          gap: 10
        }}>
          <span style={{
            width: 6, height: 6, borderRadius: "50%",
            background: "oklch(0.72 0.14 152)",
            boxShadow: "0 0 12px oklch(0.72 0.14 152)",
            animation: "c7pulse 1.6s ease-in-out infinite"
          }} />
          USDT/BRL
          <span style={{ color: "var(--c7-silver-3)", fontWeight: 600 }}>{fmt(ticker)}</span>
        </div>
        <C7Button variant="primary" as="a" href="https://www.core7cap.com/app/#/login">{t.nav.login} →</C7Button>
      </div>
      <style>{`@keyframes c7pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }`}</style>
    </nav>);

};

const HeroP = ({ t, onQuote }) => {
  return (
    <section style={{
      position: "relative",
      padding: "80px 40px 100px",
      minHeight: 680,
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      overflow: "hidden"
    }}>
      {/* F1 background */}
      <div style={{
        position: "absolute",
        top: 0,
        bottom: 0,
        right: 0,
        width: "100%",
        backgroundImage: "url('assets/c7_f1.jpg')",
        backgroundSize: "auto 300%",
        backgroundPosition: "right center",
        backgroundRepeat: "no-repeat",
        opacity: 0.42,
        pointerEvents: "none"
      }} />
      {/* Gradient overlay para legibilidade do texto à esquerda */}
      <div style={{
        position: "absolute",
        inset: 0,
        background: "linear-gradient(90deg, rgba(4,4,5,0.92) 0%, rgba(4,4,5,0.7) 45%, rgba(4,4,5,0.2) 100%)",
        pointerEvents: "none"
      }} />
      <FlowBackdrop />

      {/* Eyebrow */}
      <Reveal>
        <div className="c7-eyebrow" style={{ position: "relative", zIndex: 2, display: "flex", alignItems: "center", gap: 12, marginBottom: 56 }}>
          <span style={{ width: 36, height: 1, background: "var(--c7-silver-2)" }} />
          {t.hero.eyebrow}
        </div>
      </Reveal>

      {/* Big title */}
      <div style={{ position: "relative", zIndex: 2, maxWidth: 1280 }}>
        <Reveal delay={120}>
          <h1 style={{
            fontFamily: "var(--c7-font-display)",
            fontSize: "clamp(56px, 8.5vw, 144px)",
            fontWeight: 200,
            lineHeight: 0.95,
            letterSpacing: "-0.035em",
            margin: "0 0 48px",
            color: "var(--c7-white)"
          }}>
            <span style={{ display: "block" }}>{t.hero.title_a}</span>
            <span className="c7-chrome-text" style={{ display: "block", fontWeight: 400, fontStyle: "italic" }}>
              {t.hero.title_b}
            </span>
          </h1>
        </Reveal>
      </div>

      {/* Sub + CTA */}
      <div style={{ position: "relative", zIndex: 2, maxWidth: 720 }}>
        <Reveal delay={220}>
          <p style={{ fontSize: 20, lineHeight: 1.55, color: "var(--c7-silver-3)", marginBottom: 40, fontWeight: 300 }}>
            {t.hero.sub}
          </p>
        </Reveal>
        <Reveal delay={300}>
          <div style={{ display: "flex", gap: 16 }}>
            <C7Button variant="primary" onClick={onQuote}>{t.hero.cta_primary} →</C7Button>
          </div>
        </Reveal>
      </div>

      {/* Caption */}
      <Reveal delay={420}>
        <div style={{
          position: "relative", zIndex: 2,
          marginTop: 72, paddingTop: 20,
          borderTop: "1px solid rgba(255,255,255,0.08)",
          display: "flex", justifyContent: "space-between",
          fontFamily: "var(--c7-font-mono)", fontSize: 11,
          color: "var(--c7-silver-1)", letterSpacing: "0.16em", textTransform: "uppercase"
        }}>
          <span>{t.hero.hero_caption}</span>
        </div>
      </Reveal>
    </section>);

};

const FlowBackdrop = () => {
  // Linhas curvas animadas — liquidez/velocidade
  const [t, setT] = React.useState(0);
  React.useEffect(() => {
    let raf;
    const start = performance.now();
    const loop = (now) => {
      setT((now - start) / 1000);
      raf = requestAnimationFrame(loop);
    };
    raf = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(raf);
  }, []);
  const lines = 14;
  return (
    <svg
      style={{ position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: 0.6 }}
      viewBox="0 0 1600 800"
      preserveAspectRatio="none">
      
      <defs>
        <linearGradient id="flow" x1="0" y1="0" x2="1" y2="0">
          <stop offset="0" stopColor="rgba(200,200,205,0)" />
          <stop offset="0.4" stopColor="rgba(200,200,205,0.35)" />
          <stop offset="0.6" stopColor="rgba(200,200,205,0.35)" />
          <stop offset="1" stopColor="rgba(200,200,205,0)" />
        </linearGradient>
      </defs>
      {Array.from({ length: lines }).map((_, i) => {
        const offset = i / lines * 800;
        const phase = t * 0.4 + i * 0.4;
        const amp = 60 + Math.sin(phase * 0.7) * 30;
        const path = `M 0 ${offset} Q 400 ${offset + Math.sin(phase) * amp}, 800 ${offset + Math.sin(phase + 1) * amp * 0.6} T 1600 ${offset}`;
        return (
          <path
            key={i}
            d={path}
            stroke="url(#flow)"
            strokeWidth={i % 3 === 0 ? "0.8" : "0.4"}
            fill="none"
            opacity={0.2 + i % 3 * 0.15} />);


      })}
    </svg>);

};

const TickerStripP = () => {
  const [prices, setPrices] = React.useState({
    USDTBRL: { price: 5.4218, prev: 5.4218 },
    BTCUSDT: { price: 71420, prev: 71420 },
    ETHUSDT: { price: 3884, prev: 3884 }
  });

  React.useEffect(() => {
    let cancelled = false;
    const symbols = ["USDTBRL", "BTCUSDT", "ETHUSDT"];

    const fetchAll = async () => {
      try {
        const results = await Promise.all(
          symbols.map((s) =>
            fetch(`https://api.binance.com/api/v3/ticker/price?symbol=${s}`).then((r) => r.json())
          )
        );
        if (cancelled) return;
        setPrices((prev) => {
          const next = { ...prev };
          results.forEach((r, i) => {
            const sym = symbols[i];
            const newPrice = parseFloat(r.price);
            if (!isNaN(newPrice)) {
              next[sym] = { price: newPrice, prev: prev[sym].price };
            }
          });
          return next;
        });
      } catch (e) {/* mantém valores anteriores */}
    };

    fetchAll();
    const id = setInterval(fetchAll, 7000);
    return () => { cancelled = true; clearInterval(id); };
  }, []);

  const arrow = (cur, prev) => cur > prev ? "▲" : cur < prev ? "▼" : "●";
  const fmtBRL = (n) => n.toFixed(4);
  const fmtBig = (n) => n.toLocaleString("en-US", { maximumFractionDigits: 0 });

  const items = [
    `USDT/BRL ${fmtBRL(prices.USDTBRL.price)} ${arrow(prices.USDTBRL.price, prices.USDTBRL.prev)}`,
    "USDT/USD 0.9998 ●",
    `BTC/USDT ${fmtBig(prices.BTCUSDT.price)} ${arrow(prices.BTCUSDT.price, prices.BTCUSDT.prev)}`,
    `ETH/USDT ${fmtBig(prices.ETHUSDT.price)} ${arrow(prices.ETHUSDT.price, prices.ETHUSDT.prev)}`,
    "SETTLEMENT ≤ 5 min",
    "DESK ACTIVE 24H"];

  return (
    <div style={{
      borderTop: "1px solid rgba(255,255,255,0.08)",
      borderBottom: "1px solid rgba(255,255,255,0.08)",
      padding: "16px 0",
      overflow: "hidden",
      whiteSpace: "nowrap",
      background: "rgba(255,255,255,0.012)"
    }}>
      <div style={{ display: "inline-flex", gap: 60, animation: "c7marquee 50s linear infinite", paddingLeft: 60 }}>
        {[...items, ...items, ...items].map((x, i) =>
        <span key={i} style={{
          fontFamily: "var(--c7-font-mono)", fontSize: 12,
          letterSpacing: "0.18em",
          color: x.includes("▲") ? "oklch(0.72 0.14 152)" : x.includes("▼") ? "oklch(0.62 0.18 25)" : "var(--c7-silver-1)",
          textTransform: "uppercase"
        }}>
            {x}
          </span>
        )}
      </div>
      <style>{`@keyframes c7marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-33.33%); } }`}</style>
    </div>);

};

const LivePanelSection = ({ t, ticker, trend, fmt }) => {
  const [ref, shown] = useReveal();
  const [flashClass, setFlashClass] = React.useState("");
  const prevPrice = React.useRef(ticker);
  const [animatedPrice, setAnimatedPrice] = React.useState(0);
  const book = useOrderBook();

  // Count-up entrance: anima de 0 até ticker quando entra em view
  React.useEffect(() => {
    if (!shown) return;
    const start = performance.now();
    const duration = 1400;
    const target = ticker;
    let raf;
    const tick = (t) => {
      const p = Math.min(1, (t - start) / duration);
      const eased = 1 - Math.pow(1 - p, 3);
      setAnimatedPrice(target * eased);
      if (p < 1) raf = requestAnimationFrame(tick);else
      setAnimatedPrice(null); // libera para o ticker live
    };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [shown]);

  // Flash green/red quando o ticker oscila (após o entrance acabar)
  React.useEffect(() => {
    if (animatedPrice !== null) return; // ainda animando entrance
    const diff = ticker - prevPrice.current;
    if (Math.abs(diff) > 0.0001) {
      setFlashClass(diff > 0 ? "c7-flash-up" : "c7-flash-down");
      const id = setTimeout(() => setFlashClass(""), 700);
      prevPrice.current = ticker;
      return () => clearTimeout(id);
    }
  }, [ticker, animatedPrice]);

  const displayPrice = animatedPrice !== null ? animatedPrice : ticker;

  return (
    <section ref={ref} style={{
      padding: "56px 40px",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      display: "flex",
      justifyContent: "center"
    }}>
      <style>{`
        @keyframes c7-live-pulse {
          0%, 100% { opacity: 1; transform: scale(1); }
          50% { opacity: 0.4; transform: scale(0.85); }
        }
        @keyframes c7-flash-up {
          0% { color: oklch(0.78 0.16 152); text-shadow: 0 0 24px oklch(0.72 0.18 152 / 0.6); }
          100% { color: var(--c7-platinum); text-shadow: none; }
        }
        @keyframes c7-flash-down {
          0% { color: oklch(0.68 0.20 25); text-shadow: 0 0 24px oklch(0.62 0.22 25 / 0.6); }
          100% { color: var(--c7-platinum); text-shadow: none; }
        }
        .c7-flash-up { animation: c7-flash-up 0.7s ease-out; }
        .c7-flash-down { animation: c7-flash-down 0.7s ease-out; }
        .c7-live-dot {
          display: inline-block;
          width: 6px;
          height: 6px;
          border-radius: 50%;
          background: oklch(0.72 0.14 152);
          margin-right: 8px;
          vertical-align: middle;
          animation: c7-live-pulse 1.6s ease-in-out infinite;
          box-shadow: 0 0 8px oklch(0.72 0.14 152 / 0.6);
        }
      `}</style>
      <div style={{

        maxWidth: 900,
        background: "rgba(10,10,12,0.7)",
        border: "1px solid rgba(255,255,255,0.10)",
        backdropFilter: "blur(16px)",
        padding: "32px 40px", width: "1400px"
      }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 24 }}>
          <div className="c7-eyebrow">{t.hero.ticker_label}</div>
          <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 9, color: "oklch(0.72 0.14 152)", letterSpacing: "0.18em" }}>
            <span className="c7-live-dot"></span>LIVE
          </div>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 48, alignItems: "center" }}>
          <div>
            <div className={`c7-chrome-text ${flashClass}`} style={{
              fontFamily: "var(--c7-font-display)",
              fontSize: 64,
              fontWeight: 300,
              letterSpacing: "-0.02em",
              lineHeight: 1,
              marginBottom: 8, backgroundSize: "cover", width: "300px"
            }}>
              R$ {fmt(displayPrice)}
            </div>
            <div style={{
              display: "grid", gridTemplateColumns: "1fr 1fr 1fr",
              gap: 1, background: "rgba(255,255,255,0.06)", marginTop: 20
            }}>
              {(() => {
                const bidStr = book.bid > 0 ? `R$ ${fmt(book.bid)}` : `R$ ${fmt(ticker - 0.012)}`;
                const askStr = book.ask > 0 ? `R$ ${fmt(book.ask)}` : `R$ ${fmt(ticker + 0.014)}`;
                const spreadStr = book.spread > 0 ? `${book.spread.toFixed(2)}%` : "0.48%";
                return [["BID", bidStr], ["ASK", askStr], ["SPREAD", spreadStr]];
              })().map(([k, v]) =>
              <div key={k} style={{ background: "rgba(10,10,12,0.95)", padding: "10px 16px" }}>
                  <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 9, color: "var(--c7-silver-1)", letterSpacing: "0.18em", marginBottom: 4 }}>{k}</div>
                  <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 13, color: "var(--c7-platinum)" }}>{v}</div>
                </div>
              )}
            </div>
          </div>
          <div>
            <Sparkline width={500} height={80} color="rgba(200,200,205,0.7)" trend={trend} />
          </div>
        </div>
      </div>
    </section>);

};

const LivePanel = ({ t, ticker, fmt }) => {
  return (
    <div style={{
      background: "rgba(10,10,12,0.7)",
      border: "1px solid rgba(255,255,255,0.10)",
      backdropFilter: "blur(16px)",
      padding: 28
    }}>
      <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 20 }}>
        <div className="c7-eyebrow">{t.hero.ticker_label}</div>
        <div style={{
          fontFamily: "var(--c7-font-mono)",
          fontSize: 9,
          color: "oklch(0.72 0.14 152)",
          letterSpacing: "0.18em"
        }}>● LIVE</div>
      </div>
      <div className="c7-chrome-text" style={{
        fontFamily: "var(--c7-font-display)",
        fontSize: 48,
        fontWeight: 300,
        letterSpacing: "-0.02em",
        marginBottom: 12,
        lineHeight: 1
      }}>
        R$ {fmt(ticker)}
      </div>
      <Sparkline width={300} height={48} color="rgba(200,200,205,0.7)" />
      <div style={{
        display: "grid",
        gridTemplateColumns: "1fr 1fr 1fr",
        gap: 1,
        background: "rgba(255,255,255,0.06)",
        marginTop: 20
      }}>
        {[
        ["BID", `R$ ${fmt(ticker - 0.012)}`],
        ["ASK", `R$ ${fmt(ticker + 0.014)}`],
        ["SPREAD", "0.48%"]].
        map(([k, v]) =>
        <div key={k} style={{ background: "rgba(10,10,12,0.95)", padding: "10px 12px" }}>
            <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 9, color: "var(--c7-silver-1)", letterSpacing: "0.18em", marginBottom: 4 }}>{k}</div>
            <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 12, color: "var(--c7-platinum)" }}>{v}</div>
          </div>
        )}
      </div>
    </div>);

};

const MetricsP = ({ t }) => {
  const [hoverIdx, setHoverIdx] = React.useState(null);
  const [isMobile, setIsMobile] = React.useState(false);
  React.useEffect(() => {
    const mq = window.matchMedia("(max-width: 768px)");
    const update = () => setIsMobile(mq.matches);
    update();
    mq.addEventListener ? mq.addEventListener("change", update) : mq.addListener(update);
    return () => {
      mq.removeEventListener ? mq.removeEventListener("change", update) : mq.removeListener(update);
    };
  }, []);
  return (
    <section style={{
      padding: "72px 40px",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      background: "linear-gradient(180deg, rgba(255,255,255,0.012), transparent)"
    }}>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 0 }}>
        {t.metrics.map((m, i) => {
          const isHover = hoverIdx === i;
          return (
            <Reveal key={i} delay={i * 80}>
            <div
                onMouseEnter={() => !isMobile && setHoverIdx(i)}
                onMouseLeave={() => !isMobile && setHoverIdx(null)}
                onClick={() => isMobile && setHoverIdx(isHover ? null : i)}
                style={{
                  padding: "8px 32px",
                  borderLeft: i === 0 ? "none" : "1px solid rgba(255,255,255,0.08)",
                  position: "relative",
                  cursor: isMobile && m.d ? "pointer" : "default",
                  transform: isHover ? "scale(1.04)" : "scale(1)",
                  transformOrigin: "left center",
                  transition: "transform 0.4s cubic-bezier(0.22,1,0.36,1), filter 0.4s ease"
                }}>
                
              {/* Glow background */}
              <div style={{
                  position: "absolute",
                  inset: -8,
                  background: "radial-gradient(circle at 30% 50%, rgba(220,220,230,0.06), transparent 70%)",
                  opacity: isHover ? 1 : 0,
                  transition: "opacity 0.5s ease",
                  pointerEvents: "none",
                  zIndex: 0
                }} />
              <div style={{ position: "relative", zIndex: 1 }}>
                {/* "+" / "×" indicator — só visível no mobile via CSS */}
                {m.d &&
                  <span className="c7-metric-toggle" style={{
                    position: "absolute",
                    top: 0,
                    right: 0,
                    fontFamily: "var(--c7-font-mono)",
                    fontSize: 28,
                    color: "var(--c7-silver-2)",
                    transition: "transform 0.4s ease",
                    transform: isHover ? "rotate(45deg)" : "rotate(0deg)",
                    lineHeight: 1,
                    pointerEvents: "none",
                    display: "none"
                  }}>+</span>
                }
                <div className="c7-chrome-text" style={{
                    fontFamily: "var(--c7-font-display)",
                    fontSize: 56,
                    fontWeight: 300,
                    letterSpacing: "-0.025em",
                    lineHeight: 1,
                    marginBottom: 14,
                    textShadow: isHover ? "0 0 32px rgba(220,220,230,0.18)" : "none",
                    transition: "text-shadow 0.4s ease"
                  }}>{m.v}</div>
                <div style={{
                    fontFamily: "var(--c7-font-mono)",
                    fontSize: 14,
                    color: "var(--c7-silver-2)",
                    letterSpacing: "0.14em",
                    textTransform: "uppercase"
                  }}>{m.l}</div>
                {/* Descrição que aparece com fade-in */}
                {m.d &&
                  <div style={{
                    marginTop: 14,
                    fontSize: 14,
                    lineHeight: 1.55,
                    color: "var(--c7-silver-2)",
                    fontWeight: 300,
                    opacity: isHover ? 1 : 0,
                    transform: isHover ? "translateY(0)" : "translateY(-4px)",
                    transition: "opacity 0.45s ease 0.1s, transform 0.45s cubic-bezier(0.22,1,0.36,1) 0.1s",
                    maxHeight: isHover ? 200 : 0,
                    overflow: "hidden"
                  }}>
                    {m.d}
                  </div>
                  }
              </div>
            </div>
          </Reveal>);
        })}
      </div>
    </section>);

};

const AboutP = ({ t }) => {
  return (
    <section id="s0" style={{
      padding: "160px 40px",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      position: "relative",
      overflow: "hidden"
    }}>
      {/* Eyebrow no canto superior esquerdo */}
      <div className="c7-eyebrow" style={{ position: "absolute", top: 56, left: 40 }}>{t.about.eyebrow}</div>

      {/* Conteúdo centralizado */}
      <Reveal delay={100}>
        <div style={{ textAlign: "center", maxWidth: 800, margin: "0 auto" }}>
          <h2 style={{
            fontFamily: "var(--c7-font-display)",
            fontSize: "clamp(40px, 5vw, 80px)",
            fontWeight: 200,
            lineHeight: 1.02,
            letterSpacing: "-0.03em",
            margin: "0 0 48px",
            color: "var(--c7-white)"
          }}>
            {t.about.title}
          </h2>
          {t.about.body.split("\n\n").map((para, i) =>
          <p key={i} style={{ fontSize: 19, lineHeight: 1.6, color: "var(--c7-silver-3)", marginBottom: 24, fontWeight: 300 }}>
              {para}
            </p>
          )}
          <p style={{ fontSize: 19, lineHeight: 1.6, color: "var(--c7-silver-3)", fontWeight: 300 }}>
            {t.about.body2}
          </p>
        </div>
      </Reveal>
    </section>);
};

const ProcessP = ({ t, onQuote }) => {
  const containerRef = React.useRef(null);
  const [activeStep, setActiveStep] = React.useState(-1);
  // lineProgress[i]: 0..1 preenchimento da linha entre step i e i+1
  const [lineProgress, setLineProgress] = React.useState([0, 0, 0]);
  const animRefs = React.useRef([null, null, null]);
  const progressRef = React.useRef([0, 0, 0]);

  const animLine = (idx, target, dur = 800) => {
    if (animRefs.current[idx]) cancelAnimationFrame(animRefs.current[idx]);
    const start = performance.now();
    const from = progressRef.current[idx];
    const tick = (now) => {
      const p = Math.min(1, (now - start) / dur);
      const ease = p < 0.5 ? 2 * p * p : 1 - Math.pow(-2 * p + 2, 2) / 2;
      const val = from + (target - from) * ease;
      progressRef.current[idx] = val;
      setLineProgress((prev) => {const c = [...prev];c[idx] = val;return c;});
      if (p < 1) animRefs.current[idx] = requestAnimationFrame(tick);
    };
    animRefs.current[idx] = requestAnimationFrame(tick);
  };

  const handleEnter = (i) => {
    setActiveStep(i);
    // Linhas anteriores: completas instantaneamente
    for (let k = 0; k < i; k++) {
      if (animRefs.current[k]) cancelAnimationFrame(animRefs.current[k]);
      progressRef.current[k] = 1;
      setLineProgress((prev) => {const c = [...prev];c[k] = 1;return c;});
    }
    // Linha atual (i → i+1): só anima se não for o último box
    if (i < 3) animLine(i, 1, 900);
    // Linhas seguintes: resetam para 0
    for (let k = i + 1; k < 3; k++) {
      if (animRefs.current[k]) cancelAnimationFrame(animRefs.current[k]);
      progressRef.current[k] = 0;
      setLineProgress((prev) => {const c = [...prev];c[k] = 0;return c;});
    }
  };

  const handleLeave = () => {
    setActiveStep(-1);
    // Resetar TODAS as linhas ao sair, para que a próxima entrada recomece do zero
    for (let k = 0; k < 3; k++) {
      if (animRefs.current[k]) cancelAnimationFrame(animRefs.current[k]);
      progressRef.current[k] = 0;
    }
    setLineProgress([0, 0, 0]);
  };

  // Calcula posições das caixas para desenhar SVG
  const BOX = 72;
  const GAP = 24;
  const COLS = 4;
  // Vamos usar SVG posicionado sobre o grid, com viewBox dinâmica
  // Cada coluna ocupa 1/4. O centro do box fica em col*25% + 12.5% - metade do box

  return (
    <section id="processo" style={{ padding: "160px 40px", borderBottom: "1px solid rgba(255,255,255,0.06)", position: "relative" }}>
      {/* Eyebrow no canto superior esquerdo */}
      <div className="c7-eyebrow" style={{ position: "absolute", top: 56, left: 40 }}>{t.process.eyebrow}</div>

      {/* Layout: título + steps à esquerda, calculadora à direita */}
      <div style={{ display: "grid", gridTemplateColumns: "1fr auto", gap: 80, alignItems: "start" }}>
        <div>
          <Reveal>
            <h2 style={{
              fontFamily: "var(--c7-font-display)",
              fontSize: "clamp(40px, 5vw, 80px)",
              fontWeight: 200, lineHeight: 1.02,
              letterSpacing: "-0.03em", margin: "0 0 72px", color: "var(--c7-white)", textAlign: "center"

            }}>{t.process.title}</h2>
          </Reveal>

          <div ref={containerRef} style={{ position: "relative" }}>
        {/* SVG overlay para as 3 linhas animadas */}
        <svg
              style={{
                position: "absolute",
                top: 0, left: 0,
                width: "100%",
                height: BOX + 2,
                pointerEvents: "none",
                overflow: "visible"
              }}
              preserveAspectRatio="none">
              
          <defs>
            <filter id="glow-line">
              <feGaussianBlur stdDeviation="2" result="blur" />
              <feMerge><feMergeNode in="blur" /><feMergeNode in="SourceGraphic" /></feMerge>
            </filter>
          </defs>
          {[0, 1, 2].map((idx) => {
                // Linha vai do lado direito do box idx até o lado esquerdo do box idx+1
                // Cada coluna = 25% da largura. Box tem 72px. Gap entre colunas = 24px.
                // x1 = col_idx_start + 72px, x2 = col_(idx+1)_start
                // Em % relativo ao container: col i começa em i*25% + i*gap/totalWidth
                // Simplificamos: usamos calc() no SVG via foreignObject não é possível
                // Usamos porcentagens aproximadas: col i center ~ (i + 0.5) * 25%
                // Box right ~ col_start + 72/(containerWidth) — usamos valor fixo visual
                // Melhor abordagem: posicionar linhas entre centros dos boxes mas recuadas
                const colW = 25; // % por coluna
                const boxPct = 5; // 72px ~ 5% de 1440px
                const gapPct = 1.67; // 24px ~ 1.67% de 1440px
                const x1 = idx * colW + boxPct + gapPct * idx;
                const x2 = (idx + 1) * colW + gapPct * (idx + 1);
                const lineW = x2 - x1;
                return (
                  <g key={idx}>
                {/* Trilho base */}
                <line
                      x1={`${x1}%`}
                      y1={BOX / 2}
                      x2={`${x2}%`}
                      y2={BOX / 2}
                      stroke="rgba(255,255,255,0.10)"
                      strokeWidth="1" />
                    
                {/* Linha animada */}
                <line
                      x1={`${x1}%`}
                      y1={BOX / 2}
                      x2={`${x1 + lineProgress[idx] * lineW}%`}
                      y2={BOX / 2}
                      stroke="rgba(200,200,205,0.9)"
                      strokeWidth="1.5"
                      strokeLinecap="round"
                      filter={lineProgress[idx] > 0.02 ? "url(#glow-line)" : "none"} />
                    
                {/* Ponto brilhante na ponta */}
                {lineProgress[idx] > 0.02 && lineProgress[idx] < 0.98 &&
                    <circle
                      cx={`${x1 + lineProgress[idx] * lineW}%`}
                      cy={BOX / 2}
                      r="3"
                      fill="rgba(230,230,234,1)"
                      filter="url(#glow-line)" />

                    }
              </g>);

              })}
        </svg>

        {/* Grid dos steps */}
        <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: GAP }}>
          {t.process.steps.map((s, i) =>
              <Reveal key={i} delay={i * 100}>
              <div
                  style={{ position: "relative" }}
                  onMouseEnter={() => handleEnter(i)}
                  onMouseLeave={handleLeave}>
                  
                <ProcBox label={s.n} active={activeStep === i} lit={activeStep >= i || lineProgress[Math.max(0, i - 1)] >= 0.95} />
                <h4 style={{
                    fontFamily: "var(--c7-font-display)", fontSize: 22, fontWeight: 500,
                    margin: "0 0 12px", color: "var(--c7-white)", letterSpacing: "-0.01em"
                  }}>{s.t}</h4>
                <p style={{ fontSize: 16, lineHeight: 1.6, color: "var(--c7-silver-2)", margin: 0, fontWeight: 300 }}>
                  {s.d}
                </p>
              </div>
            </Reveal>
              )}
        </div>
      </div>
        </div>
        {/* Calculadora à direita */}
        <Reveal delay={200}>
          <div style={{ width: 420, position: "sticky", top: 100 }}>
            <QuoteCalculator t={t.desk} onConfirm={onQuote} />
          </div>
        </Reveal>
      </div>
    </section>);

};

const ProcBox = ({ label, active, lit }) =>
<div style={{ width: 72, height: 72, marginBottom: 28, position: "relative" }}>
    {/* Aura glow prata */}
    <div style={{
    position: "absolute",
    inset: -12,
    borderRadius: 4,
    background: "radial-gradient(ellipse at center, rgba(200,200,205,0.18) 0%, transparent 65%)",
    opacity: active ? 1 : 0,
    transition: "opacity 0.5s ease",
    pointerEvents: "none"
  }} />
    {/* Box */}
    <div style={{
    width: 72, height: 72,
    border: `1px solid ${active ? "rgba(210,210,218,0.7)" : lit ? "rgba(200,200,205,0.3)" : "rgba(255,255,255,0.14)"}`,
    background: active ?
    "linear-gradient(135deg, #202028 0%, #0c0c12 100%)" :
    "linear-gradient(135deg, #14141a 0%, #0a0a0d 100%)",
    boxShadow: active ?
    "0 0 0 1px rgba(200,200,205,0.12), 0 0 24px rgba(200,200,205,0.12)" :
    "none",
    display: "flex", alignItems: "center", justifyContent: "center",
    transition: "all 0.45s cubic-bezier(.2,.8,.2,1)",
    position: "relative", zIndex: 1
  }}>
      <span className="c7-chrome-text" style={{
      fontFamily: "var(--c7-font-display)", fontSize: 24, fontWeight: 300
    }}>{label}</span>
    </div>
  </div>;


const FaqP = ({ t }) => {
  const [open, setOpen] = React.useState(0);
  const items = t.faq && t.faq.items || [];
  return (
    <section id="faq" style={{
      padding: "160px 40px",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      position: "relative"
    }}>
      <div className="c7-eyebrow" style={{ position: "absolute", top: 56, left: 40 }}>{t.faq && t.faq.eyebrow}</div>
      <div style={{ maxWidth: 960, margin: "0 auto" }}>
        <Reveal>
          <h2 style={{
            fontFamily: "var(--c7-font-display)",
            fontSize: "clamp(40px, 5vw, 80px)",
            fontWeight: 200, lineHeight: 1.02,
            letterSpacing: "-0.03em", margin: "0 0 72px",
            color: "var(--c7-white)", textAlign: "center"
          }}>{t.faq && t.faq.title}</h2>
        </Reveal>
        <div style={{ borderTop: "1px solid rgba(255,255,255,0.08)" }}>
          {items.map((it, i) =>
          <Reveal key={i} delay={i * 60}>
              <div
              onClick={() => setOpen(open === i ? -1 : i)}
              style={{
                borderBottom: "1px solid rgba(255,255,255,0.08)",
                padding: "28px 4px",
                cursor: "pointer",
                transition: "background 0.3s"
              }}>
              
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", gap: 24 }}>
                  <h4 style={{
                  fontFamily: "var(--c7-font-display)",
                  fontSize: 22, fontWeight: 400,
                  margin: 0, color: "var(--c7-white)",
                  letterSpacing: "-0.01em"
                }}>{it.q}</h4>
                  <span style={{
                  fontFamily: "var(--c7-font-mono)",
                  fontSize: 20,
                  color: "var(--c7-silver-2)",
                  transition: "transform 0.4s ease",
                  transform: open === i ? "rotate(45deg)" : "rotate(0deg)",
                  flexShrink: 0
                }}>+</span>
                </div>
                <div style={{
                maxHeight: open === i ? 240 : 0,
                overflow: "hidden",
                transition: "max-height 0.5s cubic-bezier(.2,.8,.2,1), opacity 0.4s",
                opacity: open === i ? 1 : 0
              }}>
                  <p style={{
                  fontSize: 17, lineHeight: 1.65,
                  color: "var(--c7-silver-3)",
                  margin: "20px 0 8px",
                  fontWeight: 300,
                  maxWidth: 760
                }}>{it.a}</p>
                </div>
              </div>
            </Reveal>
          )}
        </div>
      </div>
    </section>);

};

const ContactP = ({ t, lang = "pt", quoteData = null }) => {
  return (
    <section id="contact" style={{
      padding: "160px 40px",
      borderBottom: "1px solid rgba(255,255,255,0.06)",
      background: "linear-gradient(180deg, transparent, rgba(255,255,255,0.012))"
    }}>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 80 }}>
        <Reveal>
          <div>
            <div className="c7-eyebrow" style={{ marginBottom: 24 }}>{t.contact.eyebrow}</div>
            <h2 style={{
              fontFamily: "var(--c7-font-display)",
              fontSize: "clamp(40px, 5.5vw, 88px)",
              fontWeight: 200,
              lineHeight: 1,
              letterSpacing: "-0.03em",
              margin: "0 0 32px",
              color: "var(--c7-white)"
            }}>
              {t.contact.title}
            </h2>
            <p style={{ fontSize: 18, lineHeight: 1.55, color: "var(--c7-silver-3)", maxWidth: 460, marginBottom: 48, fontWeight: 300 }}>
              {t.contact.sub}
            </p>
            <div style={{ paddingTop: 28, borderTop: "1px solid rgba(255,255,255,0.12)" }}>
              <div className="c7-eyebrow" style={{ marginBottom: 14 }}>{t.contact.direct}</div>
              <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 18, color: "var(--c7-platinum)", marginBottom: 6 }}>suporte@core7cap.com</div>
              <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 14, color: "var(--c7-silver-2)" }}>+55 27 99265 9494</div>
            </div>
          </div>
        </Reveal>
        <Reveal delay={150}>
          <ContactFormP t={t.contact} lang={lang} quoteData={quoteData} />
        </Reveal>
      </div>
    </section>);

};

const ContactFormP = ({ t, lang = "pt", quoteData = null }) => {
  const [submitted, setSubmitted] = React.useState(false);
  const [sending, setSending] = React.useState(false);
  const [error, setError] = React.useState("");
  const [personType, setPersonType] = React.useState("pj");

  const buildQuoteMsg = (q) => {
    if (!q) return "";
    const isEn = lang === "en";
    const fmt2 = (n, d = 2) => n.toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d });
    const side = q.side === "buy"
      ? (isEn ? "Buy USDT" : "Comprar USDT")
      : (isEn ? "Sell USDT" : "Vender USDT");
    const sendLabel  = isEn ? "Send"    : "Envio";
    const recvLabel  = isEn ? "Receive" : "Recebimento";
    const rateLabel  = isEn ? "Rate"    : "Taxa";
    const midLabel   = isEn ? "Ref. rate" : "Câmbio ref.";
    const spreadLabel= isEn ? "Spread"  : "Spread";
    return [
      `[${isEn ? "Quote" : "Cotação"}: ${side}]`,
      `${sendLabel}: ${q.side === "buy" ? "R$ " + fmt2(q.amount, 2) : fmt2(q.amount, 4) + " USDT"}`,
      `${recvLabel}: ${q.side === "buy" ? fmt2(q.receive, 4) + " USDT" : "R$ " + fmt2(q.receive, 2)}`,
      `${rateLabel} C7: R$ ${fmt2(q.c7Rate, 4)}`,
      `${midLabel}: R$ ${fmt2(q.mid, 4)}`,
      `${spreadLabel}: ${(q.spreadPct * 100).toFixed(2)}%`,
    ].join("\n");
  };

  const [data, setData] = React.useState(() => ({
    name: "", company: "", email: "", ticket: "USD 100k – 500k",
    msg: buildQuoteMsg(quoteData)
  }));

  // Atualiza a msg se quoteData chegar depois (via scroll do QuoteCalculator)
  React.useEffect(() => {
    if (quoteData) {
      setData(prev => ({ ...prev, msg: buildQuoteMsg(quoteData) }));
    }
  }, [quoteData]);
  const [hcaptchaToken, setHcaptchaToken] = React.useState("");
  // Honeypot — campo invisível para bots
  const [website, setWebsite] = React.useState("");
  const captchaRef = React.useRef(null);
  const captchaContainerId = React.useRef("hcaptcha-" + Math.random().toString(36).slice(2));
  const widgetIdRef = React.useRef(null);
  const [showCaptcha, setShowCaptcha] = React.useState(false);
  // Guarda os dados validados aguardando o captcha
  const pendingSubmit = React.useRef(false);

  // Renderiza o widget hCaptcha uma única vez, na primeira vez que showCaptcha vira true
  const captchaRendered = React.useRef(false);
  React.useEffect(() => {
    if (!showCaptcha || captchaRendered.current) return;
    const tryRender = () => {
      if (window.hcaptcha && document.getElementById(captchaContainerId.current)) {
        widgetIdRef.current = window.hcaptcha.render(captchaContainerId.current, {
          sitekey: "50b2fe65-b00b-4b9e-ad62-3ba471098be2",
          theme: "dark",
          callback: (token) => setHcaptchaToken(token),
          "expired-callback": () => setHcaptchaToken(""),
          "error-callback": () => setHcaptchaToken(""),
        });
        captchaRendered.current = true;
      } else {
        setTimeout(tryRender, 300);
      }
    };
    tryRender();
  }, [showCaptcha]);

  // Dispara o envio automaticamente assim que o token chegar
  React.useEffect(() => {
    if (hcaptchaToken && pendingSubmit.current) {
      pendingSubmit.current = false;
      doSend(hcaptchaToken);
    }
  }, [hcaptchaToken]);

  const set = (k) => (e) => {
    setError("");
    let v = e.target.value;
    if (k === "msg" && v.length > 1000) v = v.slice(0, 1000);
    setData({ ...data, [k]: v });
  };

  const hasLink = (text) => {
    if (!text) return false;
    return [/https?:\/\//i, /www\./i, /\b[a-z0-9-]+\.(com|net|org|io|co|br|xyz|info|biz|ru|cn|tk|ml|ga|cf|me|dev|app|link)\b/i].some((p) => p.test(text));
  };

  const validate = () => {
    if (!data.name.trim()) return t.err_name;
    if (!data.email.trim()) return t.err_email;
    if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) return t.err_email_invalid;
    if (personType === "pj" && !data.company.trim()) return t.err_company;
    if (data.msg.length > 1000) return t.err_msg_long;
    if (hasLink(data.msg)) return t.err_msg_link;
    return null;
  };

  const resetCaptcha = () => {
    setShowCaptcha(false);
    setHcaptchaToken("");
    pendingSubmit.current = false;
    if (widgetIdRef.current !== null && window.hcaptcha) {
      try { window.hcaptcha.reset(widgetIdRef.current); } catch (e) {}
    }
  };

  const doSend = async (token) => {
    setSending(true);
    setError("");
    try {
      const payload = {
        access_key: "14e01ea5-a0d5-495c-937a-5dbe337d2b94",
        subject: `[Core 7 Capital] Novo contato — ${data.name}${personType === "pj" && data.company ? ` (${data.company})` : ""}`,
        from_name: "Core 7 Capital — Site",
        replyto: data.email,
        "Nome": data.name,
        "E-mail": data.email,
        "Tipo": personType === "pj" ? "Empresa" : "Pessoa física",
        "Empresa": data.company || "-",
        "Ticket": data.ticket,
        "Mensagem": data.msg || "(sem mensagem)",
        "Idioma": lang.toUpperCase(),
        "botcheck": website,
        "h-captcha-response": token,
      };
      const res = await fetch("https://api.web3forms.com/submit", {
        method: "POST",
        headers: { "Content-Type": "application/json", "Accept": "application/json" },
        body: JSON.stringify(payload),
      });
      const result = await res.json();
      if (result.success) {
        setSubmitted(true);
      } else {
        setError(result.message || t.err_send);
        resetCaptcha();
      }
    } catch (ex) {
      setError(t.err_send);
      resetCaptcha();
    } finally {
      setSending(false);
    }
  };

  const handleSubmit = async (e) => {
    e.preventDefault();
    const err = validate();
    if (err) { setError(err); return; }
    setError("");
    pendingSubmit.current = true;
    setShowCaptcha(true);
  };

  if (submitted) {
    return (
      <div style={{ padding: "100px 40px", textAlign: "center", border: "1px solid rgba(255,255,255,0.12)", background: "rgba(20,20,26,0.5)" }}>
        <div className="c7-chrome-text" style={{ fontFamily: "var(--c7-font-display)", fontSize: 36, fontWeight: 300, marginBottom: 16 }}>{t.success_title}</div>
        <p style={{ color: "var(--c7-silver-2)", fontSize: 14 }}>{t.success_sub}</p>
      </div>);
  }

  const inputStyle = {
    width: "100%", background: "rgba(0,0,0,0.4)", border: "1px solid rgba(255,255,255,0.10)",
    padding: "16px 18px", fontFamily: "var(--c7-font-display)", fontSize: 16,
    color: "var(--c7-white)", outline: "none", fontWeight: 300, boxSizing: "border-box"
  };
  const tabBtn = (active) => ({
    flex: 1, padding: "12px 16px",
    background: active ? "rgba(255,255,255,0.06)" : "transparent",
    border: "1px solid rgba(255,255,255,0.10)",
    color: active ? "var(--c7-platinum)" : "var(--c7-silver-1)",
    fontFamily: "var(--c7-font-mono)", fontSize: 11, letterSpacing: "0.18em",
    textTransform: "uppercase", cursor: "pointer", transition: "all 0.2s"
  });

  return (
    <form onSubmit={handleSubmit} noValidate style={{ padding: 40, background: "rgba(10,10,12,0.6)", border: "1px solid rgba(255,255,255,0.10)", backdropFilter: "blur(12px)", display: "grid", gap: 22 }}>

      {/* Honeypot */}
      <input type="text" name="website" value={website} onChange={(e) => setWebsite(e.target.value)}
        tabIndex={-1} autoComplete="off" aria-hidden="true"
        style={{ position: "absolute", left: "-9999px", width: 1, height: 1, opacity: 0 }} />

      {/* PF / PJ toggle */}
      <div>
        <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 10, letterSpacing: "0.2em", color: "var(--c7-silver-1)", textTransform: "uppercase", marginBottom: 10 }}>{t.person_type}</div>
        <div style={{ display: "flex", gap: 0 }}>
          <button type="button" onClick={() => setPersonType("pf")} style={tabBtn(personType === "pf")}>{t.person_pf}</button>
          <button type="button" onClick={() => setPersonType("pj")} style={tabBtn(personType === "pj")}>{t.person_pj}</button>
        </div>
      </div>

      <div style={{ display: "grid", gridTemplateColumns: personType === "pj" ? "1fr 1fr" : "1fr", gap: 18 }}>
        <input style={inputStyle} placeholder={t.name + " *"} value={data.name} onChange={set("name")} required />
        {personType === "pj" && <input style={inputStyle} placeholder={t.company + " *"} value={data.company} onChange={set("company")} required />}
      </div>
      <input style={inputStyle} placeholder={t.email + " *"} type="email" value={data.email} onChange={set("email")} required />
      <select style={{ ...inputStyle, appearance: "none" }} value={data.ticket} onChange={set("ticket")}>
        {["USD 0 – 50K","USD 50k – 100k", "USD 100k – 500k", "USD 500k – 1M", "USD 1M – 5M", "USD 5M+"].map((o) =>
          <option key={o} value={o} style={{ background: "#0b0b0d" }}>{o}</option>)}
      </select>
      <div style={{ position: "relative" }}>
        <textarea style={{ ...inputStyle, resize: "vertical", paddingBottom: 28 }} rows={3}
          maxLength={1000} placeholder={`${t.msg} ${t.msg_optional}`} value={data.msg} onChange={set("msg")} />
        <div style={{ position: "absolute", bottom: 8, right: 12, fontFamily: "var(--c7-font-mono)", fontSize: 10, color: data.msg.length > 950 ? "var(--c7-silver-1)" : "rgba(200,200,205,0.35)", letterSpacing: "0.05em", pointerEvents: "none" }}>
          {data.msg.length}/1000
        </div>
      </div>

      {/* hCaptcha widget — visível apenas após clicar Enviar */}
      <div style={{ display: showCaptcha ? "block" : "none" }}>
        <div style={{ fontFamily: "var(--c7-font-mono)", fontSize: 10, letterSpacing: "0.2em", color: "var(--c7-silver-1)", textTransform: "uppercase", marginBottom: 10 }}>
          {lang === "pt" ? "Confirme que você não é um robô" : "Confirm you are not a robot"}
        </div>
        <div id={captchaContainerId.current} ref={captchaRef} />
      </div>

      {error && (
        <div role="alert" style={{ padding: "12px 16px", background: "rgba(180,60,60,0.12)", border: "1px solid rgba(220,90,90,0.4)", color: "#ffb4b4", fontFamily: "var(--c7-font-text)", fontSize: 13, letterSpacing: "0.02em" }}>
          {error}
        </div>
      )}

      <C7Button variant="primary" style={{ justifyContent: "center", opacity: (sending || (showCaptcha && !hcaptchaToken)) ? 0.6 : 1, pointerEvents: sending ? "none" : "auto" }}>
        {sending ? t.sending : showCaptcha && !hcaptchaToken ? (lang === "pt" ? "Aguardando verificação..." : "Waiting for verification...") : `${t.send} →`}
      </C7Button>
    </form>
  );
};

const FooterP = ({ t }) => {
  return (
    <footer style={{ padding: "72px 40px 48px", background: "rgba(0,0,0,0.5)" }}>
      <div style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr 1fr 1.4fr", gap: 48, marginBottom: 56 }}>
        <div>
          <C7Logo size={22} />
          <p style={{ marginTop: 24, color: "var(--c7-silver-2)", fontSize: 14, lineHeight: 1.6, fontWeight: 300, maxWidth: 320 }}>
            {t.footer.tagline}
          </p>
          <div style={{ marginTop: 20, fontFamily: "var(--c7-font-mono)", fontSize: 11, color: "var(--c7-silver-1)", letterSpacing: "0.16em" }}>
            {t.footer.address}
          </div>
        </div>
        <div>
          <div className="c7-eyebrow" style={{ marginBottom: 16 }}>Navegação</div>
          <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
            {[
            { label: t.nav.edge, href: "#processo" },
            { label: t.nav.about, href: "#processo" },
            { label: t.nav.pillars, href: "#s0" },
            { label: t.nav.process, href: "#faq" },
            { label: t.nav.contact, href: "#contact" }].
            map((x) =>
            <li key={x.label} style={{ fontSize: 14 }}>
                <a href={x.href} style={{ color: "var(--c7-silver-3)", textDecoration: "none", transition: "color 0.2s" }}
              onMouseEnter={(e) => e.currentTarget.style.color = "var(--c7-white)"}
              onMouseLeave={(e) => e.currentTarget.style.color = "var(--c7-silver-3)"}>
                  {x.label}
                </a>
              </li>
            )}
          </ul>
        </div>
        <div>
          <div className="c7-eyebrow" style={{ marginBottom: 16 }}>Contato</div>
          <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
            <li style={{ fontFamily: "var(--c7-font-mono)", fontSize: 13, color: "var(--c7-silver-3)" }}>suporte@core7cap.com</li>
            <li style={{ fontFamily: "var(--c7-font-mono)", fontSize: 13, color: "var(--c7-silver-3)" }}>+55 27 99265 9494</li>
          </ul>
        </div>
        <div>
          <div className="c7-eyebrow" style={{ marginBottom: 16 }}>Legal</div>
          <p style={{ fontSize: 11, color: "var(--c7-silver-1)", lineHeight: 1.6, fontWeight: 300 }}>
            {t.footer.disclaimer}
          </p>
        </div>
      </div>
      <Hairline />
      <div style={{ display: "flex", justifyContent: "space-between", marginTop: 28, fontFamily: "var(--c7-font-mono)", fontSize: 11, color: "var(--c7-silver-1)", letterSpacing: "0.12em" }}>
        <span>{t.footer.rights}</span>
        <span>v 2026.04 · BUILD 0007</span>
      </div>
    </footer>);

};

window.Core7Site = Core7Site;