import React from 'react';
import { Link } from 'react-router-dom';
import { cn } from '@/lib/utils';

interface AuthLayoutProps {
  title: string;
  subtitle?: string;
  children: React.ReactNode;
  footerLinks?: Array<{ label: string; to: string }>;
  className?: string;
}

export function AuthLayout({
  title,
  subtitle,
  children,
  footerLinks,
  className,
}: AuthLayoutProps) {
  return (
    <div
      className={cn(
        'min-h-screen flex items-center justify-center bg-kodo-void py-12 px-4 sm:px-6 lg:px-8 relative overflow-hidden',
        className,
      )}
      role="main"
      aria-label="Page d'authentification"
    >
      {/* Background Effects */}
      <div className="absolute inset-0 overflow-hidden pointer-events-none">
        <div className="absolute top-0 right-0 w-96 h-96 bg-kodo-cyan/5 rounded-full blur-3xl" />
        <div className="absolute bottom-0 left-0 w-96 h-96 bg-kodo-magenta/5 rounded-full blur-3xl" />
      </div>

      <div className="max-w-md w-full space-y-8 relative z-10 animate-fade-in">
        {/* Logo and Title */}
        <header className="text-center">
          <div className="flex items-center justify-center mb-6">
            <div
              className="h-12 w-12 rounded-xl bg-gradient-to-br from-kodo-cyan to-kodo-cyan-dim flex items-center justify-center shadow-glow-cyan"
              aria-hidden="true"
            >
              <span className="text-kodo-void font-bold text-2xl">V</span>
            </div>
            <span className="ml-3 font-bold text-3xl text-white">Veza</span>
          </div>
          <h1
            id="auth-form-title"
            className="text-4xl font-bold text-white mb-2"
          >
            {title}
          </h1>
          {subtitle && (
            <p className="text-sm text-kodo-secondary" role="doc-subtitle">
              {subtitle}
            </p>
          )}
        </header>

        {/* Content Card */}
        <section
          className="glass rounded-2xl border border-white/10 py-8 px-6 shadow-2xl backdrop-blur-xl"
          aria-labelledby="auth-form-title"
        >
          {children}
        </section>

        {/* Footer Links */}
        {footerLinks && footerLinks.length > 0 && (
          <nav
            className="text-center space-x-4"
            aria-label="Navigation d'authentification"
          >
            {footerLinks.map((link) => (
              <Link
                key={link.to}
                to={link.to}
                className="text-sm text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 rounded"
              >
                {link.label}
              </Link>
            ))}
          </nav>
        )}
      </div>
    </div>
  );
}
