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 { BadgeCheckIcon, ChevronLeftIcon } from "../components/icons";

const LAST_UPDATED = "June 4, 2026";

export const metadata: Metadata = {
  title: "Terms & Conditions | VehCall",
  description:
    "The terms governing your use of VehCall (VTRIG TECH) — eligibility, subscriptions, refunds, alert delivery, liability, and dispute resolution under Indian law.",
  alternates: { canonical: "/terms" },
  openGraph: {
    type: "website",
    url: "/terms",
    title: "Terms & Conditions | VehCall",
    description: "The terms governing your use of the VehCall platform.",
  },
};

/** Reusable, anchored 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>
  );
}

/** Numbered sub-heading within a section (e.g. 4.1, 5.4). */
function SubHeading({ children, id }: { children: ReactNode; id?: string }) {
  return (
    <h3
      id={id}
      className="scroll-mt-28 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 emphasis / warning 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: "acceptance", title: "Acceptance of Terms" },
  { id: "description-of-service", title: "Description of Service" },
  { id: "eligibility", title: "Eligibility & Registration" },
  { id: "qr-sticker", title: "QR Sticker — Use & Misuse" },
  { id: "subscription-payment", title: "Subscription Plans & Payment" },
  { id: "alert-delivery", title: "Alert Delivery & Liability" },
  { id: "parking-pass", title: "Parking Pass — Partner Locations" },
  { id: "prohibited-activities", title: "Prohibited Activities" },
  { id: "intellectual-property", title: "Intellectual Property" },
  { id: "disclaimer", title: "Disclaimer of Warranties" },
  { id: "limitation-of-liability", title: "Limitation of Liability" },
  { id: "indemnification", title: "Indemnification" },
  { id: "termination", title: "Suspension & Termination" },
  { id: "governing-law", title: "Governing Law & Disputes" },
  { id: "amendments", title: "Amendments to Terms" },
  { id: "contact", title: "Contact Us" },
];

export default function TermsPage() {
  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">
                <BadgeCheckIcon width={14} height={14} />
                Legal
              </span>
              <h1 className="mt-4 text-4xl font-extrabold leading-tight sm:text-5xl">
                Terms &amp; <span className="text-gradient">Conditions</span>
              </h1>
              <p className="mt-4 max-w-3xl text-base leading-relaxed text-white/60 sm:text-lg">
                Please read these terms carefully before using VehCall. By
                downloading, installing, or using our app or website, you agree
                to be bound by the terms set out below.
              </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 lg:grid-cols-3">
              {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="acceptance" title="1. Acceptance of Terms">
              <p>
                By downloading, installing, or using the VehCall application or
                website, you (“User”) agree to be bound by these Terms and
                Conditions (“Terms”). If you do not agree to these Terms, do not
                use the platform. These Terms are governed by the laws of India.
              </p>
            </Section>

            <Section
              id="description-of-service"
              title="2. Description of Service"
            >
              <p>
                VehCall provides a QR-based vehicle alert system. Upon
                registration, users receive a QR sticker to affix to their
                vehicle. When the sticker is scanned by a third party (attendant,
                fellow motorist, or parking operator), the registered vehicle
                owner receives an alert via WhatsApp and/or phone call. No
                personal contact information is shared with the person scanning
                the sticker.
              </p>
              <p>
                VehCall also operates a parking pass system in partnership with
                authorised parking operators. Subscribers may use their
                registered QR as proof of a valid parking pass at partner
                locations.
              </p>
            </Section>

            <Section id="eligibility" title="3. Eligibility and Registration">
              <List
                items={[
                  "You must be at least 18 years of age to register on VehCall",
                  "You must provide accurate and complete information during registration",
                  "You are responsible for maintaining the confidentiality of your account credentials",
                  "You may register a maximum of 3 vehicles under the Premium Annual plan and 1 vehicle under the Individual plan",
                  "VehCall reserves the right to suspend or terminate accounts with false or misleading information",
                ]}
              />
            </Section>

            <Section id="qr-sticker" title="4. QR Sticker — Use and Misuse">
              <SubHeading>4.1 Correct Use</SubHeading>
              <List
                items={[
                  "Affix the QR sticker clearly on your vehicle windscreen in a visible position",
                  "Ensure the sticker is not obscured, damaged, or tampered with",
                  "Only use the sticker issued for your registered vehicle",
                ]}
              />

              <SubHeading>4.2 Prohibited Use</SubHeading>
              <List
                items={[
                  "You must not transfer your QR sticker to another vehicle or another person",
                  "You must not attempt to replicate, clone, or digitally duplicate the QR code",
                  "You must not use the platform to harass, stalk, or intimidate any individual",
                  "You must not use the alert system for commercial solicitation or spam",
                ]}
              />

              <Callout>
                Misuse of the QR sticker or alert system may result in immediate
                account suspension without refund and may be reported to law
                enforcement authorities.
              </Callout>
            </Section>

            <Section
              id="subscription-payment"
              title="5. Subscription Plans and Payment"
            >
              <SubHeading>5.1 Plans</SubHeading>
              <p>
                VehCall offers the following subscription plans (prices inclusive
                of applicable GST):
              </p>
              <List
                items={[
                  <>
                    <strong className="text-white/85">Full Day Pass</strong> —
                    Rs. 100 (single day, single vehicle)
                  </>,
                  <>
                    <strong className="text-white/85">Monthly Pass</strong> — Rs.
                    299/month (single vehicle)
                  </>,
                  <>
                    <strong className="text-white/85">Annual Pass</strong> — Rs.
                    2,499/year (single vehicle)
                  </>,
                  <>
                    <strong className="text-white/85">Premium Annual</strong> —
                    Rs. 3,999/year (up to 3 vehicles)
                  </>,
                ]}
              />

              <SubHeading>5.2 Payment</SubHeading>
              <p>
                All payments are processed via Razorpay or Cashfree. VehCall does
                not store payment card details.
              </p>
              <List
                items={[
                  "GST invoices are generated automatically and available in-app",
                  "Subscription activates immediately upon successful payment",
                ]}
              />

              <SubHeading>5.3 Renewal</SubHeading>
              <p>
                Subscriptions do not auto-renew by default. You will receive a
                reminder 7 days before expiry.
              </p>
              <List
                items={[
                  "If auto-renewal is enabled by the user, it may be cancelled at any time from account settings",
                ]}
              />

              <SubHeading id="refund-policy">5.4 Refund Policy</SubHeading>
              <List
                items={[
                  <>
                    <strong className="text-white/85">Day Pass:</strong>{" "}
                    Non-refundable once activated
                  </>,
                  <>
                    <strong className="text-white/85">
                      Monthly / Annual Pass:
                    </strong>{" "}
                    Refund of pro-rated unused amount within 7 days of purchase,
                    if no QR scans have occurred on the account
                  </>,
                  "No refund is applicable after 7 days or once the QR sticker has been scanned",
                  <>
                    Refund requests must be emailed to{" "}
                    <a href="mailto:info@vehcall.com">info@vehcall.com</a> with
                    your order ID
                  </>,
                ]}
              />
            </Section>

            <Section
              id="alert-delivery"
              title="6. Alert Delivery — Limitations of Liability"
            >
              <p>
                VehCall uses WhatsApp Business API and telephony services to
                deliver alerts. You acknowledge and agree that:
              </p>
              <List
                items={[
                  "Alert delivery depends on your phone being switched on, connected to the internet or mobile network, and WhatsApp being installed and active",
                  "VehCall is not responsible for alerts not received due to network failure, phone being switched off, WhatsApp account issues, or DND (Do Not Disturb) settings",
                  "VehCall does not guarantee that an alert will be delivered within any specific time period",
                  "VehCall is not liable for any loss, damage, towing charges, parking fines, or other costs arising from a missed or delayed alert",
                ]}
              />
              <Callout>
                We recommend keeping your phone notifications active and WhatsApp
                installed for best results.
              </Callout>
            </Section>

            <Section
              id="parking-pass"
              title="7. Parking Pass — Partner Locations"
            >
              <p>
                VehCall parking passes are valid only at locations operated by
                authorised VehCall parking partners. VehCall does not guarantee
                availability of parking space at any partner location. A valid
                pass entitles you to park without per-hour charges at partner
                locations — it does not reserve a specific parking bay. VehCall
                is not responsible for disputes between users and parking
                operators regarding space availability.
              </p>
            </Section>

            <Section id="prohibited-activities" title="8. Prohibited Activities">
              <p>Users must not engage in any of the following:</p>
              <List
                items={[
                  "Using the platform for any unlawful purpose under Indian law",
                  "Attempting to reverse-engineer, hack, or disrupt the VehCall platform",
                  "Creating false accounts or impersonating another person",
                  "Using automated tools, bots, or scripts to interact with the platform",
                  "Uploading malicious code or interfering with platform security",
                  "Using the scan/alert feature to track or surveil individuals without consent",
                ]}
              />
            </Section>

            <Section id="intellectual-property" title="9. Intellectual Property">
              <p>
                All content on the VehCall platform — including the app, website,
                logo, QR technology, design, and software — is the exclusive
                intellectual property of VTRIG TECH and is protected
                under Indian copyright, trademark, and patent law.
              </p>
              <p>
                Users are granted a limited, non-exclusive, non-transferable
                licence to use the VehCall app for personal, non-commercial
                purposes only. No other rights are granted.
              </p>
            </Section>

            <Section id="disclaimer" title="10. Disclaimer of Warranties">
              <p>
                The VehCall platform is provided “as is” and “as available”. To
                the fullest extent permitted by applicable law, VehCall makes no
                warranties, express or implied, including but not limited to:
              </p>
              <List
                items={[
                  "Warranties of merchantability or fitness for a particular purpose",
                  "Uninterrupted or error-free operation of the platform",
                  "Accuracy or completeness of any information on the platform",
                ]}
              />
            </Section>

            <Section
              id="limitation-of-liability"
              title="11. Limitation of Liability"
            >
              <p>
                To the maximum extent permitted by Indian law, VehCall’s total
                liability to any user for any claim arising out of or related to
                these Terms or use of the platform shall not exceed the amount
                paid by that user for their current active subscription plan.
              </p>
              <p>
                VehCall shall not be liable for any indirect, incidental,
                consequential, or punitive damages including loss of data, loss
                of profits, or damage to property.
              </p>
            </Section>

            <Section id="indemnification" title="12. Indemnification">
              <p>
                You agree to indemnify, defend, and hold harmless VTRIG TECH,
                its directors, officers, employees, and agents from any
                claims, losses, damages, or expenses (including legal fees)
                arising from: (a) your use of the platform; (b) your violation of
                these Terms; (c) your violation of any third-party rights; or (d)
                any false information provided by you.
              </p>
            </Section>

            <Section
              id="termination"
              title="13. Account Suspension and Termination"
            >
              <List
                items={[
                  "VehCall reserves the right to suspend or terminate your account at any time for violation of these Terms",
                  "You may delete your account at any time from app settings",
                  "Upon termination, your QR sticker will be deactivated immediately",
                  "Any unused subscription balance will be refunded on a pro-rated basis, subject to Section 5.4",
                ]}
              />
            </Section>

            <Section
              id="governing-law"
              title="14. Governing Law and Dispute Resolution"
            >
              <p>
                These Terms shall be governed by and construed in accordance with
                the laws of India. Any dispute arising out of or in connection
                with these Terms shall first be attempted to be resolved through
                mutual discussion within 30 days.
              </p>
              <p>
                If unresolved, disputes shall be subject to arbitration under the
                Arbitration and Conciliation Act, 1996, with the seat of
                arbitration at Noida, Uttar Pradesh. The language of arbitration
                shall be English. The award shall be final and binding on both
                parties.
              </p>
              <p>
                Subject to the above arbitration clause, courts in Noida, Uttar
                Pradesh shall have exclusive jurisdiction.
              </p>
            </Section>

            <Section id="amendments" title="15. Amendments to Terms">
              <p>
                VehCall reserves the right to modify these Terms at any time.
                Material changes will be communicated via in-app notification
                and/or email at least 7 days before taking effect. Your continued
                use of the platform after the effective date constitutes
                acceptance of the revised Terms. If you do not agree to the
                revised Terms, you must stop using the platform and may request a
                pro-rated refund.
              </p>
            </Section>

            <Section id="contact" title="16. Contact Us">
              <p>
                For any questions regarding these Terms and Conditions or Privacy
                Policy:
              </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">Email</dt>
                  <dd>
                    <a href="mailto:info@vehcall.com">info@vehcall.com</a>
                  </dd>
                  <dt className="text-white/50">Phone / WhatsApp</dt>
                  <dd>
                    <a href="tel:+917836085780">+91 78360 85780</a>
                  </dd>
                  <dt className="text-white/50">Website</dt>
                  <dd>
                    <a
                      href="https://www.vehcall.com"
                      target="_blank"
                      rel="noopener noreferrer"
                    >
                      www.vehcall.com
                    </a>
                  </dd>
                  <dt className="text-white/50">Address</dt>
                  <dd className="text-white/85">
                    A-436, Ithum Heights, Sector 62, Noida - 201309, Uttar
                    Pradesh, India
                  </dd>
                </dl>
              </div>
            </Section>
          </div>
        </div>
      </main>

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