import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { ThemeProvider } from "@/shared/components/theme-provider";
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { notFound } from "next/navigation";
import { routing } from "@/i18n/routing";
import "../globals.css";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Yolando — Backend Developer | Enterprise Banking Systems",
  description:
    "Building Secure, Scalable, Enterprise-Grade Systems. 3+ Years in Banking Technology. Specializing in Java Spring Boot, Microservices, and Enterprise Security.",
  keywords: [
    "Backend Developer",
    "Java",
    "Spring Boot",
    "Microservices",
    "Banking",
    "Enterprise",
    "Portfolio",
  ],
  authors: [{ name: "Yolando" }],
  openGraph: {
    title: "Yolando — Backend Developer | Enterprise Banking Systems",
    description:
      "Building Secure, Scalable, Enterprise-Grade Systems. 3+ Years in Banking Technology.",
    type: "website",
  },
};

export default async function RootLayout({
  children,
  params,
}: Readonly<{
  children: React.ReactNode;
  params: Promise<{ locale: string }>;
}>) {
  const { locale } = await params;

  // Ensure that the incoming `locale` is valid
  if (!routing.locales.includes(locale as any)) {
    notFound();
  }

  // Providing all messages to the client
  // side is the easiest way to get started
  const messages = await getMessages();

  return (
    <html
      lang={locale}
      suppressHydrationWarning
      className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
    >
      <body className="min-h-full flex flex-col">
        <NextIntlClientProvider messages={messages}>
          <ThemeProvider>{children}</ThemeProvider>
        </NextIntlClientProvider>
      </body>
    </html>
  );
}
