import { Outlet, Link, createRootRoute, HeadContent, Scripts } from "@tanstack/react-router";

import appCss from "../styles.css?url";

function NotFoundComponent() {
  return (
    <div className="flex min-h-screen items-center justify-center bg-background px-4">
      <div className="max-w-md text-center">
        <h1 className="text-7xl font-bold text-gradient-primary">404</h1>
        <h2 className="mt-4 text-xl font-semibold text-foreground">გვერდი ვერ მოიძებნა</h2>
        <p className="mt-2 text-sm text-muted-foreground">
          მოთხოვნილი გვერდი არ არსებობს ან გადატანილია.
        </p>
        <div className="mt-6">
          <Link
            to="/"
            className="inline-flex items-center justify-center rounded-md bg-gradient-primary px-5 py-2.5 text-sm font-medium text-primary-foreground transition-smooth hover:opacity-90"
          >
            მთავარ გვერდზე
          </Link>
        </div>
      </div>
    </div>
  );
}

export const Route = createRootRoute({
  head: () => ({
    meta: [
      { charSet: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      { title: "Looper Agency — ვაკანსია: Generative AI Designer" },
      {
        name: "description",
        content:
          "შემოგვიერთდი Looper Agency-ში Generative AI Designer-ის პოზიციაზე. ანაზღაურებადი სტაჟირება საბურთალოზე.",
      },
      { property: "og:title", content: "Looper Agency — ვაკანსია: Generative AI Designer" },
      {
        property: "og:description",
        content:
          "შემოგვიერთდი Looper Agency-ში Generative AI Designer-ის პოზიციაზე. ანაზღაურებადი სტაჟირება საბურთალოზე.",
      },
      { property: "og:type", content: "website" },
      { name: "twitter:card", content: "summary_large_image" },
      { name: "twitter:title", content: "Looper Agency — ვაკანსია: Generative AI Designer" },
      { name: "description", content: "Internship - Video Editor" },
      { property: "og:description", content: "Internship - Video Editor" },
      { name: "twitter:description", content: "Internship - Video Editor" },
      { property: "og:image", content: "https://storage.googleapis.com/gpt-engineer-file-uploads/xZytHt6yfaVWJeF0ObMcBEk33fv2/social-images/social-1779278259547-VIDEO_EDITOR.webp" },
      { name: "twitter:image", content: "https://storage.googleapis.com/gpt-engineer-file-uploads/xZytHt6yfaVWJeF0ObMcBEk33fv2/social-images/social-1779278259547-VIDEO_EDITOR.webp" },
    ],
    links: [
      { rel: "stylesheet", href: appCss },
      {
        rel: "preconnect",
        href: "https://fonts.googleapis.com",
      },
      {
        rel: "preconnect",
        href: "https://fonts.gstatic.com",
        crossOrigin: "anonymous",
      },
      {
        rel: "stylesheet",
        href: "https://fonts.googleapis.com/css2?family=Noto+Sans+Georgian:wght@400;500;600;700;800;900&family=Noto+Serif+Georgian:wght@600;700;800&display=swap",
      },
    ],
  }),
  shellComponent: RootShell,
  component: RootComponent,
  notFoundComponent: NotFoundComponent,
});

function RootShell({ children }: { children: React.ReactNode }) {
  return (
    <html lang="ka">
      <head>
        <HeadContent />
      </head>
      <body>
        {children}
        <Scripts />
      </body>
    </html>
  );
}

function RootComponent() {
  return <Outlet />;
}
