import { redirect } from "next/navigation";
import { auth } from "@/lib/auth";

export default async function Home() {
  const session = await auth();

  if (session?.user) {
    redirect(session.user.role === "ADMIN" ? "/admin" : "/dashboard");
  }

  return (
    <main className="flex-1 flex flex-col items-center justify-center px-4 py-20 text-center gap-6">
      <div className="w-16 h-16 rounded-2xl bg-gradient-to-br from-[#07008b] to-[#177ce5] text-white grid place-items-center font-black text-2xl">
        BP
      </div>
      <h1 className="text-3xl font-extrabold text-[#07008b] max-w-xl">
        Mon Bilan Prévention — espace pharmacies
      </h1>
      <p className="text-slate-500 max-w-md">
        Chaque pharmacie dispose de son propre QR code pour recueillir les Bilans Prévention
        de ses patients, analysés automatiquement.
      </p>
      <div className="flex gap-3">
        <a
          href="/connexion"
          className="rounded-lg bg-[#07008b] text-white font-semibold px-5 py-2.5 text-sm"
        >
          Se connecter
        </a>
        <a
          href="/inscription"
          className="rounded-lg bg-white border border-slate-300 font-semibold px-5 py-2.5 text-sm"
        >
          Inscrire ma pharmacie
        </a>
      </div>
    </main>
  );
}
