import type { Metadata } from 'next';
import ThemeWrapper from '@/lib/components/wrapper/ThemeWrapper';
import './globals.css';
import AuthWrapper from '@/lib/components/wrapper/AuthWrapper';
import { getServerSession } from 'next-auth';
import NavigationWrapper from '@/lib/components/wrapper/NavigationWrapper';
import BackgroundImage from '@/lib/components/ui/BackgroundImage';
import ToastProvider from '@/lib/providers/ToastProvider';

export const metadata: Metadata = {
  title: 'Maddy Admin',
  description: 'Maddy mail server configuration panel',
};

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body className={`p-4 h-full m-0`}>
        <ThemeWrapper>
          <BackgroundImage />
          <ToastProvider>
            <AuthWrapper session={await getServerSession()}>
              <NavigationWrapper>
                {children}
              </NavigationWrapper>
            </AuthWrapper>
          </ToastProvider>
        </ThemeWrapper>
      </body>
    </html>
  );
}
