"use client";

import type { ReactNode } from "react";

import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import AppSidebar from "@/components/AppSidebar";
import { NotificationProvider } from "@/lib/notification-context";
import { UserProvider } from "@/lib/user-context";

const AppShellContent = ({ children }: { children: ReactNode }) => {
  return (
    <SidebarProvider defaultOpen>
      <div className="flex min-h-screen bg-muted/50 p-6">
        <AppSidebar />
        <SidebarInset>
          <div className="w-full max-w-[1200px] py-6 px-6">
            <div className="grid gap-5">{children}</div>
          </div>
        </SidebarInset>
      </div>
    </SidebarProvider>
  );
};

const AppShell = ({ children }: { children: ReactNode }) => {
  return (
    <UserProvider>
      <NotificationProvider>
        <AppShellContent>{children}</AppShellContent>
      </NotificationProvider>
    </UserProvider>
  );
};

export default AppShell;
