import type { Metadata } from "next";
import type { ReactNode } from "react";
import Link from "next/link";
import Navbar from "../components/Navbar";
import Footer from "../components/Footer";
import Reveal from "../components/Reveal";
import WhatsAppFloatButton from "../components/WhatsAppFloatButton";
import { ShieldCheckIcon, ChevronLeftIcon } from "../components/icons";

const LAST_UPDATED = "June 4, 2026";

export const metadata: Metadata = {
  title: "Privacy Policy | VehCall",
  description:
    "How VehCall (VTRIG TECH) collects, uses, stores, and protects your personal information in compliance with the Digital Personal Data Protection Act, 2023.",
  alternates: { canonical: "/privacy-policy" },
  openGraph: {
    type: "website",
    url: "/privacy-policy",
    title: "Privacy Policy | VehCall",
    description:
      "How VehCall collects, uses, and protects your personal information.",
  },
};

/** Reusable, anchored policy section with a consistent heading + body rhythm. */
function Section({
  id,
  title,
  children,
}: {
  id: string;
  title: string;
  children: ReactNode;
}) {
  return (
    <Reveal as="section" className="scroll-mt-28">
      <h2 id={id} className="text-xl font-bold text-white sm:text-2xl">
        {title}
      </h2>
      <div className="mt-4 space-y-4 text-sm leading-relaxed text-white/65 sm:text-base [&_a]:text-brand [&_a]:underline-offset-2 hover:[&_a]:underline">
        {children}
      </div>
    </Reveal>
  );
}

/** Lettered sub-heading within a section (e.g. 2.1, 4.2). */
function SubHeading({ children }: { children: ReactNode }) {
  return (
    <h3 className="pt-1 text-sm font-semibold text-white/85 sm:text-base">
      {children}
    </h3>
  );
}

/** Bulleted list matched to the site's brand-dot styling. */
function List({ items }: { items: ReactNode[] }) {
  return (
    <ul className="space-y-2.5">
      {items.map((item, i) => (
        <li key={i} className="flex gap-3">
          <span className="mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-brand" />
          <span>{item}</span>
        </li>
      ))}
    </ul>
  );
}

/** Highlighted note for the "we do NOT…" style emphasis blocks. */
function Callout({ children }: { children: ReactNode }) {
  return (
    <p className="rounded-xl border border-brand/20 bg-brand/5 px-4 py-3 text-sm text-white/75">
      {children}
    </p>
  );
}

const SECTIONS = [
  { id: "who-we-are", title: "Who We Are" },
  { id: "information-we-collect", title: "Information We Collect" },
  { id: "how-we-use", title: "How We Use Your Information" },
  { id: "how-we-share", title: "How We Share Your Information" },
  { id: "data-security", title: "Data Storage and Security" },
  { id: "data-retention", title: "Data Retention" },
  { id: "your-rights", title: "Your Rights (DPDP Act, 2023)" },
  { id: "cookies", title: "Cookies and Tracking" },
  { id: "children", title: "Children’s Privacy" },
  { id: "changes", title: "Changes to This Policy" },
  { id: "grievance-officer", title: "Grievance Officer" },
];

