/* Landing page sections — MeetingMind */

function Hero({ lang }) {
  const title = MM.t(lang, "hero_title").split("\n");
  return (
    <section className="section" style={{ paddingTop: 80, paddingBottom: 60, position: "relative", overflow: "hidden" }}>
      <div className="bg-grid" style={{ position: "absolute", inset: 0, opacity: 0.5, pointerEvents: "none" }}/>
      <div className="container" style={{ position: "relative" }}>
        <div style={{ maxWidth: 820 }}>
          <span className="eyebrow"><span className="dot"/>{MM.t(lang, "hero_eyebrow")}</span>
          <h1 style={{ marginTop: 20, marginBottom: 24 }}>
            {title[0]}<br/>
            <span style={{ color: "var(--text-muted)" }}>{title[1]}</span>
          </h1>
          <p className="lead" style={{ marginBottom: 28 }}>{MM.t(lang, "hero_sub")}</p>
          <div style={{ display: "flex", gap: 12, flexWrap: "wrap", alignItems: "center" }}>
            <a href="app.html" className="btn btn-primary btn-lg">
              {MM.t(lang, "hero_cta")} <Icon name="arrow-right" size={14}/>
            </a>
            <a href="#demo" className="btn btn-secondary btn-lg">
              <Icon name="play" size={14}/> {MM.t(lang, "hero_cta2")}
            </a>
          </div>
          <div className="muted mono" style={{ marginTop: 18, fontSize: 12 }}>{MM.t(lang, "hero_meta")}</div>
        </div>

        <ProductPreview lang={lang}/>
      </div>
    </section>
  );
}

function ProductPreview({ lang }) {
  const sample = lang === "en" ? {
    title: "Q3 Roadmap Sync",
    when: "Today · 32 min",
    decisions: [
      "Ship onboarding revamp by Aug 15",
      "Pause the mobile app rebuild",
      "Hire 2 senior PMs in Q3",
    ],
    actions: [
      ["Anna", "Draft new onboarding flow", "Aug 7"],
      ["Marco", "Brief recruiter on PM roles", "Jul 30"],
      ["Lia", "Send users.csv export to design", "Jul 26"],
    ],
  } : {
    title: "Sync Roadmap Q3",
    when: "Hoje · 32 min",
    decisions: [
      "Lançar onboarding novo até 15/ago",
      "Pausar refactor do app mobile",
      "Contratar 2 PMs sênior no Q3",
    ],
    actions: [
      ["Ana", "Esboçar novo fluxo de onboarding", "07/ago"],
      ["Marco", "Briefar recrutadora pras vagas de PM", "30/jul"],
      ["Lia", "Enviar export de users.csv pro design", "26/jul"],
    ],
  };
  return (
    <div className="card" style={{ marginTop: 56, padding: 0, overflow: "hidden", boxShadow: "var(--shadow-lg)" }}>
      <div style={{ display: "flex", alignItems: "center", gap: 8, padding: "10px 14px", borderBottom: "1px solid var(--border)", background: "var(--bg-sunken)" }}>
        <div style={{ display: "flex", gap: 6 }}>
          {["#FF5F57", "#FEBC2E", "#28C840"].map((c) => (
            <div key={c} style={{ width: 10, height: 10, borderRadius: "50%", background: c, opacity: 0.85 }}/>
          ))}
        </div>
        <div className="mono" style={{ fontSize: 12, color: "var(--text-subtle)", marginLeft: 12 }}>meetingmind.app/m/q3-sync</div>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "1.1fr 1fr", minHeight: 420 }}>
        <div style={{ padding: 28, borderRight: "1px solid var(--border)", background: "var(--bg)" }}>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", marginBottom: 16 }}>
            <div>
              <h3 style={{ marginBottom: 4 }}>{sample.title}</h3>
              <div className="mono muted" style={{ fontSize: 12 }}>{sample.when}</div>
            </div>
            <span className="badge badge-accent">{lang === "en" ? "Processed" : "Processado"}</span>
          </div>
          <SectionLabel icon="doc">TL;DR</SectionLabel>
          <p style={{ fontSize: 14, color: "var(--text)", marginTop: 6, marginBottom: 22, lineHeight: 1.6 }}>
            {lang === "en"
              ? "Team agreed to ship the onboarding revamp before mid-August, deferring the mobile app rebuild. Two senior PM hires unblocked for Q3."
              : "O time concordou em lançar o onboarding novo antes da metade de agosto, adiando o refactor do app mobile. Duas vagas de PM sênior aprovadas pro Q3."}
          </p>
          <SectionLabel icon="check">{lang === "en" ? "Decisions" : "Decisões"}</SectionLabel>
          <ul style={{ listStyle: "none", padding: 0, margin: "8px 0 0", display: "grid", gap: 8 }}>
            {sample.decisions.map((d, i) => (
              <li key={i} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontSize: 14 }}>
                <span style={{ color: "var(--success)", marginTop: 3 }}><Icon name="check" size={14}/></span>
                <span>{d}</span>
              </li>
            ))}
          </ul>
        </div>
        <div style={{ padding: 28 }}>
          <SectionLabel icon="list">{lang === "en" ? "Action items" : "Action items"}</SectionLabel>
          <div style={{ display: "grid", gap: 10, marginTop: 10 }}>
            {sample.actions.map(([who, what, when], i) => (
              <div key={i} className="card" style={{ padding: 12, display: "grid", gridTemplateColumns: "auto 1fr auto", gap: 12, alignItems: "center" }}>
                <Avatar name={who}/>
                <div>
                  <div style={{ fontSize: 14, fontWeight: 500 }}>{what}</div>
                  <div className="mono muted" style={{ fontSize: 11, marginTop: 2 }}>{who}</div>
                </div>
                <span className="badge mono" style={{ fontSize: 11 }}>{when}</span>
              </div>
            ))}
          </div>
          <div style={{ marginTop: 22 }}>
            <SectionLabel icon="mail">{lang === "en" ? "Follow-up email" : "E-mail de follow-up"}</SectionLabel>
            <div className="card" style={{ padding: 14, marginTop: 10, fontSize: 13, fontFamily: "var(--font-mono)", lineHeight: 1.6, color: "var(--text-muted)" }}>
              <div><span style={{ color: "var(--text-subtle)" }}>{lang === "en" ? "Subject:" : "Assunto:"}</span> {lang === "en" ? "Q3 roadmap — what we decided" : "Roadmap Q3 — o que ficou definido"}</div>
              <div style={{ marginTop: 6 }}>{lang === "en" ? "Hey team — quick recap from today's sync…" : "Oi pessoal — recap rápido do nosso sync de hoje…"}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

