"use client"

import { usePathname, useSearchParams } from "next/navigation"
import { Navigation } from "@/components/navigation"

/**
 * Layout navigation: header with logo (left), nav links, and account.
 * Shown on every page so users always see BuildMate and can go back or navigate.
 */
export function LayoutNavigation() {
  const pathname = usePathname()
  const searchParams = useSearchParams()

  // No main site header on admin — admin has its own layout
  if (pathname?.startsWith("/admin")) {
    return null
  }

  // When admin clicks Eye/View from admin, open without main header so it stays "admin" context
  if (searchParams?.get("fromAdmin") === "1") {
    return null
  }

  // Minimal header (logo + account only) on auth pages
  const useMinimalHeader = pathname?.startsWith("/login") ||
    pathname?.startsWith("/register") ||
    pathname?.startsWith("/forgot-password") ||
    pathname?.startsWith("/reset-password")

  // Full header on dashboard, builder, builds, guides, support, profile, etc.
  const useDashboardVariant = pathname?.startsWith("/dashboard") ||
    pathname?.startsWith("/profile") ||
    pathname?.startsWith("/mybuilds") ||
    pathname?.startsWith("/likedbuilds")

  if (useMinimalHeader) {
    return <Navigation variant="minimal" />
  }
  if (useDashboardVariant) {
    return <Navigation variant="dashboard" />
  }

  return <Navigation />
}