// pages/legal.jsx — Privacy Policy, Terms & Conditions, Refund Policy
// These pages exist for payment-gateway (Razorpay) verification and reuse
// the existing Navbar / Footer / design tokens. No new styles introduced.

const EFFECTIVE_DATE = "October 1, 2025";
const LAST_UPDATED   = "October 1, 2025";

const LEGAL_BUSINESS_NAME = "CS Tuitions";
const BRAND_NAME          = "Computer-tution";
const CONTACT_EMAIL       = "revathi@computertution.in";
const CONTACT_PHONE       = "+91 98765 43210";
const JURISDICTION        = "Chennai, Tamil Nadu";

// ────────────────────────────────────────────────────────────
// Shared shell for all three legal pages
// ────────────────────────────────────────────────────────────
function LegalShell({ go, eyebrow, title, children }) {
  return (
    <>
      <Navbar go={go} />
      <section style={{ padding: "64px 0 32px", background: "var(--paper)", borderBottom: "1px solid var(--line)" }}>
        <div className="container-narrow">
          <div className="eyebrow">{eyebrow}</div>
          <h1 style={{ fontSize: "clamp(40px, 4.6vw, 60px)", marginTop: 16, marginBottom: 20, lineHeight: 1.05 }}>{title}</h1>
          <div className="row gap-16" style={{ flexWrap: "wrap", fontFamily: "var(--font-mono)", fontSize: 12, color: "var(--ink-3)", letterSpacing: "0.04em", textTransform: "uppercase" }}>
            <span>Effective date · {EFFECTIVE_DATE}</span>
            <span>·</span>
            <span>Last updated · {LAST_UPDATED}</span>
          </div>
        </div>
      </section>

      <section style={{ padding: "64px 0 96px", background: "var(--white)" }}>
        <div className="container-narrow">
          <div style={{ fontSize: 16, color: "var(--ink-2)", lineHeight: 1.7 }}>
            {children}
          </div>

          <div className="card" style={{ marginTop: 56, background: "var(--paper)", borderColor: "var(--line)" }}>
            <div className="eyebrow" style={{ marginBottom: 10 }}>Questions?</div>
            <div style={{ fontSize: 15, color: "var(--ink-2)" }}>
              For any concerns about this policy, write to{" "}
              <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a>{" "}
              or call <a href={`tel:${CONTACT_PHONE.replace(/\s/g, "")}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_PHONE}</a>.
              These policies are governed by the laws of India, with disputes subject to the jurisdiction of courts in {JURISDICTION}.
            </div>
          </div>

          <div className="row gap-12" style={{ marginTop: 32, flexWrap: "wrap" }}>
            <button className="btn btn-secondary btn-sm" onClick={() => go("/privacy")}>Privacy Policy</button>
            <button className="btn btn-secondary btn-sm" onClick={() => go("/terms")}>Terms &amp; Conditions</button>
            <button className="btn btn-secondary btn-sm" onClick={() => go("/refund")}>Refund Policy</button>
          </div>
        </div>
      </section>

      <Footer go={go} />
    </>
  );
}

// ────────────────────────────────────────────────────────────
// Section helpers (only use existing tokens / utilities)
// ────────────────────────────────────────────────────────────
const LegalH2 = ({ children }) => (
  <h2 style={{ fontSize: 26, fontWeight: 700, color: "var(--ink)", marginTop: 48, marginBottom: 16, letterSpacing: "-0.01em", lineHeight: 1.2 }}>
    {children}
  </h2>
);

const LegalH3 = ({ children }) => (
  <h3 style={{ fontSize: 17, fontWeight: 600, color: "var(--ink)", marginTop: 28, marginBottom: 10 }}>
    {children}
  </h3>
);

const LegalP = ({ children }) => (
  <p style={{ marginBottom: 14, color: "var(--ink-2)" }}>{children}</p>
);

const LegalList = ({ children }) => (
  <ul style={{ paddingLeft: 22, margin: "8px 0 18px", color: "var(--ink-2)" }}>{children}</ul>
);

const LegalLI = ({ children }) => (
  <li style={{ marginBottom: 8, lineHeight: 1.65 }}>{children}</li>
);

// ────────────────────────────────────────────────────────────
// Privacy Policy
// ────────────────────────────────────────────────────────────
function PrivacyPage({ go }) {
  return (
    <LegalShell go={go} eyebrow="Legal" title="Privacy Policy">
      <LegalP>
        This Privacy Policy describes how {LEGAL_BUSINESS_NAME} (operating the website and service under the brand name "{BRAND_NAME}", referred to as "we", "us" or "our") collects, uses, stores and protects your personal information when you visit our website, create a student account, or enrol in our online tutoring programmes for ICSE Class 10 Computer Applications and ISC Class 12 Computer Science.
      </LegalP>
      <LegalP>
        By using our service you agree to the practices described in this policy. We are committed to handling your data responsibly and in accordance with applicable Indian data-protection law.
      </LegalP>

      <LegalH2>1. Information we collect</LegalH2>
      <LegalP>When you create an account or enrol in a course, we collect the following information directly from you:</LegalP>
      <LegalList>
        <LegalLI><strong>Full name</strong> — to identify the enrolled student and personalise the account.</LegalLI>
        <LegalLI><strong>Email address</strong> — for login, schedule communication, receipts and customer support.</LegalLI>
        <LegalLI><strong>Phone number</strong> — for class reminders, doubt-channel access, and urgent batch notifications.</LegalLI>
        <LegalLI><strong>Class</strong> — Class 10 or Class 12, to route you to the correct course.</LegalLI>
        <LegalLI><strong>Board</strong> — ICSE or ISC, to route you to the correct syllabus.</LegalLI>
        <LegalLI><strong>Payment transaction details</strong> — Razorpay payment ID, transaction status, amount and date. We do <em>not</em> collect or see your card number, CVV, UPI PIN, bank credentials or any other payment instrument data.</LegalLI>
      </LegalList>

      <LegalH2>2. Why we collect this information</LegalH2>
      <LegalP>Your information is used strictly for the following purposes:</LegalP>
      <LegalList>
        <LegalLI>To create and manage your student account.</LegalLI>
        <LegalLI>To process your enrolment and grant access to the correct batch.</LegalLI>
        <LegalLI>To send class schedule updates, reminders, recordings and reschedule notices.</LegalLI>
        <LegalLI>To provide customer support, answer doubts and respond to your queries.</LegalLI>
        <LegalLI>To issue payment receipts and maintain enrolment records.</LegalLI>
      </LegalList>

      <LegalH2>3. How your data is stored</LegalH2>
      <LegalP>
        All personal information is stored securely on encrypted servers operated by our infrastructure provider. We use industry-standard encryption in transit (HTTPS/TLS) and at rest. Access to student data is restricted to the tutor and authorised support staff on a need-to-know basis.
      </LegalP>
      <LegalP>
        We <strong>never sell</strong> your personal information. We do not share your information with third parties for marketing purposes. Limited sharing occurs only with the service providers listed in Section 6 below, and only as strictly required to deliver the service you signed up for.
      </LegalP>

      <LegalH2>4. Payment data</LegalH2>
      <LegalP>
        All payments are processed by <strong>Razorpay</strong>, a PCI-DSS Level 1 certified payment gateway. Card numbers, expiry dates, CVVs, UPI PINs, net-banking credentials and bank account numbers are entered directly into Razorpay's secure interface and are <strong>never stored on our servers</strong>. We only receive the payment reference ID, transaction status, amount and timestamp returned by Razorpay.
      </LegalP>

      <LegalH2>5. Recordings and course content</LegalH2>
      <LegalP>
        Live classes are recorded and made available exclusively to enrolled students of the relevant batch, typically within 24 hours of each session. Recordings are not made public, not sold, and not shared externally. They are accessible only through the authenticated student dashboard and are tied to your enrolled batch and account.
      </LegalP>

      <LegalH2>6. Third-party services</LegalH2>
      <LegalP>We use the following carefully selected third-party services to deliver the tutoring service. Each is used strictly for the purpose stated:</LegalP>
      <LegalList>
        <LegalLI><strong>Razorpay</strong> — payment processing for all enrolment fees and refunds.</LegalLI>
        <LegalLI><strong>Zoom</strong> — hosting live online classes and (in some cases) generating raw session recordings.</LegalLI>
        <LegalLI><strong>Supabase</strong> — secure encrypted storage of account data, enrolment records and recording metadata.</LegalLI>
      </LegalList>
      <LegalP>
        Each provider operates under its own privacy policy and security certifications. We share the minimum data necessary for each to perform its function (for example, your name and email with Zoom so you can join a scheduled class).
      </LegalP>

      <LegalH2>7. Cookies</LegalH2>
      <LegalP>
        We use only basic, functional cookies. These cookies are limited to session management and keeping you logged in to your student account between visits. We do not use advertising cookies, tracking pixels, or third-party analytics that profile individual users.
      </LegalP>

      <LegalH2>8. Your rights</LegalH2>
      <LegalP>
        As a student or parent of a student using our service, you have the right to:
      </LegalP>
      <LegalList>
        <LegalLI>Request a copy of the personal data we hold about you.</LegalLI>
        <LegalLI>Request correction of any inaccurate personal data.</LegalLI>
        <LegalLI>Request deletion of your account and associated personal data.</LegalLI>
        <LegalLI>Withdraw consent for non-essential communications at any time.</LegalLI>
      </LegalList>
      <LegalP>
        To exercise any of these rights, write to us at <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a>. We will respond to verified requests within a reasonable time frame. Please note that records required to be retained for tax, audit or legal compliance may be preserved even after account deletion, in accordance with applicable Indian law.
      </LegalP>

      <LegalH2>9. Contact</LegalH2>
      <LegalP>
        For any privacy concerns, data requests, or questions about this policy:
      </LegalP>
      <LegalList>
        <LegalLI>Email: <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a></LegalLI>
        <LegalLI>Phone: <a href={`tel:${CONTACT_PHONE.replace(/\s/g, "")}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_PHONE}</a></LegalLI>
      </LegalList>

      <LegalH2>10. Governing law</LegalH2>
      <LegalP>
        This Privacy Policy is governed by and construed in accordance with the laws of India.
      </LegalP>

      <LegalH2>11. Updates to this policy</LegalH2>
      <LegalP>
        We may update this Privacy Policy from time to time. The "Last updated" date at the top of this page indicates when the most recent revision came into effect. Material changes will be communicated to enrolled students by email.
      </LegalP>
    </LegalShell>
  );
}

