import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { redirect } from "next/navigation";
import { Sidebar } from "@/components/dashboard/Sidebar";

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

  return (
    <div className="flex h-screen overflow-hidden" style={{ background: "var(--bg-base)" }}>
      <Sidebar user={session.user} />
      <main className="flex-1 overflow-y-auto relative" style={{ background: "var(--bg-panel)" }}>
        {/* Top gradient line */}
        <div className="sticky top-0 h-px bg-gradient-to-r from-transparent via-indigo-500/30 to-transparent z-10 pointer-events-none" />
        {children}
      </main>
    </div>
  );
}
