// Pricing.jsx — Partnership section + Testimonial Slider + CTA

function Testimonial() {
  const { Container, Eyebrow, Icon } = window;

  const testimonials = [
    { quote: "Working with Zentro over the past couple of years has been one of the best investments I've made for my business. Together we have developed a system that makes reviewing and approving content incredibly easy. Their designs are always on brand, and they consistently bring fresh ideas to help improve engagement and keep up with the ever-changing algorithm. Beyond their creativity, they're positive, responsive, and so easy to communicate with. They've taken a huge task off my plate and given me the confidence of knowing my business has a consistent, professional presence on Instagram. That has allowed me to spend more time focusing on my clients and my family. I'm so grateful I found Zentro and highly recommend them to anyone looking for a talented, reliable social media partner.", name: "Laura Bostrom", role: "Founder, Everyday Order", photo: "uploads/testimonials/Laura.jpg" },
    { quote: "The quality of editing from Zentro is unmatched. Our brand finally looks as professional as our product. Highly recommend to any serious business.", name: "Kat Mua", role: "K&I Perfumes", photo: "uploads/testimonials/kat.jpg" },
    { quote: "Zentro helped bring our creative vision to life in a way that genuinely connected with our audience. Every edit felt intentional, every detail was handled with care, and the entire process was seamless. Having a team we could trust with our visuals allowed us to focus on making music.", name: "Jordan Mota", role: "We Just Changed", photo: "uploads/testimonials/WeJustChanged.jpg" },
  ];

  const total = testimonials.length;
  const [index, setIndex] = React.useState(0);
  const [locked, setLocked] = React.useState(false);
  const trackRef = React.useRef(null);

  const getIdx = (i) => ((i % total) + total) % total;

  const go = (dir) => {
    if (locked) return;
    setLocked(true);
    const track = trackRef.current;
    if (!track) return;
    track.style.transition = "transform 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94)";
    track.style.transform = `translateX(calc(-${(index + dir + 1)} * (31% + 12px)))`;
    setTimeout(() => {
      const next = getIdx(index + dir);
      setIndex(next);
      track.style.transition = "none";
      track.style.transform = `translateX(calc(-${(next + 1)} * (31% + 12px)))`;
      setLocked(false);
    }, 430);
  };

  const extended = [];
  for (let i = 0; i < total * 3; i++) { extended.push(testimonials[i % total]); }

  React.useEffect(() => {
    const track = trackRef.current;
    if (!track) return;
    track.style.transition = "none";
    track.style.transform = `translateX(calc(-${(index + 1)} * (31% + 12px)))`;
  }, [index]);

  const Avatar = ({ t }) => (
    t.photo
      ? <img src={t.photo} alt={t.name} style={{ width: 40, height: 40, borderRadius: "50%", objectFit: "cover", flexShrink: 0, border: "2px solid rgba(251,208,40,0.3)" }} />
      : <div style={{ width: 40, height: 40, borderRadius: "50%", background: "rgba(251,208,40,0.12)", border: "2px solid rgba(251,208,40,0.3)", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 15, color: "var(--gold-400)" }}>
          {t.name.charAt(0)}
        </div>
  );

  const navBtn = (handler) => ({
    onClick: handler,
    style: { width: 44, height: 44, borderRadius: "50%", border: "1px solid var(--border-default)", background: "var(--surface-card)", color: "var(--text-primary)", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, transition: "all 0.15s" },
    onMouseEnter: (e) => { e.currentTarget.style.borderColor = "var(--gold-500)"; e.currentTarget.style.color = "var(--gold-500)"; },
    onMouseLeave: (e) => { e.currentTarget.style.borderColor = "var(--border-default)"; e.currentTarget.style.color = "var(--text-primary)"; },
  });

  return (
    <section style={{ padding: "100px 0", borderTop: "1px solid var(--border-subtle)" }}>
      <Container>
        <div style={{ textAlign: "center", marginBottom: 48 }}>
          <Eyebrow>What clients say</Eyebrow>
          <h2 style={{ marginTop: 20, fontFamily: "var(--font-display)", fontWeight: 900, fontSize: "clamp(2.25rem, 4.5vw, 3.5rem)", lineHeight: 1.02, letterSpacing: "-0.03em", color: "var(--text-primary)" }}>
            Results That Speak<br /><span style={{ color: "var(--gold-500)", fontStyle: "italic" }}>For Themselves.</span>
          </h2>
        </div>

        <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
          <button {...navBtn(() => go(-1))}><Icon name="ChevronLeft" size={18} /></button>
          <div style={{ flex: 1, overflow: "hidden" }}>
            <div ref={trackRef} style={{ display: "flex", gap: 12, willChange: "transform", transform: `translateX(calc(-${(index + 1)} * (31% + 12px)))` }}>
              {extended.map((t, i) => {
                const pos = i - (index + 1);
                const isActive = pos === 1;
                const isPeek = pos === -1 || pos === 3;
                return (
                  <div key={i} style={{
                    flexShrink: 0, width: "31%", height: 260, overflow: "hidden",
                    background: "var(--surface-card)",
                    border: `1px solid ${isActive ? "rgba(251,208,40,0.45)" : "var(--border-subtle)"}`,
                    borderRadius: "var(--radius-lg)", padding: "26px 22px",
                    opacity: isPeek ? 0.2 : (pos === 0 || pos === 2) ? 0.65 : isActive ? 1 : 0.05,
                    transform: `scale(${isActive ? 1 : isPeek ? 0.9 : 0.95})`,
                    transition: "opacity 0.42s ease, transform 0.42s ease, border-color 0.42s ease",
                    boxShadow: isActive ? "0 0 32px rgba(251,208,40,0.1)" : "none",
                    cursor: isPeek ? "pointer" : "default", boxSizing: "border-box",
                  }} onClick={() => { if (pos === -1) go(-1); if (pos === 3) go(1); }}>
                    <div style={{ display: "flex", gap: 3, marginBottom: 12 }}>
                      {[...Array(5)].map((_, s) => <svg key={s} width="14" height="14" viewBox="0 0 24 24" fill="var(--gold-500)"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>)}
                    </div>
                    <p style={{ fontFamily: "var(--font-sans)", fontSize: 15, lineHeight: 1.6, color: "var(--text-secondary)", margin: "0 0 18px", overflow: "hidden", display: "-webkit-box", WebkitLineClamp: 5, WebkitBoxOrient: "vertical" }}>"{t.quote}"</p>
                    <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
                      <Avatar t={t} />
                      <div>
                        <div style={{ fontFamily: "var(--font-sans)", fontWeight: 700, fontSize: 15, color: "var(--text-primary)" }}>{t.name}</div>
                        <div style={{ fontFamily: "var(--font-sans)", fontSize: 13, color: "var(--text-tertiary)" }}>{t.role}</div>
                      </div>
                    </div>
                  </div>
                );
              })}
            </div>
          </div>
          <button {...navBtn(() => go(1))}><Icon name="ChevronRight" size={18} /></button>
        </div>

        <div style={{ display: "flex", justifyContent: "center", gap: 8, marginTop: 28 }}>
          {testimonials.map((_, i) => (
            <div key={i} onClick={() => { if (!locked) setIndex(i); }}
              style={{ width: i === index ? 24 : 8, height: 8, borderRadius: 99, background: i === index ? "var(--gold-500)" : "var(--border-default)", cursor: "pointer", transition: "all 0.3s ease" }} />
          ))}
        </div>
      </Container>
    </section>
  );
}

