/**
 * /debug — Página visual de logs (protegida por token)
 * Acceso: https://cursos.nirgua.com.ve/debug?token=TU_TOKEN
 */
import { redirect } from "next/navigation";
import DebugPanel from "@/components/debug/DebugPanel";

export const dynamic = "force-dynamic";

interface Props {
  searchParams: { token?: string };
}

export default function DebugPage({ searchParams }: Props) {
  const token    = searchParams.token || "";
  const envToken = process.env.DEBUG_TOKEN;

  // Si no hay DEBUG_TOKEN configurado o el token es incorrecto → 404
  if (!envToken || token !== envToken) {
    redirect("/not-found");
  }

  return <DebugPanel token={token} />;
}
