"use client";

import { Sidebar } from "@/components/dashboard/sidebar";
import { ReactNode, useState } from "react";
import { SidebarContext } from "@/components/layout/sidebar-context";

interface PageLayoutProps {
  children: ReactNode;
}

export function PageLayout({ children }: PageLayoutProps) {
  const [sidebarOpen, setSidebarOpen] = useState(false);

  return (
    <SidebarContext.Provider
      value={{ open: sidebarOpen, setOpen: setSidebarOpen }}
    >
      <div className="flex h-screen bg-background overflow-hidden page-background">
        <Sidebar open={sidebarOpen} onOpenChange={setSidebarOpen} />
        <main className="flex-1 overflow-auto overflow-x-hidden page-content">
          <div className="p-4 md:p-6 space-y-4 md:space-y-6 max-w-full">
            {children}
          </div>
        </main>
      </div>
    </SidebarContext.Provider>
  );
}
