import { redirect } from "next/navigation";
import { getSession } from "@/lib/auth";
import Sidebar from "@/components/Sidebar";

export default async function DashboardLayout({ children }: { children: React.ReactNode }) {
  const session = await getSession();
  if (!session) redirect("/login");

  return (
    <div className="flex h-screen overflow-hidden">
      <Sidebar clinic={session} />
      <main className="flex-1 overflow-y-auto relative bg-orbs w-full" style={{ background: "linear-gradient(135deg, #f5f3ff 0%, #fafaff 30%, #fef7ff 60%, #fafaff 100%)" }}>
        {/* Subtle dot pattern */}
        <div className="absolute inset-0 pointer-events-none opacity-[0.35]"
          style={{ backgroundImage: "radial-gradient(#c7c7e0 0.5px, transparent 0.5px)", backgroundSize: "28px 28px" }} />
        <div className="relative px-4 md:px-6 lg:px-8 py-6 min-h-full page-enter w-full">
          {children}
        </div>
      </main>
    </div>
  );
}
