import type { Metadata } from "next";
import { headers } from "next/headers";
import "./globals.css";
import { QueryProvider } from "@/core/providers";
import { SessionTimeoutWarning } from "@/features/auth/components/SessionTimeoutWarning";

export const metadata: Metadata = {
  title: {
    default: "Assist Solutions - IT Services for Expats in Japan",
    template: "%s | Assist Solutions",
  },
  description:
    "One stop IT solution for Japan's international community. Internet, mobile, VPN, and tech support with English service since 2002.",
  robots: {
    index: false,
    follow: false,
  },
};

// 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="antialiased">
        <QueryProvider nonce={nonce}>
          {children}
          <SessionTimeoutWarning />
        </QueryProvider>
      </body>
    </html>
  );
}
