import type { Metadata } from "next";
import { MillIcon, PackageIcon, ShippingIcon } from "../components/icons";
import { ContainerSm } from "../components/layout/ContainerSm";
import Link from "next/link";
import Image from "next/image";
import { ArrowUpRight, ChevronRight } from "lucide-react";

import {
  textCopy,
  servicesData,
  allServicesData,
  buyingStepsData,
} from "./_data/services-data";
import heroImg from "./_assets/services-hero-banner.png";
import Heading from "../components/ui/Heading";
import { Container } from "../components/layout/Container";

export const metadata: Metadata = {
  title: "Services - Basmati Pakistan",
  description:
    "Our Services Explore Our Diverse Range of Services We provide end-to-end solutions for Basmati rice export, ensuring quality, timely delivery, and exceptional customer support. Let us simplify your sourcing experience. Milling Services Our advanced milling technology ensures precision processing, preserving the unique flavor and aroma of Basmati rice while meeting international quality standards. Packaging Solution […]",
  alternates: {
    canonical: "https://basmatipakistan.com/services/",
  },
  openGraph: {
    title: "Services - Basmati Pakistan",
    description:
      "Our Services Explore Our Diverse Range of Services We provide end-to-end solutions for Basmati rice export, ensuring quality, timely delivery, and exceptional customer support. Let us simplify your sourcing experience. Milling Services Our advanced milling technology ensures precision processing, preserving the unique flavor and aroma of Basmati rice while meeting international quality standards. Packaging Solution […]",
    url: "https://basmatipakistan.com/services/",
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "Services - Basmati Pakistan",
    description:
      "Our Services Explore Our Diverse Range of Services We provide end-to-end solutions for Basmati rice export, ensuring quality, timely delivery, and exceptional customer support. Let us simplify your sourcing experience. Milling Services Our advanced milling technology ensures precision processing, preserving the unique flavor and aroma of Basmati rice while meeting international quality standards. Packaging Solution […]",
  },
};

interface ServiceCardProps {
  icon: React.ReactNode;
  iconBg: string;
  title: string;
  description: string;
  href: string;
}

function ServiceCard({
  icon,
  iconBg,
  title,
  description,
  href,
}: ServiceCardProps) {
  return (
    <div className="group w-full overflow-hidden hover:border-primary transition-all duration-500 transform hover:-translate-y-4  px-9 pt-10 pb-12 border border-gray-200 rounded-xl relative">
      <div className="transform group-hover:-translate-y-17 transition-all duration-500">
        <div
          className={`rounded-full ${iconBg} p-3 flex items-center justify-center w-fit mb-8`}
        >
          {icon}
        </div>
        <Heading as="h4" variant="card" className="text-primary">
          {title}
        </Heading>
        <p className="text-gray-600 leading-6">{description}</p>
        <Link
          href={href}
          className="absolute -bottom-22 opacity-0 group-hover:opacity-100 transition-all duration-500 right-0 rounded-full border border-gray-300 p-3"
        >
          <ArrowUpRight size={30} strokeWidth={0.5} className="text-black/80" />
        </Link>
      </div>
    </div>
  );
}

