'use client';

import Link from 'next/link';
import { Heart } from 'lucide-react';
import ProductCard from '@/components/product/ProductCard';
import Button from '@/components/ui/Button';
import { useWishlist } from '@/presentation/hooks/useWishlist';
import { useTranslation } from '@/hooks/useTranslation';
import { localizeProduct } from '@/lib/product-i18n';

export default function WishlistPage() {
  const { items } = useWishlist();
  const { t } = useTranslation();
  const localizedItems = items.map((p) => localizeProduct(p, t));

  return (
    <div className="bg-gray-50">
      <div className="border-b border-gray-100 bg-white">
        <div className="mx-auto max-w-7xl px-4 py-12 sm:px-6 lg:px-8">
          <h1 className="section-heading">{t('wishlist.title')}</h1>
          <p className="text-gray-500">
            {t('wishlist.saved', { count: items.length })}
          </p>
        </div>
      </div>

      <div className="mx-auto max-w-7xl px-4 py-10 sm:px-6 lg:px-8">
        {items.length === 0 ? (
          <div className="card-premium flex flex-col items-center justify-center p-16 text-center">
            <div className="mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-50">
              <Heart className="h-8 w-8 text-red-300" />
            </div>
            <h2 className="mb-2 text-lg font-semibold text-brand-900">
              {t('wishlist.empty')}
            </h2>
            <p className="mb-6 text-sm text-gray-500">{t('wishlist.emptyHint')}</p>
            <Link href="/shop">
              <Button>{t('wishlist.browse')}</Button>
            </Link>
          </div>
        ) : (
          <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
            {localizedItems.map((product) => (
              <ProductCard key={product.id} product={product} />
            ))}
          </div>
        )}
      </div>
    </div>
  );
}