/* global React, window */
/* ============================================
   Legal pages — Terms of Service, Privacy Policy,
   Refund Policy. Shared readable long-form layout.
   ============================================ */

function LegalSection({ n, title, children }) {
  return (
    <section style={{ marginBottom: 36 }}>
      <div className="flex gap-3" style={{ alignItems: 'baseline', marginBottom: 12 }}>
        <span className="font-mono" style={{ fontSize: 13, color: 'var(--cyan)', fontWeight: 600 }}>{n}</span>
        <h2 style={{ fontSize: 22, lineHeight: 1.2 }}>{title}</h2>
      </div>
      <div className="text-muted legal-body" style={{ fontSize: 15.5, lineHeight: 1.75 }}>
        {children}
      </div>
    </section>
  );
}

function LegalHero({ eyebrow, title, accent, intro }) {
  return (
    <section style={{ padding: '64px 0 24px' }}>
      <div className="container" style={{ maxWidth: 880 }}>
        <span className="eyebrow">{eyebrow}</span>
        <h1 className="mt-4" style={{ fontSize: 52, lineHeight: 1.04 }}>
          {title} <span className="gradient-text">{accent}</span>
        </h1>
        <p className="mt-6 text-muted" style={{ fontSize: 17, lineHeight: 1.6 }}>{intro}</p>
        <div className="font-mono text-xs text-muted mt-6">LAST UPDATED · JUNE 2026</div>
      </div>
    </section>
  );
}

function LegalContact({ go }) {
  return (
    <div className="panel panel-padded mt-2" style={{ background: 'rgba(0,0,0,0.3)' }}>
      <p className="text-muted" style={{ fontSize: 14.5, lineHeight: 1.7 }}>
        Questions? Contact us at{' '}
        <a href="mailto:admin@expertforforex.com" style={{ color: 'var(--cyan)' }}>admin@expertforforex.com</a>{' '}
        or visit the{' '}
        <a onClick={() => go('about')} style={{ color: 'var(--cyan)', cursor: 'pointer' }}>contact page</a>.
      </p>
    </div>
  );
}

/* ─────────────────── TERMS OF SERVICE ─────────────────── */
function TermsPage({ go }) {
  return (
    <div>
      <LegalHero
        eyebrow="LEGAL · TERMS OF SERVICE"
        title="Terms of" accent="service"
        intro="These terms govern your access to and use of the Expert For Forex website, products, and services. By using the site or purchasing any product, you agree to these terms."
      />
      <section className="section" style={{ paddingTop: 32 }}>
        <div className="container" style={{ maxWidth: 880 }}>

          <LegalSection n="01" title="Acceptance of terms">
            <p>
              By accessing Expert For Forex, creating an account, or purchasing any expert advisor, tool, or service,
              you confirm that you are at least 18 years old, legally able to enter into a binding contract, and that
              you accept these Terms of Service in full. If you do not agree, please do not use the site.
            </p>
          </LegalSection>

          <LegalSection n="02" title="What we provide">
            <p>
              We sell automated trading software (expert advisors), related tools, and educational content. We are a
              software vendor — we are not a broker, a financial adviser, or a fund manager, and we do not manage money
              or place trades on your behalf. All products are provided on an “as is” basis.
            </p>
          </LegalSection>

          <LegalSection n="03" title="Licenses and usage">
            <p>
              When you purchase an expert advisor you receive a personal, non-exclusive, non-transferable license to use
              it on the number of accounts specified at purchase. You may not resell, redistribute, share, decompile,
              reverse-engineer, or publish any product or license key. We may revoke a license that is used in breach of
              these terms without refund.
            </p>
          </LegalSection>

          <LegalSection n="04" title="Accounts and security">
            <p>
              You are responsible for keeping your account credentials and license keys confidential, and for all
              activity that occurs under your account. Notify us immediately if you suspect unauthorised use. We are not
              liable for losses caused by your failure to safeguard your credentials.
            </p>
          </LegalSection>

          <LegalSection n="05" title="No guarantee — trading risk">
            <p>
              Nothing on this site is a promise of profit. Trading forex and CFDs with leverage carries a high level of
              risk, and you may lose some or all of your capital. Past and simulated performance is not indicative of
              future results. Please read our{' '}
              <a onClick={() => go('risk')} style={{ color: 'var(--cyan)', cursor: 'pointer' }}>Risk Disclosure</a>{' '}
              in full. You trade entirely at your own risk.
            </p>
          </LegalSection>

          <LegalSection n="06" title="Third-party services">
            <p>
              Brokers, VPS providers, and payment processors referenced on the site are independent third parties with
              their own terms. We are not responsible for their actions, availability, or solvency. Links to third
              parties may earn us a partner commission at no extra cost to you.
            </p>
          </LegalSection>

          <LegalSection n="07" title="Limitation of liability">
            <p>
              To the maximum extent permitted by law, Expert For Forex and its team shall not be liable for any
              trading losses, lost profits, or any indirect, incidental, or consequential damages arising from your use
              of the site, our products, or any third-party service. Our total liability for any claim shall not exceed
              the amount you paid us for the product giving rise to the claim.
            </p>
          </LegalSection>

          <LegalSection n="08" title="Changes to these terms">
            <p>
              We may update these terms from time to time. The latest version will always be posted on this page with an
              updated date. Continued use of the site after changes are posted constitutes acceptance of the revised
              terms.
            </p>
          </LegalSection>

          <LegalContact go={go} />
        </div>
      </section>
    </div>
  );
}