// ────────────────────────────────────────────────────────────
// Terms & Conditions
// ────────────────────────────────────────────────────────────
function TermsPage({ go }) {
  return (
    <LegalShell go={go} eyebrow="Legal" title="Terms &amp; Conditions">
      <LegalP>
        These Terms and Conditions ("Terms") govern your use of the services offered by {LEGAL_BUSINESS_NAME} under the brand name "{BRAND_NAME}" ("we", "us", "our"). By creating an account, enrolling in a course, attending a class, or otherwise using the service, you agree to be bound by these Terms.
      </LegalP>

      <LegalH2>1. Service description</LegalH2>
      <LegalP>
        {BRAND_NAME} provides online live tutoring for two specific board courses: <strong>ICSE Class 10 Computer Applications</strong> and <strong>ISC Class 12 Computer Science</strong>. The service includes scheduled live Zoom classes, access to recordings of those classes, and a doubt-resolution channel for enrolled students.
      </LegalP>

      <LegalH2>2. Eligibility</LegalH2>
      <LegalP>
        The service is intended for students currently enrolled in <strong>Class 10 under the ICSE board</strong> or <strong>Class 12 under the ISC board</strong> at a recognised school. By enrolling, you confirm that the student for whom the account is created meets this eligibility requirement. We may request reasonable verification of school and board enrolment at any time.
      </LegalP>

      <LegalH2>3. Accounts</LegalH2>
      <LegalP>
        Each enrolment is for a single named student and is limited to <strong>one account per student</strong>. You are responsible for keeping your login credentials (email and password) confidential and for all activity that occurs under your account. If you believe your account has been accessed without authorisation, notify us immediately at {CONTACT_EMAIL}.
      </LegalP>

      <LegalH2>4. Enrolment and access</LegalH2>
      <LegalP>
        Access to a course is granted only after successful payment of the enrolment fee through Razorpay. Once payment is confirmed, your account is activated and you receive access to the corresponding batch.
      </LegalP>
      <LegalP>
        Enrolment is valid for the duration of the batch you have joined, or a period of <strong>six (6) months</strong> from the date of payment, <em>whichever is earlier</em>. After this period, continued access requires renewal.
      </LegalP>

      <LegalH2>5. What enrolment includes</LegalH2>
      <LegalList>
        <LegalLI>Access to live Zoom classes as per the published batch schedule.</LegalLI>
        <LegalLI>Access to recordings of every batch class, made available within 24 hours of each session.</LegalLI>
        <LegalLI>Access to a doubt-resolution session on request, in line with batch policy.</LegalLI>
      </LegalList>

      <LegalH2>6. Prohibited use</LegalH2>
      <LegalP>You agree that you will <strong>not</strong>:</LegalP>
      <LegalList>
        <LegalLI>Share your login credentials with any other person, including classmates, friends, siblings or unrelated students.</LegalLI>
        <LegalLI>Record, screen-capture, redistribute, upload, post or publicly share any class, recording, document, worksheet or other course content, in whole or in part.</LegalLI>
        <LegalLI>Use any course material, recording or document for any commercial purpose, including resale, paid distribution, paid coaching or commercial training.</LegalLI>
      </LegalList>

      <LegalH2>7. Intellectual property</LegalH2>
      <LegalP>
        All recorded lectures, worksheets, slide decks, notes, mock papers, project rubrics, code samples and any other course materials are the <strong>exclusive intellectual property</strong> of the tutor and {LEGAL_BUSINESS_NAME}. They are licensed to you for personal study during the term of your enrolment only. They may not be copied, reproduced, redistributed, modified, displayed or used in any derivative work without our prior written consent.
      </LegalP>

      <LegalH2>8. Service availability</LegalH2>
      <LegalP>
        We will make reasonable efforts to conduct every class as scheduled. In the event that a scheduled class must be cancelled or postponed, we will either reschedule it at the earliest convenient date or make a recording of equivalent material available to the affected batch. We do not guarantee uninterrupted availability of the platform or third-party services (Zoom, Razorpay, Supabase) but will work in good faith to restore service in the event of an outage.
      </LegalP>

      <LegalH2>9. Limitation of liability</LegalH2>
      <LegalP>
        To the maximum extent permitted by law, {LEGAL_BUSINESS_NAME} shall not be liable for:
      </LegalP>
      <LegalList>
        <LegalLI>Internet connectivity issues, bandwidth problems or hardware failures on the student's end.</LegalLI>
        <LegalLI>Zoom outages, video-conferencing service interruptions, or third-party platform unavailability.</LegalLI>
        <LegalLI>Device compatibility issues, incompatible browsers, operating-system limitations or unsupported hardware.</LegalLI>
        <LegalLI>Any indirect, incidental, consequential, special or exemplary damages arising from use of, or inability to use, the service.</LegalLI>
      </LegalList>
      <LegalP>
        Our maximum aggregate liability to you for any claim arising under or related to these Terms shall not exceed the enrolment fees actually paid by you in the three (3) months immediately preceding the claim.
      </LegalP>

      <LegalH2>10. Termination</LegalH2>
      <LegalP>
        We reserve the right to <strong>terminate or suspend</strong> your access to the service, <strong>without refund</strong>, if you violate any of these Terms — in particular, sharing of credentials, redistribution of content, or any commercial misuse of course material. We will normally provide notice and an opportunity to remedy, except in cases of clear and serious violation.
      </LegalP>

      <LegalH2>11. Dispute resolution &amp; governing law</LegalH2>
      <LegalP>
        These Terms are governed by and construed in accordance with the <strong>laws of India</strong>. Any dispute, claim or controversy arising out of or relating to these Terms or the service shall be subject to the exclusive jurisdiction of the courts in <strong>{JURISDICTION}</strong>.
      </LegalP>

      <LegalH2>12. Contact</LegalH2>
      <LegalList>
        <LegalLI>Email: <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a></LegalLI>
        <LegalLI>Phone: <a href={`tel:${CONTACT_PHONE.replace(/\s/g, "")}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_PHONE}</a></LegalLI>
      </LegalList>

      <LegalH2>13. Changes to these Terms</LegalH2>
      <LegalP>
        We may revise these Terms from time to time. The "Last updated" date at the top of this page reflects the most recent revision. Continued use of the service after a revision constitutes acceptance of the updated Terms.
      </LegalP>
    </LegalShell>
  );
}

// ────────────────────────────────────────────────────────────
// Refund Policy
// ────────────────────────────────────────────────────────────
function RefundPage({ go }) {
  return (
    <LegalShell go={go} eyebrow="Legal" title="Refund Policy">
      <LegalP>
        This Refund Policy explains the conditions under which a refund of the enrolment fee paid to {LEGAL_BUSINESS_NAME} (operating as "{BRAND_NAME}") may be requested and granted. By enrolling in any course, you agree to the conditions set out below.
      </LegalP>

      <LegalH2>1. Refund amount</LegalH2>
      <LegalP>
        The refundable amount, where eligible, is <strong>₹1,800</strong> — equivalent to one month's enrolment fee per course. This corresponds to the single monthly fee charged at the time of enrolment.
      </LegalP>

      <LegalH2>2. Eligibility for a refund</LegalH2>
      <LegalP>A refund will be considered only if <strong>all</strong> of the following conditions are met:</LegalP>
      <LegalList>
        <LegalLI>The refund request is raised within <strong>7 (seven) days</strong> of the payment date.</LegalLI>
        <LegalLI>The student has <strong>not attended any live class session</strong> of the enrolled batch.</LegalLI>
        <LegalLI>The student has <strong>not accessed more than two (2) recordings</strong> of the enrolled batch.</LegalLI>
      </LegalList>

      <LegalH2>3. How to request a refund</LegalH2>
      <LegalP>To request a refund, send an email to <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a> with the following details:</LegalP>
      <LegalList>
        <LegalLI><strong>Subject line:</strong> "Refund Request"</LegalLI>
        <LegalLI><strong>Full name</strong> of the enrolled student (as on the account).</LegalLI>
        <LegalLI><strong>Registered email address</strong> used at the time of enrolment.</LegalLI>
        <LegalLI><strong>Razorpay payment ID</strong> for the transaction in question (begins with <span className="mono" style={{ color: "var(--ink)" }}>pay_</span>). This is visible in your payment receipt.</LegalLI>
      </LegalList>
      <LegalP>
        Refund requests submitted without all four pieces of information may be delayed while we verify your enrolment record.
      </LegalP>

      <LegalH2>4. Processing time</LegalH2>
      <LegalP>
        Once your refund request is verified and approved, the refund will be processed within <strong>5 to 7 business days</strong> and credited back to your <strong>original payment method</strong> via Razorpay. Depending on your bank or card issuer, it may take an additional 2 to 4 business days for the credit to reflect on your statement.
      </LegalP>

      <LegalH2>5. Non-refundable cases</LegalH2>
      <LegalP>A refund will <strong>not</strong> be granted in any of the following circumstances:</LegalP>
      <LegalList>
        <LegalLI>The refund request is raised more than 7 days after the payment date.</LegalLI>
        <LegalLI>The student has attended one or more live class sessions of the enrolled batch.</LegalLI>
        <LegalLI>The student has accessed more than two (2) recordings of the enrolled batch.</LegalLI>
        <LegalLI>The account has been terminated due to a violation of our Terms and Conditions.</LegalLI>
      </LegalList>

      <LegalH2>6. Partial refunds</LegalH2>
      <LegalP>
        <strong>Partial refunds are not applicable.</strong> Either the full refund of ₹1,800 is approved per the eligibility conditions above, or no refund is issued. There is no proportional or pro-rata refund based on classes attended or recordings viewed.
      </LegalP>

      <LegalH2>7. Failed payments</LegalH2>
      <LegalP>
        In the event of a payment failure where the amount of ₹1,800 was debited from your bank/card but enrolment was <strong>not activated</strong>, a <strong>full automatic refund of ₹1,800</strong> will be initiated within <strong>3 (three) business days</strong> through Razorpay to your original payment method. No request or follow-up from you is required for such automatic refunds. If you do not receive the refund within 5 business days of the failed transaction, please contact us with the Razorpay payment ID and we will trace the transaction.
      </LegalP>

      <LegalH2>8. Contact for refund queries</LegalH2>
      <LegalList>
        <LegalLI>Email: <a href={`mailto:${CONTACT_EMAIL}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_EMAIL}</a> (Subject: "Refund Request")</LegalLI>
        <LegalLI>Phone: <a href={`tel:${CONTACT_PHONE.replace(/\s/g, "")}`} style={{ color: "var(--blue)", fontWeight: 600 }}>{CONTACT_PHONE}</a></LegalLI>
      </LegalList>

      <LegalH2>9. Governing law</LegalH2>
      <LegalP>
        This Refund Policy is governed by and construed in accordance with the laws of India. Any dispute relating to a refund decision shall be subject to the exclusive jurisdiction of the courts in {JURISDICTION}.
      </LegalP>
    </LegalShell>
  );
}

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