<x-app-layout
    title="Instrument Categories"
    description="Browse all musical instrument categories. Find guitars, synthesizers, drums, recording gear and more."
>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Categories') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">
                    @if($categories->count() > 0)
                        <div class="mb-6">
                            <p class="text-gray-600">Browse items by category to find exactly what you're looking for.</p>
                        </div>

                        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
                            @foreach($categories as $category)
                                <a href="{{ route('categories.show', $category) }}" class="group block p-6 bg-gray-50 rounded-lg hover:bg-blue-50 transition-colors border border-gray-200 hover:border-blue-300">
                                    <div class="text-center">
                                        @if($category->icon)
                                            <div class="text-5xl mb-4">{{ $category->icon }}</div>
                                        @else
                                            <div class="w-16 h-16 mx-auto mb-4 bg-gray-300 rounded-full flex items-center justify-center">
                                                <span class="text-gray-500 font-semibold text-xl">
                                                    {{ substr($category->name, 0, 1) }}
                                                </span>
                                            </div>
                                        @endif
                                        
                                        <h3 class="font-semibold text-lg text-gray-900 group-hover:text-blue-600 mb-2">{{ $category->name }}</h3>
                                        
                                        @if($category->description)
                                            <p class="text-sm text-gray-600 mb-3">{{ $category->description }}</p>
                                        @endif
                                        
                                        <div class="flex items-center justify-center text-sm text-gray-500">
                                            <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
                                            </svg>
                                            <span>{{ $category->items_count ?? 0 }} items</span>
                                        </div>
                                    </div>
                                </a>
                            @endforeach
                        </div>
                    @else
                        <div class="text-center py-12">
                            <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
                            </svg>
                            <h3 class="text-lg font-semibold text-gray-900 mb-2 mt-4">No categories available</h3>
                            <p class="text-gray-600 mb-6">Categories will appear here once they are created.</p>
                            
                            <div class="mt-8">
                                <a href="{{ route('items.index') }}" class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 transition ease-in-out duration-150">
                                    Browse All Items
                                </a>
                            </div>
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
</x-app-layout>