import "@/css/satoshi.css";
import "@/css/style.css";
import "@/css/style2.css";
import "@/css/media.css";
// import "@/js/custom.js";
// import "@/js/us-aea-en.js";
// import "@/js/bootstrap.bundle.min.js.map";
// import "@js/vendor.min.js";

//  import

import "flatpickr/dist/flatpickr.min.css";
import "jsvectormap/dist/jsvectormap.css";

import type { Metadata } from "next";
import { headers } from "next/headers";
import NextTopLoader from "nextjs-toploader";
import type { PropsWithChildren } from "react";
import { Providers } from "./providers";
import { ThemeProvider } from "next-themes";
import { SidebarProvider } from "../../src/components/Layouts/sidebar/sidebar-context";
import { AuthProvider } from "@/contexts/AuthProvider";
import { Toaster } from "sonner";
import DynamicFavicon from "@/components/DynamicFavicon";
// import GeneralSettings from "@/models/GeneralSettings";
import GeneralSettingsLoader, {
  generalsettingsdata,
} from "@/components/GeneralSettingsLoader";

import { Montserrat, Playfair_Display, Bebas_Neue, Cormorant_SC } from "next/font/google";
const montserrat = Montserrat({
  subsets: ["latin"],
});

const playfair = Playfair_Display({
  subsets: ["latin"],
});

const bebas = Bebas_Neue({
  weight: "400",
  subsets: ["latin"],
});

const cormorant = Cormorant_SC({
  weight: ["300", "400", "500", "600", "700"],
  subsets: ["latin"],
});
// const generalSettings= JSON.stringify(localStorage.getItem('general-settings'))
export const metadata: Metadata = {
  title: {
    template: "Dulhe Sahab | %s",
    default: "Dulhe Sahab",
  },
  icons: {
    icon: "/favicon.png",
  },
  description:
    "Next.js admin dashboard toolkit with 200+ templates, UI components, and integrations for fast dashboard development.",
};

export default async function RootLayout({ children }: PropsWithChildren) {
  const headerList = await headers();

  const pathname = headerList.get("url-pathname") ?? "";

  const isAdmin = pathname.startsWith("/admin");

  return (
    <html lang="en" suppressHydrationWarning>
      <body>        
        <GeneralSettingsLoader />
        {/* <DynamicFavicon /> */}
        <Providers>
          <NextTopLoader color="#5750F1" showSpinner={false} />

          <div className="min-h-screen bg-gray-2 dark:bg-[#020d1a]">
            <main className={
                isAdmin
                  ? "min-h-screen bg-gray-2 dark:bg-[#020d1a] max-w-screen-3xl"
                  : "min-h-screen bg-gray-2 dark:bg-[#020d1a]"
              }>
              {/* <ThemeProvider defaultTheme="light" attribute="class">
                <SidebarProvider>{children}</SidebarProvider>
              </ThemeProvider> */}
              <AuthProvider>{children}</AuthProvider>
            </main>
          </div>
        </Providers>
        <Toaster
          position="bottom-right"
          closeButton
          duration={3000}
          visibleToasts={3}
          expand
          gap={10}
          offset={24}
          toastOptions={{
            className:
              "!z-[999999] !rounded-[14px] !border !border-white/10 !bg-[rgba(29,29,29,0.78)] !text-[#f9fafb] !shadow-[0_18px_45px_rgba(0,0,0,0.28)] !backdrop-blur-xl",
            style: {
              padding: "12px 14px",
              fontSize: "14px",
              lineHeight: "1.45",
              fontWeight: 500,
              minWidth: "340px",
            },
            classNames: {
              toast:
                "!rounded-[14px] !border !border-white/10 !bg-[rgba(29,29,29,0.78)] !text-[#f9fafb] !shadow-[0_18px_45px_rgba(0,0,0,0.28)] !backdrop-blur-xl",
              title: "!text-[14px] !font-semibold !text-white",
              description: "!text-[13px] !font-normal !text-gray-300 !mt-1",
              closeButton:
               "!left-auto !right-3 !top-1/2 !-translate-y-1/2 !h-6 !w-6 !rounded-full !border !border-white/10 !bg-white/10 !text-white/70 hover:!bg-white/20 hover:!text-white",
              error: "!border-l-4 !border-l-red-400",
              warning: "!border-l-4 !border-l-amber-400",
              info: "!border-l-4 !border-l-blue-400",
            },
          }}
        />
      </body>
    </html>
  );
}
