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 ActiveSessionBanner from "@/components/ActiveSessionBanner";
import MainContentWrapper from "@/components/MainContentWrapper";
import AuthListener from "@/components/AuthListener";
import SyncHandler from "@/components/SyncHandler";

const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
    title: {
        default: "Whisky Vault",
        template: "%s | Whisky Vault"
    },
    description: "Dein persönlicher Whisky-Begleiter zum Scannen und Verkosten.",
    manifest: "/manifest.json",
    appleWebApp: {
        capable: true,
        statusBarStyle: "default",
        title: "Whisky Vault",
    },
    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">
            <body className={inter.className}>
                <I18nProvider>
                    <SessionProvider>
                        <AuthListener />
                        <ActiveSessionBanner />
                        <MainContentWrapper>
                            <SyncHandler />
                            <PWARegistration />
                            <OfflineIndicator />
                            <UploadQueue />
                            {children}
                        </MainContentWrapper>
                    </SessionProvider>
                </I18nProvider>
            </body>
        </html>
    );
}