function SectionLabel({ icon, children }) {
  return (
    <div className="mono" style={{ display: "inline-flex", alignItems: "center", gap: 6, fontSize: 11, textTransform: "uppercase", letterSpacing: "0.1em", color: "var(--text-subtle)" }}>
      <Icon name={icon} size={12}/>{children}
    </div>
  );
}

function Avatar({ name }) {
  const initials = name.split(" ").map(s => s[0]).slice(0, 2).join("").toUpperCase();
  const hue = (name.charCodeAt(0) * 23) % 360;
  return (
    <div style={{
      width: 28, height: 28, borderRadius: "50%",
      background: `oklch(0.85 0.06 ${hue})`, color: `oklch(0.35 0.1 ${hue})`,
      display: "grid", placeItems: "center", fontSize: 11, fontWeight: 600,
      fontFamily: "var(--font-mono)",
    }}>{initials}</div>
  );
}

function LogosStrip({ lang }) {
  const logos = ["Vercel", "Linear", "Loom", "Notion", "Stripe", "Figma", "Raycast"];
  return (
    <section style={{ padding: "32px 0", borderTop: "1px solid var(--border)", borderBottom: "1px solid var(--border)" }}>
      <div className="container" style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 24, flexWrap: "wrap" }}>
        <div className="mono muted" style={{ fontSize: 12 }}>
          {lang === "en" ? "Trusted by teams shipping at" : "Times que enviam pela primeira vez nas startups"}
        </div>
        <div style={{ display: "flex", gap: 28, flexWrap: "wrap", opacity: 0.7 }}>
          {logos.map(l => (
            <span key={l} style={{ fontWeight: 600, letterSpacing: "-0.02em", fontSize: 16, color: "var(--text-muted)" }}>{l}</span>
          ))}
        </div>
      </div>
    </section>
  );
}

