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

import { AnimatedLogo } from "@/components/layout/animated-logo";
import { Container } from "@/components/layout/container";
import { FloatingPreferences } from "@/components/layout/floating-preferences";
import { MotionFade } from "@/components/motion-fade";
import { getSiteSettings } from "@/lib/app-config";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { resolveLocale } from "@/lib/locale";
import { AppCard } from "@/components/ui/app-card";
import { CardContent } from "@/components/ui/card";

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="surface-ambient relative min-h-screen overflow-hidden">
      <FloatingPreferences locale={localeKey} />

      <Container className="relative flex min-h-screen items-center py-24 sm:py-28">
        <MotionFade className="w-full">
          <AppCard
            level={3}
            className="mx-auto w-full max-w-4xl overflow-hidden border-border/70 bg-surface-1/88 shadow-none"
          >
            <CardContent className="relative p-6 text-center sm:p-10 lg:p-14">
              <div className="pointer-events-none absolute -right-20 -top-20 h-48 w-48 rounded-full bg-brand-secondary/15 blur-3xl sm:h-64 sm:w-64" />
              <div className="pointer-events-none absolute -bottom-24 -left-16 h-56 w-56 rounded-full bg-brand-primary/15 blur-3xl sm:h-72 sm:w-72" />

              <div className="relative">
                <p className="inline-flex items-center gap-2 rounded-pill border border-border bg-surface-1 px-3 py-1 text-xs font-semibold uppercase tracking-[0.14em] text-foreground/80">
                  <Sparkles className="h-3.5 w-3.5 text-brand-secondary" />
                  {t("badge")}
                </p>

                <div className="mt-8">
                  <AnimatedLogo />
                </div>

                <h1 className="text-balance mx-auto mt-8 max-w-3xl text-4xl font-semibold tracking-tight text-foreground sm:text-5xl lg:text-6xl">
                  {t("titleStart")}{" "}
                  <span className="brand-gradient-text">{t("titleAccent")}</span>{" "}
                  {t("titleEnd")}
                </h1>

                <p className="mx-auto mt-5 max-w-2xl text-base leading-relaxed text-muted-foreground sm:text-lg">
                  {t("description")}
                </p>

                <p className="mx-auto mt-4 max-w-2xl text-sm text-foreground/72 sm:mt-5 sm:text-base">
                  {t("note")}
                </p>
              </div>
            </CardContent>
          </AppCard>
        </MotionFade>
      </Container>
    </div>
  );
}
