import Link from "next/link";
import ResetPasswordForm from "@/components/auth/ResetPasswordForm";

export default function ResetPasswordPage({
  searchParams,
}: {
  searchParams?: { token?: string; email?: string };
}) {
  const token = searchParams?.token?.trim() ?? "";
  const email = searchParams?.email?.toLowerCase().trim() ?? "";

  if (!token || !email) {
    return (
      <main className="mx-auto max-w-xl p-6">
        <h1 className="text-display">Enlace invalido</h1>
        <p className="text-body mt-2">Faltan parametros para restablecer la contrasena.</p>
        <p className="text-label mt-4 text-benell-text-soft">
          <Link href="/forgot-password" className="font-semibold text-benell-brown hover:underline">
            Solicitar nuevo enlace
          </Link>
        </p>
      </main>
    );
  }

  return (
    <main className="mx-auto max-w-xl p-6">
      <h1 className="text-display">Nueva contrasena</h1>
      <p className="text-body mt-2 text-benell-text-soft">Define una nueva contrasena para {email}.</p>
      <ResetPasswordForm token={token} email={email} />
    </main>
  );
}
