'use client'

import { useVulaContent } from '@/hooks/useVulaContent'
import Image from 'next/image'

export default function SowetoLookbookSection() {
  const { items, loading } = useVulaContent('gallery')
  if (loading) return <div className="flex justify-center py-16"><div className="w-8 h-8 rounded-full border-2 border-[#18181b] border-t-transparent animate-spin" /></div>
  if (items.length === 0) return null

  return (
    <section id="lookbook" data-vula-section="sowetolookbook" data-vula-cms="gallery" className="py-20 bg-white text-[#101418]">
      <div className="max-w-7xl mx-auto px-4">
        <h2 className="text-4xl md:text-5xl font-black uppercase tracking-tight text-center mb-12">
          Soweto Lookbook
        </h2>
        <div className="columns-2 md:columns-3 gap-4 space-y-4">
          {items.map((item) => {
            const d = item.data as { title?: string; description?: string; image?: string }
            return (
              <div key={item.id} className="break-inside-avoid border-2 border-[#18181b] shadow-[6px_6px_0_0_#18181b] rounded-none overflow-hidden bg-white">
                <div className="relative w-full" style={{ minHeight: '200px' }}>
                  {d.image && (
                    <Image src={d.image} alt={d.title || ''} fill className="object-cover" sizes="(max-width: 768px) 100vw, 50vw" />
                  )}
                </div>
                <div className="p-4">
                  <h3 className="text-lg font-black uppercase">{d.title}</h3>
                  <p className="text-sm text-gray-600 uppercase tracking-wide">{d.description}</p>
                </div>
              </div>
            )
          })}
        </div>
      </div>
    </section>
  )
}
