import { Lock } from 'lucide-react';
import Link from 'next/link';
import type { ReactNode } from 'react';

import { cn } from '@/lib/utils';

/**
 * Content block for the (auth) layout. The split screen, logo and brand panel live in app/(auth)/layout.tsx.
 */
export function AuthCard({
  title,
  description,
  top,
  children,
  footer,
  align = 'left',
}: {
  title: string;
  description?: ReactNode;
  /** Rendered above the title: an info chip, an illustration, an invitation card. */
  top?: ReactNode;
  children?: ReactNode;
  footer?: ReactNode;
  align?: 'left' | 'center';
}) {
  return (
    <div className={cn(align === 'center' && 'text-center')}>
      {top === undefined ? null : <div className={cn('mb-6', align === 'center' && 'flex flex-col items-center')}>{top}</div>}
      <h1 className="font-display text-[28px] font-bold leading-9 tracking-[-0.02em] text-foreground">{title}</h1>
      {description === undefined ? null : <div className="mt-2 text-body text-muted-foreground">{description}</div>}
      {children === undefined ? null : <div className="mt-8">{children}</div>}
      {footer === undefined ? null : <div className="mt-8 text-center text-small text-muted-foreground">{footer}</div>}
    </div>
  );
}

export function SecurityNote() {
  return (
    <p className="flex items-center justify-center gap-1.5 text-caption text-subtle-foreground">
      <Lock className="h-3 w-3" aria-hidden="true" />
      Your data is encrypted in transit.
    </p>
  );
}

export function AuthLink({ href, children }: { href: string; children: ReactNode }) {
  return (
    <Link href={href} className="rounded-sm font-semibold text-primary underline-offset-4 hover:underline">
      {children}
    </Link>
  );
}
