import type { Metadata } from "next";
import { Compass, Layers3, Users } from "lucide-react";
import { getTranslations } from "next-intl/server";

import { Container } from "@/components/layout/container";
import { MotionFade } from "@/components/motion-fade";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { resolveLocale } from "@/lib/locale";
import { AppCard } from "@/components/ui/app-card";
import { CardContent } from "@/components/ui/card";

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

export async function generateMetadata({
  params: { locale },
}: AboutPageProps): Promise<Metadata> {
  const localeKey = resolveLocale(locale);
  const t = await getTranslations({ locale: localeKey, namespace: "aboutPage" });

  return buildLocalizedMetadata({
    locale: localeKey,
    pathname: "/about",
    title: t("title"),
    description: t("intro"),
  });
}

export default async function AboutPage({ params: { locale } }: AboutPageProps) {
  const localeKey = resolveLocale(locale);
  const t = await getTranslations({ locale: localeKey, namespace: "aboutPage" });

  return (
    <Container className="flex flex-col gap-section py-10 lg:py-14">
      <MotionFade>
        <AppCard level={3}>
          <CardContent className="p-6 lg:p-10">
            <h1 className="text-3xl font-semibold text-foreground sm:text-4xl">
              {t("title")}
            </h1>
            <p className="mt-4 max-w-3xl text-base text-muted-foreground sm:text-lg">
              {t("intro")}
            </p>
          </CardContent>
        </AppCard>
      </MotionFade>

      <MotionFade delay={0.05}>
        <AppCard>
          <CardContent className="p-6 lg:p-8">
            <h2 className="text-2xl font-semibold text-foreground">
              {t("valuesTitle")}
            </h2>
            <div className="mt-6 grid gap-4 md:grid-cols-3">
              {[
                {
                  icon: Compass,
                  title: t("valueA"),
                  text: t("valueAText"),
                },
                {
                  icon: Layers3,
                  title: t("valueB"),
                  text: t("valueBText"),
                },
                {
                  icon: Users,
                  title: t("valueC"),
                  text: t("valueCText"),
                },
              ].map((item) => {
                const Icon = item.icon;

                return (
                  <AppCard key={item.title} level={2}>
                    <CardContent className="p-5">
                      <Icon className="h-5 w-5 text-brand-primary" />
                      <h3 className="mt-3 text-lg font-semibold text-foreground">
                        {item.title}
                      </h3>
                      <p className="mt-2 text-sm text-muted-foreground">{item.text}</p>
                    </CardContent>
                  </AppCard>
                );
              })}
            </div>
          </CardContent>
        </AppCard>
      </MotionFade>

      <MotionFade delay={0.1}>
        <AppCard>
          <CardContent className="p-6 lg:p-8">
            <h2 className="text-2xl font-semibold text-foreground">
              {t("processTitle")}
            </h2>
            <ol className="mt-5 grid gap-3 sm:grid-cols-3">
              {[t("processOne"), t("processTwo"), t("processThree")].map((step, index) => (
                <AppCard key={step} level={2}>
                  <CardContent className="p-4">
                    <span className="mb-2 inline-flex h-6 w-6 items-center justify-center rounded-pill bg-surface-1 text-xs font-semibold text-foreground/80">
                      {index + 1}
                    </span>
                    <p className="text-sm text-foreground/80">{step}</p>
                  </CardContent>
                </AppCard>
              ))}
            </ol>
          </CardContent>
        </AppCard>
      </MotionFade>
    </Container>
  );
}
