import { getTranslations } from 'next-intl/server';
import { Container, Button, Heading } from '@/components/ui';
import Scribble from '@/components/Scribble';
import ClientNotFoundTracker from '@/components/analytics/ClientNotFoundTracker';

export default async function NotFound() {
  console.log('--- NOT FOUND RENDERED ---');
  const t = await getTranslations('Error.notFound');

  // Suggested URL logic removed along with Payload CMS
  let suggestedUrl = null;
  let suggestedLang = null;

  return (
    <>
      <script dangerouslySetInnerHTML={{ __html: `document.body.setAttribute('data-force-solid-header', 'true');` }} />
      <ClientNotFoundTracker path="" />
      <Container className="relative py-32 mt-16 flex flex-col items-center justify-center text-center min-h-[70vh] overflow-hidden">
        {/* Industrial Background Element */}
        <div className="absolute inset-0 -z-10 opacity-[0.03] pointer-events-none flex items-center justify-center">
          <span className="text-[20rem] font-bold select-none">404</span>
        </div>

        <div className="relative mb-8">
          <Heading level={1} className="text-6xl md:text-8xl font-bold mb-2">
            404
          </Heading>
          <Scribble
            variant="circle"
            className="w-[150%] h-[150%] -top-[25%] -left-[25%] text-accent/40"
          />
        </div>

        <Heading level={2} className="text-2xl md:text-3xl font-bold mb-4 text-primary">
          {t('title')}
        </Heading>

        <p className="text-text-secondary mb-10 max-w-md text-lg mx-auto">{t('description')}</p>

        {suggestedUrl && (
          <div className="mb-12 p-6 bg-accent/10 border border-accent/20 rounded-2xl animate-fade-in shadow-lg relative overflow-hidden group">
            <div className="absolute inset-0 bg-accent/5 -skew-x-12 translate-x-full group-hover:translate-x-0 transition-transform duration-700" />
            <div className="relative z-10">
              <h3 className="text-primary font-bold mb-2 text-lg">
                Did you mean to visit the {suggestedLang} version?
              </h3>
              <p className="text-text-secondary text-sm mb-4">
                This page exists, but in another language.
              </p>
              <Button href={suggestedUrl} variant="accent" size="md" className="w-full sm:w-auto">
                Go to {suggestedLang} Version
              </Button>
            </div>
          </div>
        )}

        <div className="flex flex-col sm:flex-row gap-4 justify-center">
          <Button href="/" variant={suggestedUrl ? 'outline' : 'accent'} size="lg">
            {t('cta')}
          </Button>
          <Button href="/contact" variant={suggestedUrl ? 'ghost' : 'outline'} size="lg">
            Contact Support
          </Button>
        </div>

        <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-px h-24 bg-gradient-to-t from-accent/50 to-transparent" />
      </Container>
    </>
  );
}
