import { headers } from "next/headers";
import { auth } from "@/lib/auth";
import { redirect } from "next/navigation";
import { ChangePasswordForm } from "./change-password-form";

export const metadata = { title: "Профиль" };

export default async function ProfilePage() {
  const session = await auth.api.getSession({ headers: await headers() });
  if (!session) redirect("/login");

  return (
    <main className="max-w-lg mx-auto px-4 py-10 w-full">
      <h1 className="text-xl font-bold tracking-wide mb-8" style={{ color: "var(--foreground)" }}>
        Профиль
      </h1>

      <div className="card-aubade p-6 mb-6">
        <h2 className="text-xs uppercase tracking-widest font-bold mb-4" style={{ color: "var(--muted-foreground)" }}>
          Аккаунт
        </h2>
        <div className="space-y-3 text-sm" style={{ color: "var(--foreground)" }}>
          <div className="flex justify-between">
            <span style={{ color: "var(--muted-foreground)" }}>Имя</span>
            <span>{session.user.name}</span>
          </div>
          <div className="flex justify-between">
            <span style={{ color: "var(--muted-foreground)" }}>Email</span>
            <span>{session.user.email}</span>
          </div>
        </div>
      </div>

      <div className="card-aubade p-6">
        <h2 className="text-xs uppercase tracking-widest font-bold mb-4" style={{ color: "var(--muted-foreground)" }}>
          Смена пароля
        </h2>
        <ChangePasswordForm />
      </div>
    </main>
  );
}
