"use client";

import { languages, type Locale } from "@/config/business";
import { cn } from "@/lib/utils";

export default function LanguageSwitcher({ locale, onLocaleChange, className, buttonClassName }: { locale: Locale; onLocaleChange: (locale: Locale) => void; className?: string; buttonClassName?: string }) {
  return (
    <div className={cn("flex rounded-full border border-ink/10 bg-white/65 p-1 shadow-sm backdrop-blur-xl", className)} aria-label="Language switcher">
      {languages.map((language) => (
        <button
          key={language.code}
          type="button"
          onClick={() => onLocaleChange(language.code)}
          className={cn(
            "rounded-full px-3 py-1.5 text-xs font-semibold transition-all duration-300",
            buttonClassName,
            locale === language.code ? "bg-ink text-white shadow-sm" : "text-ink/55 hover:text-ink"
          )}
          aria-pressed={locale === language.code}
        >
          {language.label}
        </button>
      ))}
    </div>
  );
}
