// Legal pages: Terms, Privacy, Refund

function LegalPage({ which, setPage }) {
  const docs = {
    terms: {
      title: "Terms of Service",
      eyebrow: "TERMS — EFFECTIVE 19 MAY 2026",
      sections: TERMS_BODY,
    },
    privacy: {
      title: "Privacy Policy",
      eyebrow: "PRIVACY — EFFECTIVE 19 MAY 2026",
      sections: PRIVACY_BODY,
    },
    refund: {
      title: "Refund Policy",
      eyebrow: "REFUNDS — EFFECTIVE 19 MAY 2026",
      sections: REFUND_BODY,
    },
  };
  const doc = docs[which];

  return (
    <div className="page-enter page-in">
      <section className="container" style={{ paddingTop: 60, paddingBottom: 60 }}>
        <div className="eyebrow-rule">{doc.eyebrow}</div>
        <h1 className="h-section" style={{ margin: "20px 0 0" }}>{doc.title}</h1>
        <div style={{ display: "flex", gap: 6, marginTop: 30 }}>
          {[
            { id: "terms",   label: "Terms" },
            { id: "privacy", label: "Privacy" },
            { id: "refund",  label: "Refund" },
          ].map(t => (
            <button key={t.id} onClick={() => setPage(t.id)} style={{
              padding: "8px 16px", borderRadius: 999, fontSize: 13,
              background: which === t.id ? "var(--text)" : "transparent",
              color: which === t.id ? "var(--bg)" : "var(--text-2)",
              border: "1px solid", borderColor: which === t.id ? "var(--text)" : "var(--border)",
            }}>{t.label}</button>
          ))}
        </div>
      </section>

      <section className="container" style={{ paddingTop: 0, paddingBottom: 100 }}>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 2.4fr", gap: 60 }} data-mobile="stack">
          {/* TOC */}
          <aside style={{ position: "sticky", top: 120, alignSelf: "start" }}>
            <div className="eyebrow" style={{ marginBottom: 14 }}>CONTENTS</div>
            <ol style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10, fontSize: 13.5 }}>
              {doc.sections.map((s, i) => (
                <li key={i}>
                  <a href={`#sec-${i + 1}`} style={{ color: "var(--text-2)" }}>
                    <span style={{ fontFamily: "var(--mono)", color: "var(--text-3)", marginRight: 10 }}>{String(i + 1).padStart(2, "0")}</span>{s.h}
                  </a>
                </li>
              ))}
            </ol>
            <div style={{ marginTop: 32, padding: 18, background: "var(--bg-soft)", border: "1px solid var(--border)", borderRadius: 8, fontSize: 12.5, color: "var(--text-2)", lineHeight: 1.55 }}>
              Questions? Email <span style={{ color: "var(--accent)" }}>legal@forbestoffer.co</span>. We answer within 48 hours.
            </div>
          </aside>

          {/* BODY */}
          <article style={{ maxWidth: 720, fontSize: 15.5, lineHeight: 1.7, color: "var(--text-2)" }}>
            <p style={{ marginTop: 0, color: "var(--text-2)", fontSize: 15, lineHeight: 1.65 }}>
              {doc.sections[0].p[0]}
            </p>
            {doc.sections.map((s, i) => (
              <section key={i} id={`sec-${i + 1}`} style={{ marginTop: 48 }}>
                <h2 className="serif-italic" style={{ fontSize: 30, color: "var(--text)", letterSpacing: "-0.02em", margin: "0 0 18px" }}>
                  <span style={{ fontFamily: "var(--mono)", fontStyle: "normal", fontSize: 16, color: "var(--accent)", marginRight: 14, verticalAlign: 3 }}>§ {i + 1}</span>{s.h}
                </h2>
                {s.p.map((para, j) => <p key={j}>{para}</p>)}
              </section>
            ))}
            <div style={{ marginTop: 80, padding: 24, background: "var(--bg-soft)", border: "1px solid var(--border)", borderRadius: 8, fontSize: 13, color: "var(--text-3)", fontFamily: "var(--mono)", letterSpacing: "0.04em" }}>
              FOR BEST OFFER LTD · COMPANY NO. 14782301 · REGISTERED 71-75 SHELTON STREET, COVENT GARDEN, LONDON · ICO REGISTRATION ZA987654
            </div>
          </article>
        </div>
      </section>
    </div>
  );
}

