import "./globals.css";
import type { Metadata } from "next";
import { ReactNode } from "react";
import { getMetadataForLocale, fallbackLocale, locales } from "@/config/i18n";
import { AppProviders } from "@/providers/AppProviders";
import { inter, robotoMono } from "@/styles/fonts";
import { buildLocaleAlternates, buildOpenGraph, buildTwitterCard, metadataBase } from "@/seo/seoUtils";

const baseMeta = getMetadataForLocale(fallbackLocale);

export const metadata: Metadata = {
  metadataBase: metadataBase(),
  title: baseMeta.title,
  description: baseMeta.description,
  alternates: {
    canonical: "/",
    languages: buildLocaleAlternates("/")
  },
  openGraph: buildOpenGraph({
    locale: fallbackLocale,
    title: baseMeta.title,
    description: baseMeta.description,
    path: "/"
  }),
  twitter: buildTwitterCard({
    title: baseMeta.title,
    description: baseMeta.description
  }),
  keywords: [
    "generative AI platform",
    "AI image generator",
    "AI video generator",
    "creative workflow",
    "AllAI Studio"
  ],
  other: {
    "x-default-locale": fallbackLocale,
    "supported-locales": locales.join(",")
  }
};

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang={fallbackLocale} className={`${inter.variable} ${robotoMono.variable}`}>
      <body>
        <AppProviders>{children}</AppProviders>
      </body>
    </html>
  );
}
