import type { Metadata } from "next";
import { headers } from "next/headers";
import { Sora } from "next/font/google";
import { GeistSans } from "geist/font/sans";
import "./globals.css";
import { QueryProvider } from "@/core/providers";
import { SessionTimeoutWarning } from "@/features/auth/components/SessionTimeoutWarning";

// Display font for headlines and hero text
const sora = Sora({
  subsets: ["latin"],
  variable: "--font-display",
  display: "swap",
  weight: ["500", "600", "700", "800"],
});

export const metadata: Metadata = {
  title: "Assist Solutions Portal",
  description: "Manage your subscriptions, billing, and support with Assist Solutions",
};

// Disable static generation for the entire app since it uses dynamic features extensively
// This is the recommended approach for apps with heavy useSearchParams usage
export const dynamic = "force-dynamic";

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  // Get nonce from proxy.ts for CSP-compliant inline scripts
  const headersList = await headers();
  const nonce = headersList.get("x-nonce") || undefined;

  return (
    <html lang="en" suppressHydrationWarning>
      <body className={`${GeistSans.variable} ${sora.variable} antialiased`}>
        <QueryProvider nonce={nonce}>
          {children}
          <SessionTimeoutWarning />
        </QueryProvider>
      </body>
    </html>
  );
}
