import { CartPopupDrawer } from "@/components/layout/cart-popup-drawer";
import type { Metadata } from "next";
import { StorefrontFooter } from "@/components/layout/storefront-footer";
import { StorefrontHeader } from "@/components/layout/storefront-header";
import { WishlistToast } from "@/components/layout/wishlist-toast";
import { siteConfig } from "@/lib/site-config";
import { getCart } from "@/lib/starter-data";
import "./globals.css";

export const metadata: Metadata = {
  title: {
    default: siteConfig.name,
    template: `%s | ${siteConfig.name}`,
  },
  description: siteConfig.description,
};

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  const initialCart = await getCart();

  return (
    <html lang={siteConfig.defaultLocale}>
      <body className="min-h-screen bg-canvas text-primary antialiased">
        <StorefrontHeader />
        <main>{children}</main>
        <CartPopupDrawer initialCart={initialCart} />
        <WishlistToast />
        <StorefrontFooter />
      </body>
    </html>
  );
}
