"use client";

import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import ReactLenis from "lenis/react";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import ProductCart from '@/components/ecommerce/cart/ProductCart';
import { useParams } from 'next/navigation';
import { LanguageSwitcher } from '@/components/LanguageSwitcher';
import { Locale } from '@/lib/i18nConfig';

export default function LocaleLayout({
  children,
}: Readonly<{ children: React.ReactNode }>)
{
  const params = useParams();
  const locale = params.locale as Locale;

  return (
    <ThemeProvider
      defaultButtonVariant="text-shift"
      defaultTextAnimation="entrance-slide"
      borderRadius="pill"
      contentWidth="medium"
      sizing="largeSmallSizeMediumTitles"
      background="blurBottom"
      cardStyle="gradient-radial"
      primaryButtonStyle="shadow"
      secondaryButtonStyle="solid"
      headingFontWeight="bold"
    >
      <ReactLenis root>
        <div id="nav" data-section="nav">
          <NavbarLayoutFloatingInline
            navItems={[
              { name: "Home", id: `/${locale}` },
              { name: "Vision", id: `#about` },
              { name: "Services", id: `#product` },
              { name: "Portfolio", id: `#team` },
              { name: "Clients", id: `#testimonial` },
              { name: "Contact", id: `#contact` },
            ]}
            brandName="Enkidu Soft"
            button={{
              text: "Get in Touch",              href: `#contact`
            }}
            animateOnLoad={true}
          >
            <LanguageSwitcher currentLocale={locale} />
          </NavbarLayoutFloatingInline>
        </div>
        {children}
        {/* The ProductCart is a global component, typically rendered within a layout. Moved here. */}
        <div id="ecommerce" data-section="ecommerce">
          <ProductCart
            isOpen={false}
            onClose={() => {}}
            items={[
              {
                id: "item1",                name: "Sample Product",                price: "99.99",                quantity: 1,
                imageSrc: "http://img.b2bpic.net/free-photo/modern-equipped-computer-lab_23-2149241207.jpg",                imageAlt: "Sample Product Image"
              }
            ]}
            total="99.99"
            buttons={[
              { text: "Checkout", onClick: () => console.log("Checkout clicked") }
            ]}
          />
        </div>
      </ReactLenis>
    </ThemeProvider>
  );
}
