import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { OfflineIndicator } from "../components/features/common";
import { InstallPrompt } from "../components/features/pwa/install-prompt";
import { ThemeProvider } from "@/components/theme-provider";

const inter = localFont({
  src: "../../public/fonts/Inter-VariableFont.woff2",
  variable: "--font-inter",
  display: "swap",
});

const merriweather = localFont({
  src: [
    { path: "../../public/fonts/Merriweather-Light.woff2", weight: "300", style: "normal" },
    { path: "../../public/fonts/Merriweather-Regular.woff2", weight: "400", style: "normal" },
    { path: "../../public/fonts/Merriweather-Bold.woff2", weight: "700", style: "normal" },
    { path: "../../public/fonts/Merriweather-Black.woff2", weight: "900", style: "normal" },
  ],
  variable: "--font-merriweather",
  display: "swap",
});

export const metadata: Metadata = {
  title: "Test01 - Local-First Venting",
  description: "Transform your struggles into personal branding content with AI-powered journaling",
  // Story 3.4: PWA metadata
  manifest: "/manifest.webmanifest", // Next.js 14+ convention
  themeColor: "#64748B",
  appleWebApp: {
    capable: true,
    statusBarStyle: "default",
    title: "Test01",
  },
  icons: {
    icon: [
      { url: "/icons/icon-192x192.png", sizes: "192x192", type: "image/png" },
      { url: "/icons/icon-512x512.png", sizes: "512x512", type: "image/png" },
    ],
    apple: [
      { url: "/icons/icon-192x192.png", sizes: "192x192", type: "image/png" },
    ],
  },
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body
        className={`${inter.variable} ${merriweather.variable} font-sans antialiased`}
      >
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          {children}
          <OfflineIndicator />
          <InstallPrompt />
        </ThemeProvider>
      </body>
    </html>
  );
}