/* ─────────────────── PRIVACY POLICY ─────────────────── */
function PrivacyPage({ go }) {
  return (
    <div>
      <LegalHero
        eyebrow="LEGAL · PRIVACY POLICY"
        title="Privacy" accent="policy"
        intro="This policy explains what personal data we collect, how we use it, and the choices you have. We aim to collect only what we need to run the service."
      />
      <section className="section" style={{ paddingTop: 32 }}>
        <div className="container" style={{ maxWidth: 880 }}>

          <LegalSection n="01" title="Information we collect">
            <p>
              We collect the information you give us directly — such as your name, email address, and the details needed
              to deliver a purchase and license. When you pay, our payment processors handle your card or crypto details
              directly; we never see or store full card numbers. We also collect basic technical data (such as device,
              browser, and usage events) to operate and improve the site.
            </p>
          </LegalSection>

          <LegalSection n="02" title="How we use your data">
            <p>
              We use your data to: create and manage your account; deliver products, license keys, and downloads; provide
              customer support; send essential transactional emails; prevent fraud and abuse; and comply with our legal
              obligations. We do not sell your personal data.
            </p>
          </LegalSection>

          <LegalSection n="03" title="Service providers">
            <p>
              We rely on trusted third-party providers to run the service — for example hosting, database, email
              delivery, and payment processing. These providers only receive the data necessary to perform their function
              and are bound to protect it. We are not responsible for the independent privacy practices of brokers or VPS
              providers you choose to sign up with.
            </p>
          </LegalSection>

          <LegalSection n="04" title="Cookies and local storage">
            <p>
              We use cookies and browser local storage to keep you signed in, remember your preferences, and understand
              how the site is used. You can clear or block these through your browser settings, though some features may
              not work correctly without them.
            </p>
          </LegalSection>

          <LegalSection n="05" title="Data retention">
            <p>
              We keep your personal data for as long as your account is active or as needed to provide the service, meet
              legal and accounting requirements, resolve disputes, and enforce our agreements. You may request deletion
              of your account at any time.
            </p>
          </LegalSection>

          <LegalSection n="06" title="Your rights">
            <p>
              Depending on where you live, you may have the right to access, correct, export, or delete your personal
              data, and to object to or restrict certain processing. To exercise any of these rights, contact us at the
              email below and we will respond within a reasonable time.
            </p>
          </LegalSection>

          <LegalSection n="07" title="Security">
            <p>
              We use industry-standard measures — including encryption in transit, access controls, and secure
              infrastructure — to protect your data. No method of transmission or storage is completely secure, however,
              and we cannot guarantee absolute security.
            </p>
          </LegalSection>

          <LegalContact go={go} />
        </div>
      </section>
    </div>
  );
}

/* ─────────────────── REFUND POLICY ─────────────────── */
function RefundPage({ go }) {
  return (
    <div>
      <LegalHero
        eyebrow="LEGAL · REFUND POLICY"
        title="Refund" accent="policy"
        intro="Because our products are digital software delivered instantly, please read this policy carefully before purchasing."
      />
      <section style={{ paddingBottom: 8 }}>
        <div className="container" style={{ maxWidth: 880 }}>
          <div className="panel panel-padded" style={{ background: 'rgba(255,184,0,0.06)', borderColor: 'rgba(255,184,0,0.35)' }}>
            <div className="flex gap-3" style={{ alignItems: 'flex-start' }}>
              <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="var(--amber)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0, marginTop: 2 }}><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
              <p style={{ fontSize: 15.5, lineHeight: 1.65, color: 'var(--text)' }}>
                Digital products and license keys are delivered immediately and grant instant access to the software. For
                this reason, all sales are generally <strong>final and non-refundable</strong>, except where required by
                law or as described below.
              </p>
            </div>
          </div>
        </div>
      </section>
      <section className="section" style={{ paddingTop: 32 }}>
        <div className="container" style={{ maxWidth: 880 }}>

          <LegalSection n="01" title="Digital nature of products">
            <p>
              Expert advisors and tools are downloadable digital goods. Once a license key has been issued and the
              software has been downloaded or activated, the product is considered delivered and used, and is not
              eligible for a refund.
            </p>
          </LegalSection>

          <LegalSection n="02" title="When we may issue a refund">
            <p>
              We will consider a refund if: the product is technically faulty and we are unable to fix the issue within a
              reasonable time; you were charged in error or charged twice; or the product was never delivered. Requests
              must be made within <strong>7 days</strong> of purchase with a clear description of the problem.
            </p>
          </LegalSection>

          <LegalSection n="03" title="What is not covered">
            <p>
              Refunds are not provided for: trading losses or unsatisfactory trading results; a change of mind after
              download or activation; failure to configure the software, VPS, or broker correctly; or incompatibility you
              could have verified from the product page before buying. Performance is never guaranteed — see our{' '}
              <a onClick={() => go('risk')} style={{ color: 'var(--cyan)', cursor: 'pointer' }}>Risk Disclosure</a>.
            </p>
          </LegalSection>

          <LegalSection n="04" title="How to request a refund">
            <p>
              Email <a href="mailto:admin@expertforforex.com" style={{ color: 'var(--cyan)' }}>admin@expertforforex.com</a>{' '}
              with your order number, the email used at purchase, and a description of the issue. We aim to review every
              request within a few business days and will let you know the outcome by email.
            </p>
          </LegalSection>

          <LegalSection n="05" title="Approved refunds">
            <p>
              Approved refunds are returned to your original payment method where possible. Processing times depend on
              your payment provider. Once a refund is issued, the associated license key is deactivated and the product
              may no longer be used.
            </p>
          </LegalSection>

          <LegalContact go={go} />
        </div>
      </section>
    </div>
  );
}

window.TermsPage = TermsPage;
window.PrivacyPage = PrivacyPage;
window.RefundPage = RefundPage;
