import type { Metadata } from "next";
import { SessionProvider } from "@/components/session-provider";
import { getLocale, localeDir } from "@/lib/i18n";
import { ensureStartupInitialization } from "@/lib/startup";
import "./globals.css";
// Self-hosted (variable) fonts via next/font/local — no build-time dependency
// on Google Fonts, which is flaky/blocked from this host.
import localFont from "next/font/local";

const spaceGrotesk = localFont({
  src: "./fonts/space-grotesk.woff2",
  variable: "--font-space-grotesk",
  display: "swap",
  weight: "300 700"
});

const interTight = localFont({
  src: "./fonts/inter-tight.woff2",
  variable: "--font-inter-tight",
  display: "swap",
  weight: "300 700"
});

const jetbrainsMono = localFont({
  src: "./fonts/jetbrains-mono.woff2",
  variable: "--font-jetbrains-mono",
  display: "swap",
  weight: "300 700"
});

export const metadata: Metadata = {
  metadataBase: new URL(process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3005"),
  title: "WakeL AI - Your Next Employees Aren't Human",
  description: "Deploy autonomous AI teams that run your entire business. Zero human employees required. The future of enterprise operations.",
  openGraph: {
    title: "WakeL AI - Your Next Employees Aren't Human",
    description: "Deploy autonomous AI teams that run your entire business. Zero human employees required.",
    images: [{ url: "/assets/wakelai-og.png", width: 1200, height: 630 }]
  },
  twitter: {
    card: "summary_large_image",
    title: "WakeL AI - Your Next Employees Aren't Human",
    description: "Deploy autonomous AI teams that run your entire business. Zero human employees required.",
    images: ["/assets/wakelai-og.png"]
  }
};

export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
  // Initialize services on app startup
  await ensureStartupInitialization();

  const locale = await getLocale();

  return (
    <html
      lang={locale}
      dir={localeDir(locale)}
      className={`${spaceGrotesk.variable} ${interTight.variable} ${jetbrainsMono.variable}`}
    >
      <body className="bg-void-black text-warm-white antialiased">
        <SessionProvider>{children}</SessionProvider>
      </body>
    </html>
  );
}
