import { ArrowUpRight, Boxes, CircleDollarSign } from "lucide-react";
import Link from "next/link";

import { MotionFade } from "@/components/motion-fade";
import { pickText, productItems, resolveLocale } from "@/lib/site-data";

type ProductsPageProps = {
  params: {
    locale: string;
  };
};

export default function ProductsPage({ params: { locale } }: ProductsPageProps) {
  const localeKey = resolveLocale(locale);

  const copy =
    localeKey === "de"
      ? {
          title: "Produkte",
          intro: "Pakete fuer Teams von Start bis Skalierung.",
          open: "Produkt oeffnen",
        }
      : {
          title: "Products",
          intro: "Packages for teams from early stage to scale.",
          open: "Open product",
        };

  return (
    <div className="mx-auto flex w-full max-w-6xl flex-col gap-8 px-4 py-10 sm:px-6 lg:px-8 lg:py-14">
      <MotionFade>
        <section className="rounded-3xl border border-zinc-200 bg-white p-6 dark:border-zinc-800 dark:bg-zinc-950 lg:p-10">
          <div className="flex items-center gap-3">
            <Boxes className="h-5 w-5 text-zinc-700 dark:text-zinc-200" />
            <h1 className="text-3xl font-semibold text-zinc-900 dark:text-zinc-100 sm:text-4xl">
              {copy.title}
            </h1>
          </div>
          <p className="mt-4 max-w-3xl text-base text-zinc-600 dark:text-zinc-300 sm:text-lg">
            {copy.intro}
          </p>
        </section>
      </MotionFade>

      <section className="grid gap-4 md:grid-cols-3">
        {productItems.map((item, index) => (
          <MotionFade key={item.slug} delay={index * 0.05}>
            <Link
              href={`/${localeKey}/products/${item.slug}`}
              className="group block rounded-2xl border border-zinc-200 bg-white p-5 transition hover:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-950 dark:hover:border-zinc-600"
            >
              <p className="text-sm text-zinc-500 dark:text-zinc-400">
                {pickText(item.segment, localeKey)}
              </p>
              <h2 className="mt-3 text-xl font-semibold text-zinc-900 dark:text-zinc-100">
                {pickText(item.name, localeKey)}
              </h2>
              <p className="mt-2 text-sm text-zinc-600 dark:text-zinc-300">
                {pickText(item.summary, localeKey)}
              </p>
              <p className="mt-4 inline-flex items-center gap-2 text-sm font-medium text-zinc-700 dark:text-zinc-200">
                <CircleDollarSign className="h-4 w-4" />
                {pickText(item.price, localeKey)}
              </p>
              <p className="mt-4 inline-flex items-center gap-2 text-sm font-medium text-zinc-700 group-hover:text-zinc-900 dark:text-zinc-200 dark:group-hover:text-white">
                {copy.open}
                <ArrowUpRight className="h-4 w-4" />
              </p>
            </Link>
          </MotionFade>
        ))}
      </section>
    </div>
  );
}