function Pricing({ onStart }) {
  const { Container, Eyebrow, Icon } = window;
  const { Button } = window.ZentroDesignSystem_967cea;

  const included = [
    { icon: "User",       title: "One Dedicated Editor",      body: "You're not working with a pool of editors. One person learns your brand, your style, and your preferences — and stays with you." },
    { icon: "Users",      title: "Creative Team Behind Them", body: "Your editor is backed by a full creative team for quality control, production support, and workflow continuity every month." },
    { icon: "RefreshCw",  title: "Revisions Included",        body: "Minor revisions are included. Adjustments, tweaks, small changes — handled without extra charges or extra briefing." },
    { icon: "Zap",        title: "Reliable Delivery",         body: "Short-form content delivered in 1–2 business days. Your workflow runs on a schedule you can actually build around." },
    { icon: "Globe",      title: "Every Platform Covered",    body: "Every video is delivered formatted and optimized for the platforms you post on — without you having to ask." },
    { icon: "FileText",   title: "Content Scripts Included",  body: "New clients receive 5 custom content scripts tailored to their brand during their first month — no extra brief needed." },
  ];

  const traditional = [
    "Multiple freelancers, different every time",
    "Re-briefing from scratch on every project",
    "Inconsistent editing style",
    "Unpredictable delivery timelines",
    "You manage the workflow",
    "Editing backs up when you're busy",
  ];

  const zentro = [
    "One dedicated editor who knows your brand",
    "No re-briefing — your editor already knows",
    "Consistent editing style, every time",
    "Reliable delivery you can schedule around",
    "We manage the workflow for you",
    "Content keeps moving, month after month",
  ];

  return (
    <>
      {/* ── Partnership — What's Included ── */}
      <section id="pricing" style={{ padding: "100px 0", borderTop: "1px solid var(--border-subtle)", scrollMarginTop: 80 }}>
        <Container>
          <div style={{ textAlign: "center", maxWidth: 700, margin: "0 auto" }}>
            <div style={{ display: "flex", justifyContent: "center" }}><Eyebrow>The partnership</Eyebrow></div>
            <h2 style={{ marginTop: 20, fontFamily: "var(--font-display)", fontWeight: 900, fontSize: "clamp(2.25rem, 4.5vw, 3.5rem)", lineHeight: 1.02, letterSpacing: "-0.03em", color: "var(--text-primary)" }}>
              Not a Service. A Workflow.
            </h2>
            <p style={{ marginTop: 16, fontFamily: "var(--font-sans)", fontSize: 17, lineHeight: 1.7, color: "var(--text-secondary)" }}>
              Zentro isn't a place you send videos to get edited. It's an ongoing editing operation built around your brand — so you never have to think about editing again.
            </p>
          </div>
          <div style={{ marginTop: 56, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 18 }} className="z-services-grid">
            {included.map((it) => (
              <div key={it.title} style={{ padding: 28, borderRadius: "var(--radius-lg)", background: "var(--surface-card)", border: "1px solid var(--border-subtle)" }}>
                <span style={{ width: 48, height: 48, borderRadius: "var(--radius-md)", background: "rgba(251,208,40,0.12)", border: "1px solid rgba(251,208,40,0.3)", display: "flex", alignItems: "center", justifyContent: "center" }}>
                  <Icon name={it.icon} size={22} color="var(--gold-400)" />
                </span>
                <h3 style={{ marginTop: 20, fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 20, letterSpacing: "-0.02em", color: "var(--text-primary)" }}>{it.title}</h3>
                <p style={{ marginTop: 10, fontFamily: "var(--font-sans)", fontSize: 14, lineHeight: 1.6, color: "var(--text-secondary)" }}>{it.body}</p>
              </div>
            ))}
          </div>

          {/* CTA removed — floating bonus widget used instead */}
        </Container>
      </section>

      {/* ── Brand Philosophy ── */}
      <section style={{ padding: "80px 0", borderTop: "1px solid var(--border-subtle)" }}>
        <Container max={820}>
          <div style={{ textAlign: "center", padding: "52px 40px", background: "linear-gradient(135deg, rgba(251,208,40,0.08), rgba(251,208,40,0.02))", border: "1px solid rgba(251,208,40,0.2)", borderRadius: "var(--radius-lg)" }}>
            <Eyebrow>Our philosophy</Eyebrow>
            <h3 style={{ marginTop: 20, fontFamily: "var(--font-display)", fontWeight: 900, fontSize: "clamp(1.75rem, 3vw, 2.5rem)", letterSpacing: "-0.03em", color: "var(--text-primary)", lineHeight: 1.15 }}>
              Consistency Builds Brands.
            </h3>
            <p style={{ marginTop: 18, maxWidth: 580, margin: "18px auto 0", fontFamily: "var(--font-sans)", fontSize: 16, lineHeight: 1.8, color: "var(--text-secondary)" }}>
              Editing should never be the reason a business stops creating content. Most businesses don't have a content problem — they have an editing bottleneck. Zentro exists to remove that bottleneck permanently, so the content keeps moving no matter what.
            </p>
          </div>
        </Container>
      </section>

      {/* New Client Bonus moved to floating widget */}

      {/* ── Comparison: Traditional vs Zentro ── */}
      <section style={{ padding: "80px 0", borderTop: "1px solid var(--border-subtle)" }}>
        <Container>
          <div style={{ textAlign: "center", marginBottom: 48 }}>
            <Eyebrow>Two ways to edit</Eyebrow>
            <h2 style={{ marginTop: 20, fontFamily: "var(--font-display)", fontWeight: 900, fontSize: "clamp(2rem, 4vw, 3rem)", letterSpacing: "-0.03em", color: "var(--text-primary)" }}>
              The Traditional Workflow<br /><span style={{ color: "var(--gold-500)", fontStyle: "italic" }}>vs The Zentro Workflow</span>
            </h2>
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 18, maxWidth: 900, margin: "0 auto" }} className="z-pricing-grid">
            <div style={{ padding: 32, borderRadius: "var(--radius-lg)", background: "var(--surface-card)", border: "1px solid var(--border-subtle)" }}>
              <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 20, color: "var(--text-secondary)", marginBottom: 24 }}>Traditional Editing Workflow</h3>
              <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 14 }}>
                {traditional.map((f) => (
                  <li key={f} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontFamily: "var(--font-sans)", fontSize: 14, color: "var(--text-tertiary)", lineHeight: 1.5 }}>
                    <Icon name="X" size={16} color="rgba(255,80,80,0.7)" style={{ marginTop: 2, flexShrink: 0 }} />{f}
                  </li>
                ))}
              </ul>
            </div>
            <div style={{ padding: 32, borderRadius: "var(--radius-lg)", background: "linear-gradient(180deg, rgba(251,208,40,0.1), var(--surface-card))", border: "1px solid rgba(251,208,40,0.4)" }}>
              <h3 style={{ fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 20, color: "var(--gold-400)", marginBottom: 24 }}>The Zentro Workflow</h3>
              <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 14 }}>
                {zentro.map((f) => (
                  <li key={f} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontFamily: "var(--font-sans)", fontSize: 14, color: "var(--text-secondary)", lineHeight: 1.5 }}>
                    <Icon name="Check" size={16} color="var(--gold-400)" style={{ marginTop: 2, flexShrink: 0 }} />{f}
                  </li>
                ))}
              </ul>
            </div>
          </div>
        </Container>
      </section>
    </>
  );
}
window.Testimonial = Testimonial;
window.Pricing = Pricing;
