"use client";

import Link from "next/link";
import { usePathname } from "next/navigation";
import type { Lang } from "@/lib/i18n";

// KO / EN 토글. 현재 경로 유지 + ?lang 토글.
export default function LangSwitch({ lang }: { lang: Lang }) {
  const pathname = usePathname() || "/";
  const href = (l: Lang) => (l === "en" ? `${pathname}?lang=en` : pathname);
  const langs: Lang[] = ["ko", "en"];
  return (
    <div className="flex items-center overflow-hidden rounded-full border border-white/15 text-[11px] font-extrabold">
      {langs.map((l) => (
        <Link
          key={l}
          href={href(l)}
          scroll={false}
          className={`px-2.5 py-1 transition ${
            lang === l ? "bg-white text-[#14171C]" : "text-white/65"
          }`}
        >
          {l.toUpperCase()}
        </Link>
      ))}
    </div>
  );
}
