// app/page.tsx
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import SignIn from "@/app/auth/sign-in/sign-in";
import SignUp from "@/app/auth/sign-up/sign-up";

export default async function HomePage() {
  // If already signed in, go straight to the app
  const ck = await cookies();
  const at = ck.get("ma_at")?.value;
  if (at) redirect("/portal");

  return (
    <main className="mx-auto max-w-5xl px-4 py-12">
    <section className="mb-10 text-center">
    <h1 className="text-3xl font-bold tracking-tight">MakeArmy</h1>
    <p className="mt-2 text-base text-muted-foreground">
    Free to use. Manage laser rigs, settings, and projects—all in one place.
    </p>
    </section>

    <section className="grid gap-6 md:grid-cols-2">
    <div className="rounded-lg border p-6">
    <h2 className="mb-3 text-lg font-semibold">Create an account</h2>
    {/* Uses your existing sign-up component */}
    <SignUp nextPath="/portal" />
    </div>

    <div className="rounded-lg border p-6">
    <h2 className="mb-3 text-lg font-semibold">Sign in</h2>
    {/* Uses your existing sign-in component */}
    <SignIn nextPath="/portal" reauth={false} />
    </div>
    </section>

    <section className="mt-8 text-center text-xs text-muted-foreground">
    We only use cookies strictly necessary to operate the site (e.g., your sign-in session).
    </section>
    </main>
  );
}
