import { Sidebar } from "@/components/layout/sidebar";
import { Topbar } from "@/components/layout/topbar";
import { AlarmProvider } from "@/lib/alarm-context";
import { ThresholdProvider } from "@/lib/threshold-context";
import { ErrorBoundary } from "@/components/error-boundary";
import { Toaster } from "sonner";

export default function DashboardLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <ThresholdProvider>
    <AlarmProvider>
      <div className="flex h-screen overflow-hidden bg-background">
        <div className="hidden md:flex">
          <Sidebar />
        </div>
        <div className="flex flex-col flex-1 min-w-0 overflow-hidden">
          <Topbar />
          <main className="flex-1 overflow-y-auto p-6">
            <ErrorBoundary>
              {children}
            </ErrorBoundary>
          </main>
        </div>
        <Toaster position="bottom-right" theme="dark" richColors />
      </div>
    </AlarmProvider>
    </ThresholdProvider>
  );
}
