<x-layouts.portal title="Deal Management" page-title="Restaurant Deals">

<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
    <div>
        <h2 class="text-xs font-bold text-zinc-500 uppercase tracking-widest">Offers & Bundles</h2>
        <p class="text-[10px] text-zinc-400 mt-0.5">Create BOGO, combos, and fixed-price deals.</p>
    </div>
    <div class="flex items-center space-x-3 w-full md:w-auto">
        <x-button :href="route('portal.deals.create')">
            Create New Deal
        </x-button>
    </div>
</div>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
    @forelse($deals as $deal)
        <div class="bg-white border border-zinc-200 rounded-sm shadow-xs overflow-hidden flex flex-col group hover:border-amber-500/50 transition-colors">
            <div class="p-6 flex-1">
                <div class="flex justify-between items-start mb-4">
                    <div class="p-2 bg-amber-50 rounded-xs text-amber-600">
                        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"></path></svg>
                    </div>
                    <span class="text-lg font-black text-zinc-900">₹{{ number_format($deal->price, 2) }}</span>
                </div>
                
                <h3 class="text-xs font-black text-zinc-900 uppercase tracking-widest mb-1">{{ $deal->name }}</h3>
                <p class="text-[10px] text-zinc-400 leading-relaxed mb-6">{{ $deal->description }}</p>
                
                <div class="space-y-4">
                    @foreach($deal->slots as $slot)
                        <div>
                            <div class="flex items-center text-[8px] font-black uppercase tracking-[0.2em] text-zinc-400 mb-2">
                                <span class="mr-2">{{ $slot->name }}</span>
                                <span class="flex-1 h-[1px] bg-zinc-100"></span>
                            </div>
                            <div class="flex flex-wrap gap-1">
                                @foreach($slot->items as $slotItem)
                                    <span class="px-2 py-0.5 bg-zinc-50 border border-zinc-100 text-[8px] font-bold text-zinc-500 rounded-xs uppercase">
                                        {{ $slotItem->item->name }}
                                    </span>
                                @endforeach
                            </div>
                        </div>
                    @endforeach
                </div>
            </div>
            
            <div class="px-6 py-4 bg-zinc-50 border-t border-zinc-100 flex justify-between items-center">
                <div class="flex items-center">
                    <div class="w-2 h-2 rounded-full {{ $deal->is_active ? 'bg-emerald-500' : 'bg-zinc-300' }} mr-2"></div>
                    <span class="text-[8px] font-black uppercase tracking-widest {{ $deal->is_active ? 'text-emerald-600' : 'text-zinc-400' }}">
                        {{ $deal->is_active ? 'Active' : 'Inactive' }}
                    </span>
                </div>
                <div class="flex items-center space-x-2">
                    <a href="{{ route('portal.deals.edit', $deal) }}" class="p-1.5 text-zinc-400 hover:text-amber-600 transition-colors">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path></svg>
                    </a>
                    <form action="{{ route('portal.deals.destroy', $deal) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this deal?')">
                        @csrf
                        @method('DELETE')
                        <button type="submit" class="p-1.5 text-zinc-400 hover:text-rose-600 transition-colors">
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
                        </button>
                    </form>
                </div>
            </div>
        </div>
    @empty
        <div class="col-span-full py-24 text-center bg-white border border-zinc-200 rounded-sm shadow-sm">
            <div class="opacity-20 mb-4 text-zinc-400 flex justify-center">
                <svg class="w-16 h-16" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"></path></svg>
            </div>
            <h3 class="text-xs font-bold text-zinc-500 uppercase tracking-widest">No Deals Found</h3>
            <p class="text-[10px] text-zinc-400 mt-2">Create your first bundle or BOGO offer to boost sales.</p>
        </div>
    @endforelse
</div>

</x-layouts.portal>
