import { NextUIProvider } from "@nextui-org/react";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import FullLoading from "@/components/FullLoading"; // 全局 Loading
import Header from "@/components/Header"; // 头部布局
import Menu from "@/components/Menu"; // 菜单
import Login from "@/components/Login";

export function ThemeProvider({ children }: { children: React.ReactNode }) {
  return (
    <>
      <NextUIProvider>
        <NextThemesProvider
          attribute="class"
          defaultTheme={process.env.DEFAULT_THEME}
        >
          <FullLoading />
          <Header name={process.env.SITE_TITLE || "AI智能体广场"} />
          <div
            className="flex justify-between items-center bg-slate-200 dark:bg-[#000]"
            style={{ height: "calc(100vh - 3.5rem)" }}
          >
            <div
              className="shadow-md mx-2 bg-[#ffffff] dark:bg-[#202123] rounded-md p-2"
              style={{ height: "calc(100vh - 5rem)", width: "5.2rem" }}
            >
              <Menu/>
            </div>
            <div
              className="relative shadow-md mr-2 bg-[#ffffff] dark:bg-[#202123] rounded-md overflow-auto scroll-smooth"
              style={{
                height: "calc(100vh - 5rem)",
                width: "calc(100% - 5.2rem)",
              }}
            >
              <main>{children}</main>
            </div>
          </div>
        </NextThemesProvider>
      </NextUIProvider>
      <Login/>
    </>
  );
}
