"use client";

import { useState, type ReactNode } from "react";
import AdminHeader from "../../components/layout/AdminHeader";
import AdminSidebar from "../../components/layout/AdminSidebar";
import { useModal } from "../../lib/modal-system/ModalContext";

interface AdminLayoutProps {
  children: ReactNode;
}

export default function AdminLayout({ children }: AdminLayoutProps) {
  const [sidebarOpen, setSidebarOpen] = useState(false);
  const { openModal } = useModal();

  return (
    <>
      <AdminHeader
        isSidebarOpen={sidebarOpen}
        onSidebarToggle={() => setSidebarOpen((prev) => !prev)}
      />

      <AdminSidebar
        isOpen={sidebarOpen}
        onClose={() => setSidebarOpen(false)}
        onLogout={() => {
          openModal("LOGOUT", {});
        }}
      />

      <main className="min-h-screen pt-16 lg:pt-20 lg:pl-56 2xl:pl-70 bg-[#FBF8FF]">
        {children}
      </main>
    </>
  );
}