export default function PrivacyPolicyPage() {
  return (
    <>
      <Navbar />

      <main className="pb-20 md:pb-0">
        {/* Header */}
        <section className="relative overflow-hidden px-5 pt-32 pb-12 sm:px-8 sm:pt-36">
          <div className="pointer-events-none absolute inset-0 bg-glow-radial" />
          <div className="relative mx-auto max-w-7xl">
            <Link
              href="/"
              className="inline-flex items-center gap-1.5 text-sm font-medium text-white/55 transition-colors hover:text-white"
            >
              <ChevronLeftIcon width={16} height={16} />
              Back to home
            </Link>

            <Reveal className="mt-8">
              <span className="eyebrow">
                <ShieldCheckIcon width={14} height={14} />
                Legal
              </span>
              <h1 className="mt-4 text-4xl font-extrabold leading-tight sm:text-5xl">
                Privacy <span className="text-gradient">Policy</span>
              </h1>
              <p className="mt-4 text-base leading-relaxed text-white/60 sm:text-lg">
                Your privacy is the reason VehCall exists. This policy explains
                what we collect, how we use it, and how we keep your personal
                contact details private — in line with the Digital Personal Data
                Protection Act, 2023.
              </p>
              <p className="mt-6 text-sm text-white/45">
                Last updated: {LAST_UPDATED}
              </p>
            </Reveal>
          </div>
        </section>

        {/* Body */}
        <div className="mx-auto max-w-7xl px-5 pb-24 sm:px-8">
          {/* Table of contents */}
          <Reveal className="glass mb-14 rounded-2xl p-6 sm:p-7">
            <h2 className="text-sm font-semibold uppercase tracking-wider text-white/50">
              On this page
            </h2>
            <ol className="mt-4 grid grid-cols-1 gap-x-8 gap-y-2.5 sm:grid-cols-2">
              {SECTIONS.map((s, i) => (
                <li key={s.id}>
                  <a
                    href={`#${s.id}`}
                    className="flex items-baseline gap-2 text-sm text-white/70 transition-colors hover:text-brand"
                  >
                    <span className="text-xs font-semibold text-brand/70">
                      {String(i + 1).padStart(2, "0")}
                    </span>
                    {s.title}
                  </a>
                </li>
              ))}
            </ol>
          </Reveal>

          <div className="space-y-12">
            <Section id="who-we-are" title="1. Who We Are">
              <p>
                VTRIG TECH (“VehCall”, “we”, “us”, “our”) operates the
                VehCall mobile application and website (www.vehcall.com). VehCall
                is a QR-based vehicle alert platform that allows vehicle owners
                to receive instant alerts when someone needs to reach them
                regarding their parked vehicle — without sharing any personal
                contact information.
              </p>
              <p className="text-white/50">
                Registered Office: [To be updated] &nbsp;|&nbsp; CIN: [To be
                updated] &nbsp;|&nbsp; GST: [To be updated]
              </p>
            </Section>

            <Section
              id="information-we-collect"
              title="2. Information We Collect"
            >
              <SubHeading>2.1 Information You Provide</SubHeading>
              <List
                items={[
                  "Full name and email address at registration",
                  "Mobile number (used only for alerts — never shared with scanners)",
                  "Vehicle registration number(s)",
                  "Payment information (processed securely via Razorpay / Cashfree — VehCall does not store card details)",
                  "Subscription plan selected",
                ]}
              />

              <SubHeading>2.2 Information Collected Automatically</SubHeading>
              <List
                items={[
                  "Device information (model, OS version, app version)",
                  "IP address and approximate location at time of app use",
                  "QR scan logs — timestamp and GPS coordinates of scan location",
                  "App usage data (screens visited, features used)",
                ]}
              />

              <SubHeading>2.3 Information from Third Parties</SubHeading>
              <List
                items={[
                  "WhatsApp Business API delivery status (message delivered / read — no message content is accessed)",
                  "Payment gateway transaction status",
                ]}
              />

              <Callout>
                We do <strong className="text-white">NOT</strong> collect:
                Aadhaar number, PAN, passport, or any government ID. We do{" "}
                <strong className="text-white">NOT</strong> share your mobile
                number with anyone who scans your QR sticker.
              </Callout>
            </Section>

            <Section id="how-we-use" title="3. How We Use Your Information">
              <List
                items={[
                  "To send you vehicle alerts via WhatsApp and/or phone call when your QR is scanned",
                  "To manage your subscription, process payments, and issue GST invoices",
                  "To verify your vehicle registration and prevent fraudulent registrations",
                  "To show you scan history and alert logs in the app",
                  "To send service communications (subscription renewal, app updates, policy changes)",
                  "To improve app performance and fix issues using anonymised usage data",
                  "To comply with applicable Indian law including the Digital Personal Data Protection Act, 2023",
                ]}
              />
              <Callout>
                We do <strong className="text-white">NOT</strong> use your data
                for advertising. We do <strong className="text-white">NOT</strong>{" "}
                sell your data to third parties.
              </Callout>
            </Section>

            <Section id="how-we-share" title="4. How We Share Your Information">
              <SubHeading>4.1 With Service Providers</SubHeading>
              <p>
                We share limited data with trusted third-party service providers
                strictly to operate the platform:
              </p>
              <List
                items={[
                  "WhatsApp Business API Provider (e.g., Interakt / Wati) — to send alert messages",
                  "Payment Gateway (Razorpay / Cashfree) — to process subscription payments",
                  "Cloud Hosting Provider (AWS / Google Cloud India region) — to store app data",
                  "SMS / call provider — as fallback alert channel",
                ]}
              />

              <SubHeading>
                4.2 With Parking Partners (Tender Holders / Authorities)
              </SubHeading>
              <p>
                When an attendant scans your QR sticker, they see ONLY whether
                your vehicle has a valid pass (green) or not (red). They do{" "}
                <strong className="text-white/85">NOT</strong> see your name,
                mobile number, or any personal details.
              </p>

              <SubHeading>4.3 Legal Disclosure</SubHeading>
              <p>
                We may disclose your information if required by a court order,
                law enforcement authority, or as required under the Information
                Technology Act, 2000 or the Digital Personal Data Protection
                Act, 2023.
              </p>

              <SubHeading>4.4 Business Transfer</SubHeading>
              <p>
                In the event of a merger, acquisition, or sale of VehCall, user
                data may be transferred to the acquiring entity. You will be
                notified via email prior to any such transfer.
              </p>
            </Section>

            <Section id="data-security" title="5. Data Storage and Security">
              <List
                items={[
                  "All data is stored on servers located in India in compliance with applicable data localisation requirements",
                  "Data is encrypted in transit (TLS 1.2+) and at rest (AES-256)",
                  "Access to personal data is restricted to authorised VehCall personnel on a need-to-know basis",
                  "Payment data is handled exclusively by PCI-DSS compliant payment gateways",
                  "We conduct periodic security reviews of our platform",
                ]}
              />
              <Callout>
                Despite our best efforts, no internet transmission is 100%
                secure. You use the platform at your own risk and we cannot
                guarantee absolute security.
              </Callout>
            </Section>

            <Section id="data-retention" title="6. Data Retention">
              <List
                items={[
                  <>
                    <strong className="text-white/85">Account data:</strong>{" "}
                    Retained for the duration of your subscription + 3 years
                    after account deletion (for legal/tax compliance)
                  </>,
                  <>
                    <strong className="text-white/85">Scan logs:</strong>{" "}
                    Retained for 12 months, then anonymised
                  </>,
                  <>
                    <strong className="text-white/85">Payment records:</strong>{" "}
                    Retained for 7 years as required under Indian tax law
                  </>,
                  <>
                    <strong className="text-white/85">Deleted accounts:</strong>{" "}
                    Personal identifiers removed within 30 days of deletion
                    request
                  </>,
                ]}
              />
            </Section>

            <Section
              id="your-rights"
              title="7. Your Rights (Under DPDP Act, 2023)"
            >
              <p>
                As a data principal under the Digital Personal Data Protection
                Act, 2023, you have the right to:
              </p>
              <List
                items={[
                  <>
                    <strong className="text-white/85">Access</strong> — request a
                    copy of the personal data we hold about you
                  </>,
                  <>
                    <strong className="text-white/85">Correction</strong> —
                    request correction of inaccurate or incomplete data
                  </>,
                  <>
                    <strong className="text-white/85">Erasure</strong> — request
                    deletion of your data (subject to legal retention
                    requirements)
                  </>,
                  <>
                    <strong className="text-white/85">
                      Grievance Redressal
                    </strong>{" "}
                    — raise a complaint with our Data Protection Officer
                  </>,
                  <>
                    <strong className="text-white/85">Nominate</strong> —
                    nominate another individual to exercise rights on your behalf
                    in case of death or incapacity
                  </>,
                ]}
              />
              <p>
                To exercise any of these rights, email us at:{" "}
                <a href="mailto:info@vehcall.com">info@vehcall.com</a> with
                subject line “Data Rights Request”. We will respond within 30
                days.
              </p>
            </Section>

            <Section id="cookies" title="8. Cookies and Tracking">
              <p>
                The VehCall website uses essential cookies for session management
                and security. We do not use advertising or third-party tracking
                cookies. You may disable cookies in your browser settings;
                however, some features may not function correctly.
              </p>
            </Section>

            <Section id="children" title="9. Children’s Privacy">
              <p>
                VehCall is not intended for use by individuals under 18 years of
                age. We do not knowingly collect personal data from minors. If
                you believe a minor has registered on our platform, please
                contact us immediately at{" "}
                <a href="mailto:info@vehcall.com">info@vehcall.com</a>.
              </p>
            </Section>

            <Section id="changes" title="10. Changes to This Privacy Policy">
              <p>
                We may update this Privacy Policy from time to time. When we make
                material changes, we will notify you via the app and/or email at
                least 7 days before the change takes effect. Continued use of
                VehCall after the effective date constitutes acceptance of the
                updated policy.
              </p>
            </Section>

            <Section id="grievance-officer" title="11. Grievance Officer">
              <p>
                In accordance with the Information Technology Act, 2000 and rules
                thereunder, the details of the Grievance Officer are:
              </p>
              <div className="glass rounded-2xl p-6">
                <dl className="grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-[auto_1fr]">
                  <dt className="text-white/50">Name</dt>
                  <dd className="text-white/85">Vikash Jha</dd>
                  <dt className="text-white/50">Email</dt>
                  <dd>
                    <a href="mailto:info@vehcall.com">info@vehcall.com</a>
                  </dd>
                  <dt className="text-white/50">Phone</dt>
                  <dd>
                    <a href="tel:+917836085780">+91 78360 85780</a>
                  </dd>
                  <dt className="text-white/50">Response Time</dt>
                  <dd className="text-white/85">
                    Within 30 days of receipt of complaint
                  </dd>
                </dl>
              </div>
            </Section>
          </div>
        </div>
      </main>

      <Footer />
      <WhatsAppFloatButton />
    </>
  );
}
