import React from 'react';
import AdminSidebar from './Partials/AdminSidebar';
import AdminHeader from './Partials/AdminHeader';
import { Toaster } from "@/Components/ui/sonner"; 
import useFlashMessages from '@/hooks/useFlashMessages'; 

export default function AdminLayout({ children }) {
    // Activate the hook to listen for backend flash messages
    useFlashMessages();

    return (
        <div className="min-h-screen bg-gray-100 dark:bg-gray-900 flex">
            
            {/* --- DESKTOP SIDEBAR --- */}
            <AdminSidebar className="hidden md:flex" />

            {/* --- MAIN CONTENT AREA --- */}
            <div className="flex-1 flex flex-col min-w-0">
                
                {/* --- HEADER --- */}
                <AdminHeader />

                <main className="flex-1 p-4 md:p-6 overflow-y-auto">
                    {children}
                </main>
            </div>

            {/* --- TOASTER COMPONENT --- */}
            <Toaster />
        </div>
    );
}