function Features({ lang }) {
  const feats = lang === "en" ? [
    { icon: "zap", title: "Decisions, not transcripts", body: "We surface what was decided and why — buried under all the chitchat." },
    { icon: "users", title: "Owner & due-date for every action", body: "Action items come pre-assigned. Pre-dated. No more 'who's doing what?'" },
    { icon: "mail", title: "Follow-up email, ready to send", body: "Get a draft summary email in your team's voice. Copy, edit, send." },
    { icon: "globe", title: "PT, EN, ES, FR", body: "Same quality output, regardless of language. Auto-detected." },
    { icon: "shield", title: "Your data stays yours", body: "Transcripts are never used to train models. Delete on demand." },
    { icon: "doc", title: "Export anywhere", body: "Markdown, PDF, Notion, Linear issues, Slack DMs. One click." },
  ] : [
    { icon: "zap", title: "Decisões, não transcrição", body: "Mostramos o que foi decidido e por quê — escondido entre conversa fiada." },
    { icon: "users", title: "Dono e prazo em cada ação", body: "Action items já vêm com responsável e data. Acabou o 'quem faz o quê?'" },
    { icon: "mail", title: "E-mail de follow-up pronto", body: "Receba um draft no tom do seu time. Copia, ajusta, envia." },
    { icon: "globe", title: "PT, EN, ES, FR", body: "Mesma qualidade em qualquer idioma. Detectado automático." },
    { icon: "shield", title: "Seus dados são seus", body: "Transcrições nunca treinam modelos. Apague quando quiser." },
    { icon: "doc", title: "Exporta pra qualquer lugar", body: "Markdown, PDF, Notion, Linear, Slack. Um clique." },
  ];
  return (
    <section className="section" id="features">
      <div className="container">
        <div style={{ maxWidth: 720, marginBottom: 56 }}>
          <SectionLabel icon="sparkles">{lang === "en" ? "Features" : "Recursos"}</SectionLabel>
          <h2 style={{ marginTop: 12, whiteSpace: "pre-line" }}>{MM.t(lang, "feat_title")}</h2>
          <p className="lead" style={{ marginTop: 14 }}>{MM.t(lang, "feat_sub")}</p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 1, background: "var(--border)", border: "1px solid var(--border)", borderRadius: "var(--radius-lg)", overflow: "hidden" }}>
          {feats.map((f, i) => (
            <div key={i} style={{ background: "var(--bg)", padding: 28 }}>
              <div style={{ width: 36, height: 36, borderRadius: 10, background: "var(--bg-sunken)", display: "grid", placeItems: "center", marginBottom: 16, color: "var(--text)" }}>
                <Icon name={f.icon} size={18}/>
              </div>
              <h3 style={{ marginBottom: 6, fontSize: 17 }}>{f.title}</h3>
              <p className="muted" style={{ margin: 0, fontSize: 14, lineHeight: 1.55 }}>{f.body}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function HowItWorks({ lang }) {
  const steps = lang === "en" ? [
    { n: "01", title: "Paste the transcript", body: "From Zoom, Meet, Teams, Otter, Granola — anywhere. Or upload a .txt/.vtt file." },
    { n: "02", title: "We process it", body: "In about 12 seconds, you get a structured breakdown — built for skimming." },
    { n: "03", title: "Send the follow-up", body: "Edit if you want. Copy the email. Push action items to Linear or Notion." },
  ] : [
    { n: "01", title: "Cole a transcrição", body: "Vinda do Zoom, Meet, Teams, Otter, Granola — qualquer um. Ou suba um .txt/.vtt." },
    { n: "02", title: "A gente processa", body: "Em uns 12 segundos, você recebe um breakdown estruturado, feito pra bater o olho." },
    { n: "03", title: "Manda o follow-up", body: "Ajusta se quiser. Copia o e-mail. Joga os action items no Linear ou Notion." },
  ];
  return (
    <section className="section" style={{ background: "var(--bg-sunken)", borderTop: "1px solid var(--border)", borderBottom: "1px solid var(--border)" }} id="how">
      <div className="container">
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 64, alignItems: "start" }}>
          <div>
            <SectionLabel icon="play">{lang === "en" ? "Workflow" : "Fluxo"}</SectionLabel>
            <h2 style={{ marginTop: 12 }}>{MM.t(lang, "how_title")}</h2>
            <p className="lead" style={{ marginTop: 14 }}>{MM.t(lang, "how_sub")}</p>
          </div>
          <div style={{ display: "grid", gap: 0 }}>
            {steps.map((s, i) => (
              <div key={i} style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 20, padding: "28px 0", borderTop: i === 0 ? "1px solid var(--border-strong)" : "1px solid var(--border)", borderBottom: i === steps.length - 1 ? "1px solid var(--border-strong)" : "none" }}>
                <div className="mono" style={{ fontSize: 24, color: "var(--text-subtle)", letterSpacing: "-0.02em" }}>{s.n}</div>
                <div>
                  <h3 style={{ marginBottom: 6 }}>{s.title}</h3>
                  <p className="muted" style={{ margin: 0, fontSize: 15 }}>{s.body}</p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function Pricing({ lang }) {
  const plans = lang === "en" ? [
    { name: "Free", price: "$0", per: "forever", desc: "For trying it out and small projects.", cta: "Start free",
      features: ["3 meetings per month", "Up to 60 min per meeting", "PT, EN, ES, FR", "Markdown export"] },
    { name: "Pro", price: "$9", per: "/ month", desc: "For PMs and small teams.", cta: "Start 14-day trial", featured: true,
      features: ["Unlimited meetings", "Up to 3 hours per meeting", "Linear + Notion + Slack", "Custom email templates", "History & search"] },
    { name: "Team", price: "$24", per: "/ user / mo", desc: "For teams of 5+.", cta: "Talk to sales",
      features: ["Everything in Pro", "SSO + admin controls", "Shared workspace", "Custom voice & glossary", "Priority support"] },
  ] : [
    { name: "Free", price: "R$0", per: "para sempre", desc: "Pra experimentar e projetos pequenos.", cta: "Começar grátis",
      features: ["3 reuniões por mês", "Até 60 min por reunião", "PT, EN, ES, FR", "Export em Markdown"] },
    { name: "Pro", price: "R$39", per: "/ mês", desc: "Pra PMs e times pequenos.", cta: "14 dias de teste", featured: true,
      features: ["Reuniões ilimitadas", "Até 3h por reunião", "Linear + Notion + Slack", "Templates de e-mail próprios", "Histórico e busca"] },
    { name: "Team", price: "R$99", per: "/ usuário / mês", desc: "Pra times de 5+.", cta: "Falar com vendas",
      features: ["Tudo do Pro", "SSO + controles de admin", "Workspace compartilhado", "Voz e glossário próprios", "Suporte prioritário"] },
  ];
  return (
    <section className="section" id="pricing">
      <div className="container">
        <div style={{ textAlign: "center", maxWidth: 640, margin: "0 auto 56px" }}>
          <SectionLabel icon="zap">{lang === "en" ? "Pricing" : "Preços"}</SectionLabel>
          <h2 style={{ marginTop: 12 }}>{MM.t(lang, "pricing_title")}</h2>
          <p className="lead" style={{ marginTop: 14, marginInline: "auto" }}>{MM.t(lang, "pricing_sub")}</p>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 16 }}>
          {plans.map((p, i) => (
            <div key={i} className="card" style={{
              padding: 28,
              borderColor: p.featured ? "var(--text)" : "var(--border)",
              boxShadow: p.featured ? "var(--shadow-lg)" : "none",
              position: "relative",
            }}>
              {p.featured && (
                <span className="badge" style={{ position: "absolute", top: -10, left: 28, background: "var(--text)", color: "var(--bg)", borderColor: "transparent" }}>
                  {lang === "en" ? "Most popular" : "Mais popular"}
                </span>
              )}
              <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", marginBottom: 6 }}>
                <h3>{p.name}</h3>
              </div>
              <div style={{ display: "flex", alignItems: "baseline", gap: 6, marginBottom: 8 }}>
                <span style={{ fontSize: 36, fontWeight: 600, letterSpacing: "-0.03em" }}>{p.price}</span>
                <span className="muted" style={{ fontSize: 14 }}>{p.per}</span>
              </div>
              <p className="muted" style={{ fontSize: 14, marginTop: 0, marginBottom: 20 }}>{p.desc}</p>
              <a href="app.html" className={`btn ${p.featured ? "btn-primary" : "btn-secondary"}`} style={{ width: "100%", marginBottom: 22 }}>{p.cta}</a>
              <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
                {p.features.map((f, j) => (
                  <li key={j} style={{ display: "flex", gap: 10, fontSize: 14, alignItems: "flex-start" }}>
                    <span style={{ color: "var(--text)", marginTop: 3 }}><Icon name="check" size={14}/></span>
                    <span className="muted">{f}</span>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function FAQ({ lang }) {
  const items = lang === "en" ? [
    ["Do I need to install anything?", "No. Paste your transcript on the web. That's it. Browser extensions and integrations are optional."],
    ["Where do transcripts come from?", "From whatever you already use: Zoom AI Companion, Google Meet, Otter, Granola, Fireflies, or copy-paste from any source."],
    ["What languages do you support?", "Portuguese, English, Spanish and French. The output language matches the input automatically."],
    ["Is my data used to train models?", "Never. Transcripts are processed and discarded by the model provider. You can delete your history anytime."],
    ["Can I cancel?", "Anytime, in one click. Pro-rated refunds for annual plans."],
    ["What if it gets something wrong?", "Every action item, decision and email is editable. Your edits make the next run sharper."],
  ] : [
    ["Preciso instalar alguma coisa?", "Não. Cola a transcrição no navegador. Pronto. Extensões e integrações são opcionais."],
    ["De onde vêm as transcrições?", "Do que você já usa: Zoom AI Companion, Google Meet, Otter, Granola, Fireflies, ou copia-cola de qualquer fonte."],
    ["Quais idiomas vocês suportam?", "Português, inglês, espanhol e francês. O idioma da saída segue o de entrada automaticamente."],
    ["Meus dados são usados pra treinar modelo?", "Nunca. Transcrições são processadas e descartadas pelo provedor do modelo. Você pode apagar histórico a qualquer momento."],
    ["Posso cancelar?", "Quando quiser, num clique. Reembolso proporcional em planos anuais."],
    ["E se a IA errar?", "Todo action item, decisão e e-mail é editável. Suas edições deixam a próxima rodada mais afiada."],
  ];
  const [open, setOpen] = React.useState(0);
  return (
    <section className="section" id="faq">
      <div className="container" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 64 }}>
        <div>
          <SectionLabel icon="doc">FAQ</SectionLabel>
          <h2 style={{ marginTop: 12 }}>{MM.t(lang, "faq_title")}</h2>
          <p className="lead" style={{ marginTop: 14 }}>
            {lang === "en" ? "Can't find your answer?" : "Não achou sua resposta?"} <a href="#" style={{ color: "var(--accent)", textDecoration: "underline", textUnderlineOffset: 3 }}>{lang === "en" ? "Email us." : "Chama no e-mail."}</a>
          </p>
        </div>
        <div>
          {items.map(([q, a], i) => (
            <div key={i} style={{ borderTop: i === 0 ? "1px solid var(--border-strong)" : "1px solid var(--border)", borderBottom: i === items.length - 1 ? "1px solid var(--border-strong)" : "none" }}>
              <button onClick={() => setOpen(open === i ? -1 : i)} style={{ width: "100%", padding: "20px 0", display: "flex", justifyContent: "space-between", alignItems: "center", textAlign: "left", fontSize: 16, fontWeight: 500 }}>
                {q}
                <span style={{ color: "var(--text-subtle)", transform: open === i ? "rotate(180deg)" : "none", transition: "transform 200ms" }}>
                  <Icon name="chevron-down" size={16}/>
                </span>
              </button>
              {open === i && (
                <div className="muted" style={{ paddingBottom: 20, fontSize: 15, lineHeight: 1.6, maxWidth: 580 }}>{a}</div>
              )}
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

function CTASection({ lang }) {
  return (
    <section className="section">
      <div className="container">
        <div className="card" style={{ padding: 64, textAlign: "center", background: "var(--text)", color: "var(--bg)", borderColor: "transparent", position: "relative", overflow: "hidden" }}>
          <h2 style={{ marginBottom: 14 }}>{MM.t(lang, "cta_title")}</h2>
          <p style={{ fontSize: 17, maxWidth: 520, margin: "0 auto 28px", color: "color-mix(in oklab, var(--bg) 70%, transparent)" }}>{MM.t(lang, "cta_sub")}</p>
          <a href="app.html" className="btn btn-lg" style={{ background: "var(--bg)", color: "var(--text)" }}>
            {MM.t(lang, "hero_cta")} <Icon name="arrow-right" size={14}/>
          </a>
        </div>
      </div>
    </section>
  );
}

window.LandingSections = { Hero, LogosStrip, Features, HowItWorks, Pricing, FAQ, CTASection };
