import type { Metadata } from "next";
import { ArrowRight, Sparkles } from "lucide-react";
import Link from "next/link";
import { getTranslations } from "next-intl/server";

import { FloatingPreferences } from "@/components/layout/floating-preferences";
import { HeroMotionBackdrop } from "@/components/layout/hero-motion-backdrop";
import { MotionFade } from "@/components/motion-fade";
import { Button } from "@/components/ui/button";
import { getSiteSettings } from "@/lib/app-config";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { getLocalizedPath, resolveLocale } from "@/lib/locale";

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

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

  return await buildLocalizedMetadata({
    locale: localeKey,
    pathname: "/coming-soon",
    title: siteSettings.locales[localeKey].siteName,
    description: t("description"),
    applyTitleTemplate: false,
  });
}

export default async function ComingSoonPage({
  params: { locale },
}: ComingSoonPageProps) {
  const localeKey = resolveLocale(locale);
  const t = await getTranslations({ locale: localeKey, namespace: "comingSoon" });

  return (
    <div className="relative min-h-screen overflow-hidden">
      <FloatingPreferences locale={localeKey} />

      <section className="hero-surface hero-home relative isolate flex min-h-screen items-center justify-center overflow-hidden px-4 pb-10 pt-24 sm:px-6 sm:pt-28 lg:px-8">
        <HeroMotionBackdrop />
        <div className="hero-header-bridge" />
        <div className="hero-content-bridge" />

        <MotionFade className="relative z-10 w-full">
          <div className="mx-auto max-w-[56rem] text-center">
            <p className="inline-flex items-center gap-2 rounded-full border border-white/24 bg-[linear-gradient(180deg,rgba(255,255,255,0.2),rgba(255,255,255,0.08))] px-4 py-2 text-xs font-semibold uppercase tracking-[0.18em] text-foreground/78 shadow-[inset_0_1px_0_rgba(255,255,255,0.42),0_18px_44px_-28px_rgba(15,23,42,0.22)] backdrop-blur-[24px] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.03))]">
              <Sparkles className="h-3.5 w-3.5 text-brand-secondary" />
              {t("badge")}
            </p>

            <p className="mx-auto mt-8 max-w-[20rem] text-base font-medium tracking-[-0.03em] text-[hsl(var(--hero-ink)/0.76)] drop-shadow-[0_10px_24px_rgba(15,23,42,0.16)] sm:text-lg">
              {t("kicker")}
            </p>

            <h1 className="mx-auto mt-5 flex max-w-[42rem] flex-col gap-y-1 pb-[0.08em] text-[3.15rem] font-semibold leading-[0.94] tracking-[-0.08em] text-[hsl(var(--hero-ink))] drop-shadow-[0_18px_40px_rgba(15,23,42,0.22)] sm:text-[4.8rem] lg:gap-y-2 lg:text-[6rem]">
              <span className="self-start bg-[linear-gradient(135deg,hsl(var(--hero-ink)),hsl(var(--hero-left)/0.9))] bg-clip-text text-transparent">
                {t("titleLineOne")}
              </span>
              <span className="self-end">{t("titleLineTwo")}</span>
              <span className="self-start bg-[linear-gradient(135deg,hsl(var(--hero-ink)),hsl(var(--hero-right)/0.85))] bg-clip-text text-transparent">
                {t("titleLineThree")}
              </span>
            </h1>

            <p className="mx-auto mt-8 max-w-[34rem] text-sm leading-7 text-foreground/68 sm:text-base">
              {t("description")}
            </p>

            <p className="mx-auto mt-4 max-w-[32rem] text-sm leading-6 text-foreground/54 sm:text-base">
              {t("note")}
            </p>

            <div className="mt-8 flex flex-wrap items-center justify-center gap-3">
              <Button asChild size="lg" className="min-w-[11rem] px-6">
                <Link href={getLocalizedPath(localeKey, "/contact")}>
                  {t("primaryCta")}
                  <ArrowRight className="h-4 w-4" />
                </Link>
              </Button>
              <Button
                asChild
                variant="outline"
                size="lg"
                className="min-w-[11rem] border-white/40 bg-white/35 px-6 backdrop-blur-sm hover:bg-white/55 dark:border-white/14 dark:bg-white/6 dark:hover:bg-white/10"
              >
                <Link href={getLocalizedPath(localeKey, "/")}>{t("secondaryCta")}</Link>
              </Button>
            </div>
          </div>
        </MotionFade>
      </section>
    </div>
  );
}
