"use client";

import { usePathname } from "next/navigation";
import { CookieConsent } from "@/components/cookie-consent";
import { SiteHeader } from "@/components/site-header";
import { SiteFooter } from "@/components/site-footer";
import { BottomNav } from "@/components/bottom-nav";

/**
 * Wraps page content with the marketing chrome (header/footer/bottom nav/
 * cookie consent). Hides the chrome on routes that own their own shell:
 *   - /admin/*  uses its own sidebar layout
 *
 * Kept as a client component because it needs `usePathname` to decide.
 * The actual page content still renders server-side; this is just chrome.
 */
export function SiteShell({ children }: { children: React.ReactNode }) {
  const pathname = usePathname() ?? "/";
  const ownShell = pathname.startsWith("/admin");

  if (ownShell) {
    return <>{children}</>;
  }

  return (
    <>
      <SiteHeader />
      <main className="flex-1">{children}</main>
      <SiteFooter />
      <BottomNav />
      <CookieConsent />
    </>
  );
}
