import Link from "next/link";
import { SetPasswordForm } from "./set-password-form";
import { redirect } from "next/navigation";

export default async function SetPasswordPage({
  searchParams,
}: {
  searchParams: Promise<{ email?: string; token?: string }>;
}) {
  const { email, token } = await searchParams;

  if (!email || !token) {
    redirect("/login");
  }

  return (
    <div className="reveal space-y-8" style={{ animationDelay: "80ms" }}>
      <div className="space-y-3">
        <span className="eyebrow text-brand-orange">Reset</span>
        <h2 className="font-display text-4xl font-light tracking-tight text-foreground">
          Reset Password
        </h2>
        <p className="text-sm leading-relaxed text-muted-foreground">
          Set up your new secure password to access your account.
        </p>
      </div>

      <SetPasswordForm defaultEmail={email} token={token} />

      <div className="flex items-center justify-between border-t border-border/60 pt-5 text-sm">
        <Link
          href="/login"
          className="text-muted-foreground transition-colors hover:text-foreground"
        >
          ← Back to login
        </Link>
      </div>
    </div>
  );
}
