import { auth } from "@/lib/auth";
import Link from "next/link";
import { Lock } from "lucide-react";
import { GlassContainer } from "@/components/ui/GlassContainer";

export default async function GuidesLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const session = await auth();

  if (!session?.user) {
    return (
      <div className="flex flex-col items-center justify-center py-24 px-4">
        <GlassContainer className="max-w-md w-full p-8 text-center">
          <div className="mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-violet-600/10 border border-violet-500/20 mb-6">
            <Lock className="h-7 w-7 text-violet-400" />
          </div>
          <h1 className="text-2xl font-bold text-white mb-3">
            Advanced Documentation
          </h1>
          <p className="text-gray-400 mb-6">
            Sign in to access in-depth configuration, deployment, troubleshooting,
            and fleet management guides.
          </p>
          <Link
            href="/auth/login"
            className="inline-block w-full py-2.5 px-4 bg-violet-600 hover:bg-violet-500 text-white font-medium rounded-lg transition shadow-lg shadow-violet-600/20 text-center"
          >
            Sign In
          </Link>
          <p className="mt-4 text-sm text-gray-500">
            Don&apos;t have an account?{" "}
            <Link
              href="/auth/register"
              className="text-violet-400 hover:text-violet-300 transition-colors"
            >
              Create one free
            </Link>
          </p>
        </GlassContainer>
      </div>
    );
  }

  return <>{children}</>;
}
