import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import PWARegistration from "@/components/PWARegistration";
import OfflineIndicator from "@/components/OfflineIndicator";
import UploadQueue from "@/components/UploadQueue";
import { I18nProvider } from "@/i18n/I18nContext";
import { SessionProvider } from "@/context/SessionContext";
import { AuthProvider } from "@/context/AuthContext";
import ActiveSessionBanner from "@/components/ActiveSessionBanner";
import MainContentWrapper from "@/components/MainContentWrapper";
import SyncHandler from "@/components/SyncHandler";
import CookieBanner from "@/components/CookieBanner";
import OnboardingTutorial from "@/components/OnboardingTutorial";
import BackgroundRemovalHandler from "@/components/BackgroundRemovalHandler";
import SentryInit from "@/components/SentryInit";

const inter = Inter({ subsets: ["latin"], variable: '--font-inter' });

export const metadata: Metadata = {
    title: {
        default: "DramLog",
        template: "%s | DramLog"
    },
    description: "Modern Whisky Enthusiast Tool",
    manifest: "/manifest.webmanifest",
    appleWebApp: {
        capable: true,
        statusBarStyle: "default",
        title: "DramLog",
    },
    formatDetection: {
        telephone: false,
    },
};

export const viewport = {
    themeColor: "#000000",
    width: "device-width",
    initialScale: 1,
    maximumScale: 1,
    userScalable: false,
};

export default function RootLayout({
    children,
}: Readonly<{
    children: React.ReactNode;
}>) {
    return (
        <html lang="de" suppressHydrationWarning={true}>
            <body className={`${inter.variable} font-sans`}>
                <SentryInit />
                <I18nProvider>

                    <AuthProvider>
                        <SessionProvider>
                            <ActiveSessionBanner />
                            <MainContentWrapper>
                                <SyncHandler />
                                <BackgroundRemovalHandler />
                                <PWARegistration />
                                <UploadQueue />
                                {children}
                            </MainContentWrapper>
                            <CookieBanner />
                            <OnboardingTutorial />
                        </SessionProvider>
                    </AuthProvider>
                </I18nProvider>
            </body>
        </html>
    );
}
