<x-layout title="Catalogo - Lauck">

    <!-- Header -->
    <x-section-header subtitle="Inicio" title="Catalogo de " highlight="Productos"/>

    <div class="w-full max-w-5xl">

        @if ($products->count() > 0)
            <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6">
                @foreach ($products as $product)
                    <div class="group p-4 border border-neutral-800 rounded-xl hover:border-neon-lime hover:-translate-y-1 transition-all duration-300">
                        {{-- Imagen si existe --}}
                        @if (!empty($product->image_path))
                            <img src="{{ asset('storage/' . $product->image_path) }}" alt="{{ $product->name }}"
                                class="w-full h-40 object-cover rounded mb-4">
                        @else
                            <div class="w-full border border-neutral-800 h-40 bg-stone-900 flex items-center justify-center rounded mb-4">
                                <span class="text-neon-lime text-md uppercase font-bold">Sin imagen</span>
                            </div>
                        @endif

                        {{-- Nombre --}}
                        <h2 class="text-lg font-semibold text-white">{{ $product->name }}</h2>

                        {{-- Descripción corta --}}
                        <div class="h-10 overflow-y-auto [scrollbar-width:none]">
                            @if (!empty($product->description))
                                <p class="text-sm text-gray-400 mt-2">{{ $product->description }}</p>
                            @endif
                        </div>

                        {{-- Precio --}}
                        @if (!empty($product->price))
                            <p class="text-white group-hover:text-neon-lime font-bold mt-3 transition-colors">${{ number_format($product->price, 2, ',', '.') }}</p>
                        @endif

                        {{-- Botón --}}
                        <a href="{{ route('catalogo.show', $product) }}"
                            class="mt-4 block w-full bg-neon-lime/80 uppercase text-black font-semibold py-2 rounded-lg text-center shadow-md shadow-neon-lime/10 hover:bg-neutral-900/70 border border-transparent hover:text-neon-lime hover:shadow-neon-lime/20 hover:border-neutral-800 transition-all">
                            Ver +
                        </a>

                    </div>
                @endforeach
            </div>
        @else
            <p class="text-center text-gray-600 mt-10">No hay productos disponibles.</p>
        @endif

        <div class="mt-3">
            {{ $products->links() }}
        </div>
    </div>
</x-layout>
