'use client';

import { X } from 'lucide-react';
import { Link } from '@/i18n/navigation';
import { buttonStyles } from '@/components/ui/buttonStyles';
import { cssVars } from '@/lib/cssVars';
import type { NavItem } from '@/lib/getNavItems';

type MobileMenuPanelProps = {
  items: NavItem[];
  labels: { close: string; nav: string; register: string };
  onClose: () => void;
};

export function MobileMenuPanel({ items, labels, onClose }: MobileMenuPanelProps) {
  return (
    <div className="flex h-full flex-col px-5 pb-8 pt-4 sm:px-8">
      <div className="flex justify-end">
        <button
          type="button"
          onClick={onClose}
          aria-label={labels.close}
          className="inline-flex size-11 items-center justify-center rounded-ui text-bone transition-colors duration-300 hover:text-gold-hi"
        >
          <X aria-hidden className="size-6" strokeWidth={1.5} />
        </button>
      </div>

      <nav aria-label={labels.nav} className="mt-8 flex flex-1 flex-col justify-center gap-2">
        {items.map((item, index) => (
          <Link
            key={item.href}
            href={item.href}
            onClick={onClose}
            style={cssVars({ '--i': index })}
            className="menu-link block border-b border-line py-5 font-serif text-4xl text-bone transition-colors duration-300 hover:text-gold-hi"
          >
            {item.label}
          </Link>
        ))}
      </nav>

      <Link
        href="/#register"
        onClick={onClose}
        style={cssVars({ '--i': items.length })}
        className={buttonStyles('primary', 'menu-link w-full')}
      >
        {labels.register}
      </Link>
    </div>
  );
}
