const PRODUCT_MESSAGES = {
  "R001": {
    label: "Mexico Total Trade Atlas",
    popup_subtitle: "Flagship cross-sector overview, launching July 2026. We'll send early-access pricing 4 weeks before formal launch, plus methodology preview 2 weeks before. Pulse $2,500 / Bundle $4,500 / Extended $6,800.",
    post_submit: "You're on the R001 Atlas waitlist. We'll email {email} with early-access pricing 4 weeks before July 2026 launch, plus methodology preview 2 weeks before.",
  },
  "R002": {
    label: "Sector Vertical Reports",
    popup_subtitle: "Industry-specific deep dives beyond AI hardware. Auto, electronics, pharma, food/bev, more sectors. Standard $1,800/sector or Bundle 3 sectors $4,500. Specify your sector in 'interest' field to weight prioritization.",
    post_submit: "You're on the R002 Sector Vertical waitlist. We're prioritizing sectors by demand signal. We'll email {email} when production begins on your sector — typically Q3 2026 onwards.",
  },
  "R003": {
    label: "R003 (general)",
    popup_subtitle: "Named-entity intelligence: Top 20-50 Mexican AI server importers. Three tiers: Pulse $1,500, Bundle $2,200, Extended $2,800. Founder-led reply within 1 business day.",
    post_submit: "Your R003 inquiry is received. Founder reply within 1 business day to {email}, confirming tier, scope, and delivery timeline.",
  },
  "R003 Pulse": {
    label: "R003 Pulse",
    popup_subtitle: "Top 20 importers + methodology disclosure + IMMEX status + 1-sentence commentary per importer. $1,500, 5 business days delivery post-confirmation. Founder-led reply within 1 business day.",
    post_submit: "Your R003 Pulse inquiry is received. Founder reply within 1 business day to {email}, confirming scope and 5-BD delivery timeline.",
  },
  "R003 Bundle": {
    label: "R003 Bundle",
    popup_subtitle: "Top 50 importers + cluster analysis + customs office matrix + country-of-origin breakdown + monthly trajectories. $2,200, 5 business days delivery. Most requested tier.",
    post_submit: "Your R003 Bundle inquiry is received. Founder reply within 1 business day to {email}, confirming scope and 5-BD delivery timeline.",
  },
  "R003 Extended": {
    label: "R003 Extended",
    popup_subtitle: "Bundle features + deeper monthly profiles + expanded forward commentary + Q&A session post-delivery. $2,800, 10 business days delivery.",
    post_submit: "Your R003 Extended inquiry is received. Founder reply within 1 business day to {email}, confirming scope and 10-BD delivery timeline + Q&A scheduling.",
  },
  "R004": {
    label: "Custom Coverage Periods",
    popup_subtitle: "Bespoke coverage: specific time windows, multi-jurisdiction analysis, custom HS-code splits. Quote-based, scoped per engagement. From $5,000. We'll respond within 7 business days to discuss your specific scope.",
    post_submit: "Your R004 Custom Coverage inquiry is received. We'll reach out to {email} within 7 business days to discuss scope, timeline, and pricing. Typical engagements range $5,000-$15,000.",
  },
  "R005": {
    label: "Multi-Sector Bundles",
    popup_subtitle: "Enterprise multi-sector packages: 5-7 sectors with cross-sector synthesis, strategic positioning, executive briefings. Quote-based from $10,000. Q3-Q4 2026 production. We'll email roadmap once configured.",
    post_submit: "You're on the R005 Multi-Sector Bundles waitlist. Production targets Q3-Q4 2026 with sectors weighted by enterprise demand. We'll email {email} with roadmap update once 5+ enterprise commitments confirm sectors.",
  },
  "Retainer Basic": {
    label: "Retainer Basic",
    popup_subtitle: "$3,000/month — 4 analyst-hours, quarterly product update, monthly check-in call, 48-hour response priority, 1 custom query/month. Setup materials within 24 hours of inquiry.",
    post_submit: "Your Retainer Basic inquiry is received. We'll email {email} within 24 hours with setup materials: scope agreement, payment terms, and onboarding call slot.",
  },
  "Retainer Standard": {
    label: "Retainer Standard",
    popup_subtitle: "$5,000/month — 8 analyst-hours, dedicated analyst, 2 monthly calls, 24-hour priority, 2 custom queries/month. Most picked tier. Setup materials within 24 hours.",
    post_submit: "Your Retainer Standard inquiry is received. We'll email {email} within 24 hours with setup materials: scope agreement, payment terms, and onboarding call slot.",
  },
  "Retainer Premium": {
    label: "Retainer Premium",
    popup_subtitle: "$8,000/month — 16 analyst-hours, weekly check-ins, 12-hour priority, unlimited custom queries, quarterly strategic memo. Enterprise white-glove. Setup within 24 hours.",
    post_submit: "Your Retainer Premium inquiry is received. We'll email {email} within 24 hours with setup materials: scope agreement, payment terms, onboarding call slot, and enterprise terms.",
  },
};

function App() {
  const [modal, setModal] = useState({ open: false, mode: "download", context: null });

  const openDownload = useCallback(() => setModal({ open: true, mode: "download", context: null }), []);
  const openWaitlist = useCallback((r) => {
    const msg = PRODUCT_MESSAGES[r.id] || {
      popup_subtitle: `We'll email you when ${r.id} (${r.title}) ships — currently scheduled for ${r.status || "later in 2026"}.`,
      post_submit: `You're on the ${r.id} waitlist. We'll notify {email} when production begins.`,
    };
    setModal({
      open: true,
      mode: "waitlist",
      context: {
        id: r.id,
        title: r.title,
        note: msg.popup_subtitle,
        successMessage: msg.post_submit,
      },
    });
  }, []);
  const openInquire = useCallback((r) => {
    const msg = PRODUCT_MESSAGES[r.id] || {
      popup_subtitle: "A founder-led reply within one business day. We'll confirm scope, coverage, and SLA before any commitment.",
      post_submit: `Your ${r.id} inquiry is received. Founder reply within 1 business day to {email}.`,
    };
    setModal({
      open: true,
      mode: "inquire",
      context: {
        id: r.id,
        title: r.title || r.id,
        note: msg.popup_subtitle,
        successMessage: msg.post_submit,
      },
    });
  }, []);
  const close = useCallback(() => setModal(m => ({ ...m, open: false })), []);

  return (
    <div className="vst-root">
      <Header/>
      <Hero onPrimaryCTA={openDownload}/>
      <FeaturedResearch onDownload={(email) => setModal({ open: true, mode: "download", context: { email } })}/>
      <Coverage onWaitlist={openWaitlist} onInquire={openInquire}/>
      <Pricing onInquire={openInquire}/>
      <FAQ onInquire={openInquire} full={false}/>
      <Methodology/>
      <About/>
      <Contact onInquire={openInquire}/>
      <CTAFinal onPrimaryCTA={openDownload}/>
      <Footer onPrimaryCTA={openDownload} onWaitlist={openWaitlist} onInquire={openInquire}/>
      <CaptureModal
        open={modal.open}
        onClose={close}
        mode={modal.mode}
        context={modal.context}
      />
    </div>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<App/>);
