import Link from 'next/link';
import type { ReactNode } from 'react';

import { AuthBrandPanel } from '@/components/auth/auth-brand-panel';
import { Logo } from '@/components/layout/logo';
import { ThemeToggle } from '@/components/layout/theme-toggle';
import { noIndex } from '@/lib/seo';

export const metadata = noIndex;

export default function AuthLayout({ children }: { children: ReactNode }) {
  return (
    <div className="grid min-h-screen bg-surface lg:grid-cols-2">
      <div className="flex min-h-screen flex-col">
        <header className="flex items-center justify-between px-6 py-6 sm:px-8 sm:py-8">
          <Logo className="rounded-md" />
          <ThemeToggle />
        </header>
        <main id="main" className="flex flex-1 items-center justify-center px-6 py-8 sm:px-8">
          <div className="w-full max-w-[420px] motion-safe:animate-[fade-up_280ms_cubic-bezier(0.2,0.8,0.2,1)_both]">{children}</div>
        </main>
        <footer className="px-6 py-6 text-center text-caption text-subtle-foreground sm:px-8">
          By continuing you agree to our{' '}
          <Link href="/terms" className="rounded-sm underline-offset-4 hover:text-foreground hover:underline">
            Terms
          </Link>{' '}
          and{' '}
          <Link href="/privacy" className="rounded-sm underline-offset-4 hover:text-foreground hover:underline">
            Privacy Policy
          </Link>
          .
        </footer>
      </div>
      <AuthBrandPanel />
    </div>
  );
}