const TERMS_BODY = [
  { h: "Who we are and what these terms cover", p: [
    "These Terms of Service govern your access to and use of forbestoffer.co (the 'Site'), our digital question banks and our 1:1 coaching services. By creating an account, purchasing a bank or booking a session you agree to these terms in full.",
    "FBO is operated by For Best Offer Ltd, a company registered in England and Wales (company no. 14782301), with registered office at 71-75 Shelton Street, Covent Garden, London WC2H 9JQ.",
  ] },
  { h: "Accounts and eligibility", p: [
    "You must be at least 16 years old to create an account. You agree to provide accurate information and to keep your account credentials secure. You are responsible for everything that happens under your account.",
    "We reserve the right to suspend or terminate any account that is sharing credentials, redistributing materials or otherwise breaching these terms.",
  ] },
  { h: "Licence to use the question banks", p: [
    "Each purchased question bank gives you a personal, non-transferable, non-exclusive licence to access the material for your own interview preparation. Lifetime access means access for as long as the account exists and FBO is operating.",
    "You may not redistribute, resell, screenshot at scale, post on social media, share with classmates, upload to study-resource websites or otherwise reproduce the materials in any form. Doing so terminates your licence immediately and we may pursue legal remedy for damages.",
  ] },
  { h: "Coaching sessions", p: [
    "Coaching sessions are conducted by independent practitioners contracted by FBO. We verify employment history and references, but the views and feedback delivered in a session are the coach's own and do not represent FBO.",
    "Sessions are recorded for your replay and for our quality assurance. Recordings are retained for 90 days and deleted thereafter.",
  ] },
  { h: "Payments, taxes and refunds", p: [
    "All prices are listed in GBP with conversion-rate references for USD, EUR and HKD shown for guidance only — you are charged in GBP. Taxes are calculated at checkout based on your billing country.",
    "Our refund policy is set out separately in the Refund Policy and forms part of these terms.",
  ] },
  { h: "Acceptable use and content sourcing", p: [
    "Our question banks are written up from candidate contributions of structure, themes and recalled question types. We do not host, distribute or reproduce proprietary test files, employer documents or copyrighted assessment material. If you believe a specific item infringes — please email legal@forbestoffer.co and we'll act within 24 hours.",
  ] },
  { h: "Limitation of liability", p: [
    "FBO provides interview preparation material and coaching. We make no guarantee of any specific interview outcome, job offer or salary outcome. Our maximum aggregate liability for any claim arising from your use of the Service is limited to the total amount you paid us in the preceding twelve months.",
  ] },
  { h: "Governing law", p: [
    "These terms are governed by the laws of England and Wales. Any dispute is subject to the exclusive jurisdiction of the courts of London.",
  ] },
];

const PRIVACY_BODY = [
  { h: "What this notice covers", p: [
    "This Privacy Policy explains what personal data we collect, why we collect it and how we keep it. We are the data controller for the information collected through forbestoffer.co. FBO is registered with the UK Information Commissioner's Office under registration ZA987654.",
  ] },
  { h: "What we collect", p: [
    "Account data: name, email address, university, country of residence. Transaction data: order history, billing country, payment-processor reference (we never store your card number — Stripe holds it). Service data: which banks you've downloaded, coaching session bookings, recorded mock sessions for 90 days, support correspondence.",
    "Usage data: pages viewed, referral source, anonymised device and browser information through privacy-respecting analytics (Plausible). We do not use Google Analytics and we do not run cross-site advertising trackers.",
  ] },
  { h: "Why we use your data", p: [
    "To deliver the question banks and coaching sessions you've bought. To match you with a coach who's worked at your target firm. To send transactional emails (purchase confirmations, refresh notifications, coach assignments). To improve the product and respond to support requests.",
  ] },
  { h: "Who we share it with", p: [
    "Payment processing: Stripe (in the EU) and WeChat Pay / Alipay where applicable. Email delivery: Postmark. Recording storage: AWS S3 (London region) with at-rest encryption. Coaching matches: only first name, target firm and target role are shared with the matched coach — never your full email or other identifying details.",
    "We never sell or rent your data to anyone, for any purpose.",
  ] },
  { h: "How long we keep it", p: [
    "Account data: for as long as your account exists, plus one year for tax records. Coaching session recordings: 90 days then deleted. Transaction records: seven years (UK tax law). Support tickets: two years.",
  ] },
  { h: "Your rights", p: [
    "Under UK GDPR you have the right to access, correct, port or delete your personal data. You can also object to processing or restrict how we use your data. Email privacy@forbestoffer.co and we'll action your request within 30 days.",
  ] },
  { h: "Cookies", p: [
    "We use a single first-party cookie to keep you signed in. We use no advertising, no remarketing, no tracking cookies. The privacy-respecting analytics we use (Plausible) is cookieless.",
  ] },
  { h: "Contact and complaints", p: [
    "Email privacy@forbestoffer.co. You also have the right to lodge a complaint with the UK Information Commissioner's Office at ico.org.uk.",
  ] },
];

const REFUND_BODY = [
  { h: "Question banks", p: [
    "We refund any question bank within 48 hours of purchase, in full, no questions asked — provided you haven't downloaded the materials. Once a bank is downloaded we cannot refund it; the product has been delivered.",
    "If you believe a bank you've downloaded was materially inaccurate or no longer current, email refund@forbestoffer.co with your order reference and a brief explanation. We review case-by-case and credit your account where appropriate.",
  ] },
  { h: "Coaching sessions", p: [
    "Coaching sessions can be cancelled and fully refunded up to 24 hours before the scheduled slot. Inside 24 hours, sessions are non-refundable unless we fail to deliver — e.g. coach cancellation, technical failure on our end.",
    "If your coach match isn't right inside the first ten minutes of the session, end the call. We refund in full and re-match at no extra charge.",
  ] },
  { h: "Bundle and pre-AC sprint refunds", p: [
    "For bundles and the Pre-AC Sprint, sessions already delivered are deducted at their à-la-carte price; the remainder is refunded. Bundle discounts only apply if all bundled items are kept — partial refunds revert to standard pricing.",
  ] },
  { h: "How to request a refund", p: [
    "Email refund@forbestoffer.co with your order reference (FBO-####-YYYY) and a brief reason. We reply within 24 hours. Approved refunds are processed back to your original payment method and typically appear within 5-10 business days, depending on your card issuer.",
  ] },
  { h: "Chargebacks", p: [
    "If you raise a chargeback through your bank for an order we believe was delivered as described, we may suspend your account pending resolution. We always prefer to settle directly — please email us first.",
  ] },
];

Object.assign(window, { LegalPage });
