@forelse($products as $product)
    <div class="bg-white rounded-xl shadow-md border border-[#d1d5db] p-4">
        <div class="flex items-start gap-4 mb-3">
            <div class="flex-shrink-0">
                @if($product->primaryImage)
                    <img src="{{ $product->primaryImage->image_data_url }}" alt="{{ $product->name }}" class="w-20 h-20 object-cover rounded-lg border border-[#d1d5db]">
                @else
                    <div class="w-20 h-20 bg-gradient-to-br from-[#d1d5db] to-[#e6d5b8] rounded-lg border border-[#d1d5db]"></div>
                @endif
            </div>
            <div class="flex-1 min-w-0">
                <h3 class="font-semibold text-black text-lg mb-1">{{ $product->name }}</h3>
                <p class="text-sm text-black mb-2">{{ $product->category->name }}</p>
                <div class="flex flex-wrap gap-2 mb-2">
                    @if($product->featured)
                        <span class="px-2 py-1 rounded-full text-xs font-semibold bg-[#d1fae5] text-[#065f46]">Featured</span>
                    @endif
                    @if($product->availability)
                        <span class="px-2 py-1 rounded-full text-xs font-semibold bg-[#d1fae5] text-[#065f46]">Available</span>
                    @else
                        <span class="px-2 py-1 rounded-full text-xs font-semibold bg-[#fee2e2] text-[#991b1b]">Unavailable</span>
                    @endif
                </div>
                <div class="mb-3">
                    @if($product->is_on_sale)
                        <div class="flex flex-col">
                            <span class="text-black font-semibold text-lg">R{{ number_format($product->sale_price, 2) }}</span>
                            <span class="text-xs text-black line-through">R{{ number_format($product->price, 2) }}</span>
                        </div>
                    @else
                        <span class="text-black font-semibold text-lg">R{{ number_format($product->price, 2) }}</span>
                    @endif
                </div>
            </div>
        </div>
        <div class="flex flex-wrap gap-2 pt-3 border-t border-[#d1d5db]">
            <a href="{{ route('admin.products.edit', $product->id) }}" class="text-black hover:text-black transition-colors font-medium text-sm">Edit</a>
            <form method="POST" action="{{ route('admin.products.destroy', $product->id) }}" onsubmit="return confirm('Are you sure?')" class="inline">
                @csrf
                @method('DELETE')
                <button type="submit" class="text-black hover:text-[#b86a4f] transition-colors font-medium text-sm">Delete</button>
            </form>
        </div>
    </div>
@empty
    <div class="bg-white rounded-xl shadow-md border border-[#d1d5db] p-8 text-center">
        <p class="text-black">No products found.</p>
    </div>
@endforelse

