export default function ServicesPage() {
  const getIcon = (type: string) => {
    switch (type) {
      case "mill":
        return <MillIcon size={35} />;
      case "package":
        return <PackageIcon size={35} />;
      case "shipping":
        return <ShippingIcon size={35} />;
      default:
        return null;
    }
  };

  return (
    <>
      <section className="relative h-[65vh] w-full">
        <Image
          src={heroImg}
          alt="Services Hero"
          fill
          placeholder="blur"
          className="absolute top-0 left-0 w-full h-full object-cover object-bottom"
          priority
          fetchPriority="high"
          loading="eager"
        />
        <div className="relative bg-black/60 w-full h-full flex items-center">
          <ContainerSm>
            <Heading as="h1" variant="title" className="text-white">
              {textCopy.heroTitle}
            </Heading>
          </ContainerSm>
        </div>
        <div className="absolute z-10 bottom-0 w-full bg-white h-24 [clip-path:polygon(100%_100%,100%_0,0_100%)]"></div>
      </section>
      <section className="mt-16 lg:mt-32">
        <Container>
          <div className="flex flex-col gap-2">
            <Heading
              as="h2"
              variant="section"
              className="text-primary text-center"
            >
              {textCopy.exploreHeadline}
            </Heading>
            <div className="w-full lg:w-4/5 mx-auto">
              <p className="text-gray-600 text-center">
                {textCopy.exploreDescription}
              </p>
            </div>
          </div>
          <div className="flex flex-col lg:flex-row justify-between gap-10 mt-24">
            {servicesData.map((service, index) => (
              <ServiceCard
                key={index}
                icon={getIcon(service.iconType)}
                iconBg={service.iconBg}
                title={service.title}
                description={service.description}
                href={service.href}
              />
            ))}
          </div>
        </Container>
      </section>
      <section className="relative mt-16 lg:mt-32 py-56 bg-primary">
        <div className="absolute z-10 top-0 w-full bg-white h-24 [clip-path:polygon(0_100%,0_0,100%_0)]" />
        <Container>
          <div className="flex flex-col gap-16">
            <div className="flex flex-col gap-2">
              <Heading
                as="h2"
                variant="section"
                className="text-white text-center"
              >
                {textCopy.processHeadline}
              </Heading>
              <div className="w-full lg:w-4/5 mx-auto">
                <p className="text-white/70 text-center">
                  {textCopy.processDescription}
                </p>
              </div>
            </div>
            <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-10">
              {buyingStepsData.map((step, index) => (
                <div key={index}>
                  <div className="flex gap-6 items-center">
                    <div
                      className={`flex items-center justify-center w-12 h-12 p-5 text-white font-semibold text-lg rounded-full border-[0.05px] ${step.borderColor} ${step.bgColor}`}
                    >{`0${index + 1}`}</div>
                    <div className="w-full bg-white/30 h-[0.08px]" />
                  </div>
                  <div className="mt-8">
                    <Heading as="h4" variant="card" className="text-white">
                      {step.title}
                    </Heading>
                    <p className="mt-2 text text-white/60">
                      {step.description}
                    </p>
                  </div>
                </div>
              ))}
            </div>
          </div>
        </Container>
        <div className="absolute z-10 -bottom-1 w-full bg-white h-24 [clip-path:polygon(100%_0,100%_100%,0_100%)]" />
      </section>
      <section className="mt-16 lg:mt-32">
        <ContainerSm>
          <div className="flex flex-col gap-16">
            <div className="flex flex-col gap-2">
              <Heading
                as="h2"
                variant="section"
                className="text-primary text-center"
              >
                {textCopy.checkAllHeadline}
              </Heading>
              <div className="w-full lg:w-4/5 mx-auto">
                <p className="text-gray-600 text-center">
                  {textCopy.checkAllDescription}
                </p>
              </div>
            </div>
            <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-12 lg:gap-20 justify-center lg:mx-12">
              {allServicesData.map((service, index) => (
                <div key={index} className="w-full">
                  <Heading as="h4" variant="card" className="text-primary">
                    {service.title}
                  </Heading>
                  <div className="w-full bg-black/10 h-[0.08px] mt-4 mb-6" />
                  <ul>
                    {service.serviceList.map((item, index) => (
                      <li key={index} className="flex gap-4 items-center my-5">
                        <div
                          className={`flex items-center justify-center w-5 h-5 ${service.iconFg} ${service.iconBg} rounded-full`}
                        >
                          <ChevronRight
                            strokeWidth={2.5}
                            size={16}
                            className="relative left-[0.8px]"
                          />
                        </div>
                        <p className="text-gray-700 leading-0">{item}</p>
                      </li>
                    ))}
                  </ul>
                  <Link
                    href="/contact"
                    className="mt-8 text-sm block w-fit px-3 py-2 font-semibold rounded-md bg-primary text-white cursor-pointer transition duration-300 hover:bg-accent"
                  >
                    {textCopy.enquireLinkLabel}
                  </Link>
                </div>
              ))}
            </div>
          </div>
        </ContainerSm>
      </section>
    </>
  );
}
