import '@/app/globals.css'
import Link from 'next/link'
import { Home, SearchX } from 'lucide-react'
import { getSiteInfo } from '@/lib/db/queries/getSiteInfo'

// Last-resort 404, rendered inside the bare root layout (src/app/layout.tsx)
// with no storefront header/footer or translations. Storefront URLs normally
// get the localized (root)/[locale]/not-found.tsx instead; this one covers
// what can't reach it: an unknown locale (the [locale] layout itself calls
// notFound()), mistyped /admin URLs, and anything outside a route group.
// Imports globals.css itself because the root layout doesn't.
export default async function RootNotFound() {
  const siteName = await getSiteInfo().then((s) => s.siteName).catch(() => '')

  return (
    <div className="min-h-screen flex items-center justify-center px-4 py-12 bg-light-gray">
      {/* A `metadata` export isn't applied to the root not-found here; React
          hoists this <title> into <head> instead. */}
      <title>{siteName ? `Page Not Found | ${siteName}` : 'Page Not Found'}</title>
      <div className="w-full max-w-lg bg-white rounded-2xl shadow-lg border border-gray-100 p-8 md:p-10 text-center">
        <div className="relative inline-flex items-center justify-center mb-6">
          <span aria-hidden className="text-[96px] md:text-[120px] font-black leading-none tracking-tight text-gradient-primary select-none">
            404
          </span>
          <span className="absolute -bottom-2 -right-4 w-12 h-12 rounded-xl bg-white shadow-md border border-gray-100 flex items-center justify-center">
            <SearchX size={24} className="text-primary" />
          </span>
        </div>
        <h1 className="text-2xl font-bold text-dark mb-2">Page not found</h1>
        <p className="text-gray-custom mb-8">
          The page you&apos;re looking for doesn&apos;t exist or has been moved.
        </p>
        <Link
          href="/"
          className="inline-flex items-center justify-center gap-2 bg-gradient-primary text-white px-6 py-3 rounded-lg font-medium hover:shadow-md transition"
        >
          <Home size={18} />
          Back to Home
        </Link>
        {siteName && <p className="text-xs text-gray-custom mt-8">{siteName}</p>}
      </div>
    </div>
  )
}
