'use client'
import { useVulaContent } from '@/hooks/useVulaContent'
import Button from '@/components/ui/Button'
import Image from 'next/image'
import Link from 'next/link'

export default function FreshKicksSection() {
  const { items, loading } = useVulaContent('product_carousels')
  if (loading) return <div className="flex justify-center py-16"><div className="w-8 h-8 rounded-full border-2 border-current border-t-transparent animate-spin" /></div>
  if (items.length === 0) return null
  return (
    <section id="fresh-kicks" data-vula-section="fresh-kicks" data-vula-cms="product_carousels" className="py-20 bg-[#101418] border-y-2 border-[#d4af37]">
      <div className="container mx-auto px-4">
        <h2 className="text-4xl font-['Archivo_Black'] uppercase text-white mb-8">Drops That <span className="text-[#ea580c]">Hit Different</span></h2>
        <div className="flex gap-6 overflow-x-auto pb-4 [-webkit-overflow-scrolling:touch]">
          {items.map((item) => {
            const d = item.data as { title?: string; subtitle?: string; cta_text?: string; cta_url?: string; image?: string }
            return (
              <div key={item.id} className="flex-shrink-0 w-80 border-2 border-[#ea580c] shadow-[6px_6px_0_0_#16a34a]">
                <div className="relative h-60 overflow-hidden">
                  <Image src={d.image ?? ''} alt={d.title ?? ''} fill className="object-cover grayscale contrast-125" sizes="320px" />
                </div>
                <div className="p-4 bg-white">
                  <h3 className="font-['Archivo_Black'] uppercase text-lg text-[#101418]">{d.title}</h3>
                  <p className="text-sm mt-1 text-gray-600">{d.subtitle}</p>
                  <Link href={d.cta_url ?? '/products'}>
                    <Button variant="outline" size="sm" className="mt-2 border-[#ea580c] text-[#ea580c]">{d.cta_text ?? 'Browse'}</Button>
                  </Link>
                </div>
              </div>
            )
          })}
        </div>
      </div>
    </section>
  )
}