import Link from "next/link";
import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { Logo } from "@/components/Logo";
import { SignInButton } from "@/components/SignInButton";

export default async function HomePage() {
  const session = await getServerSession(authOptions);
  if (session) redirect("/dashboard");

  return (
    <main className="flex min-h-dvh items-center justify-center bg-surface px-6">
      <div className="w-full max-w-sm rounded-xl border border-gray-700 bg-surface-light p-8 text-center shadow-xl">
        <div className="mb-6 flex justify-center">
          <Logo size="lg" />
        </div>
        <SignInButton large />
        <p className="mt-5 text-xs leading-relaxed text-gray-500">
          By continuing, you accept the{" "}
          <Link href="/terms" className="hover:text-gray-300">Terms</Link> and{" "}
          <Link href="/privacy" className="hover:text-gray-300">Privacy Policy</Link>.
        </p>
      </div>
    </main>
  );
}
