import type { Metadata } from "next";
import localFont from "next/font/local";
import { SessionProvider } from "next-auth/react";
import { QueryProvider } from "@/components/query-provider";
import { Toaster } from "@/components/ui/sonner";
import { ClientErrorHandler } from "@/components/client-error-handler";
import "./globals.css";

console.log('🔥 LAYOUT: Root layout module loading...')

const geistSans = localFont({
  src: "./fonts/GeistVF.woff",
  variable: "--font-geist-sans",
  weight: "100 900",
});
const geistMono = localFont({
  src: "./fonts/GeistMonoVF.woff",
  variable: "--font-geist-mono",
  weight: "100 900",
});

export const metadata: Metadata = {
  title: "LCI - Jira",
  description: "LCI - Jira",
  icons: {
    icon: "/favicon.png",
  },
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  console.log('🔥 LAYOUT: Root layout component rendering...')
  
  try {
    return (
      <html lang="en">
        <body
          suppressHydrationWarning={true}
          className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen`}
        >

          <SessionProvider>
            <QueryProvider>
              <ClientErrorHandler />
              <Toaster richColors theme="light" />
              {children}
            </QueryProvider>
          </SessionProvider>
        </body>
      </html>
    );
  } catch (error) {
    console.error('🔥 LAYOUT ERROR:', error)
    throw error
  }
}
