/**
 * /search?q=...&lang=pt&type=...&doc_id=... — URL-shareable hybrid search results.
 *
 * Same retrieval pipeline as the Cmd+K palette, but on a full page with richer
 * cards (bbox crop, classification badge, full snippet). Bookmarkable.
 */
import Link from "next/link";
import { AuthBar } from "@/components/auth-bar";
import { SearchPanel } from "@/components/search-panel";

export const dynamic = "force-dynamic";

export default async function SearchPage({
  searchParams,
}: {
  searchParams: Promise<{ q?: string; lang?: string; type?: string; doc_id?: string }>;
}) {
  const sp = await searchParams;

  return (
    <main className="min-h-screen p-6 md:p-10 max-w-5xl mx-auto">
      <div className="flex items-start justify-between gap-4 mb-6">
        <Link href="/" className="font-mono text-xs text-[#7fdbff] hover:text-[#00ff9c]">
          ← home
        </Link>
        <AuthBar />
      </div>

      <header className="mb-6">
        <div className="font-mono text-[10px] text-[#5a6678] tracking-widest uppercase mb-2">
          hybrid search · BM25 + BGE-M3 dense + cross-encoder rerank
        </div>
        <h1 className="font-mono text-2xl text-[#00ff9c] mb-1">▍ Busca semântica</h1>
      </header>

      <SearchPanel
        initialQ={sp.q ?? ""}
        initialLang={(sp.lang as "pt" | "en") ?? "pt"}
        initialType={sp.type ?? ""}
        initialDocId={sp.doc_id ?? ""}
      />
    </main>
  );
}
