
<div class="w-full" style="font-size:14px; display:flex; flex-direction:column; gap:14px;">

    
    <?php if (isset($component)) { $__componentOriginal2544aeb3df80db4e8cf42f27632fe7f3 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal2544aeb3df80db4e8cf42f27632fe7f3 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.cabecera','data' => ['rotulo' => 'Negocio','titulo' => 'Productos','descripcion' => 'Los plugins que vendemos, y el contenido versionado que cada uno sirve a los Moodle de los clientes. Entra en uno para ver qué tiene publicado, quién lo recibe y en qué entornos está instalado.']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('cabecera'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['rotulo' => 'Negocio','titulo' => 'Productos','descripcion' => 'Los plugins que vendemos, y el contenido versionado que cada uno sirve a los Moodle de los clientes. Entra en uno para ver qué tiene publicado, quién lo recibe y en qué entornos está instalado.']); ?>

         <?php $__env->slot('icono', null, []); ?> 
            <?php if (isset($component)) { $__componentOriginalb86967db162ccc0bceeb1ac50f169b8f = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb86967db162ccc0bceeb1ac50f169b8f = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.nav-icon','data' => ['name' => 'package','tint' => 'orange']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('nav-icon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'package','tint' => 'orange']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb86967db162ccc0bceeb1ac50f169b8f)): ?>
<?php $attributes = $__attributesOriginalb86967db162ccc0bceeb1ac50f169b8f; ?>
<?php unset($__attributesOriginalb86967db162ccc0bceeb1ac50f169b8f); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb86967db162ccc0bceeb1ac50f169b8f)): ?>
<?php $component = $__componentOriginalb86967db162ccc0bceeb1ac50f169b8f; ?>
<?php unset($__componentOriginalb86967db162ccc0bceeb1ac50f169b8f); ?>
<?php endif; ?>
         <?php $__env->endSlot(); ?>

         <?php $__env->slot('acciones', null, []); ?> 
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.products.create')): ?>
                <a href="<?php echo e(route('products.create')); ?>" wire:navigate
                   class="flex flex-none items-center gap-2 rounded-lg px-4 py-2.5 text-[13.5px] font-semibold text-white"
                   style="background:var(--orange-500);"
                   onmouseover="this.style.background='var(--orange-600)'"
                   onmouseout="this.style.background='var(--orange-500)'">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
                    Nuevo producto
                </a>
            <?php endif; ?>
         <?php $__env->endSlot(); ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal2544aeb3df80db4e8cf42f27632fe7f3)): ?>
<?php $attributes = $__attributesOriginal2544aeb3df80db4e8cf42f27632fe7f3; ?>
<?php unset($__attributesOriginal2544aeb3df80db4e8cf42f27632fe7f3); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal2544aeb3df80db4e8cf42f27632fe7f3)): ?>
<?php $component = $__componentOriginal2544aeb3df80db4e8cf42f27632fe7f3; ?>
<?php unset($__componentOriginal2544aeb3df80db4e8cf42f27632fe7f3); ?>
<?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session('success')): ?>
        <div class="rounded-lg px-4 py-2.5 text-[13px]" style="background:var(--success-50); color:var(--success-500);">
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    
    <div class="flex flex-wrap items-center gap-3 rounded-xl border p-3 px-4"
         style="background:var(--surface-card); border-color:var(--border-subtle);">

        <div class="flex min-w-[220px] flex-1 items-center gap-2 rounded-lg border px-3 py-1.5"
             style="border-color:var(--border-default); background:var(--surface-page);">
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="var(--text-subtle)" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="flex-none"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
            <input type="text" wire:model.live.debounce.300ms="search" placeholder="Nombre o slug"
                   class="min-w-0 flex-1 border-none bg-transparent p-0 text-[13px] focus:ring-0"
                   style="color:var(--text-body);">
        </div>

        
        <div class="flex flex-none flex-wrap gap-0.5 rounded-lg border p-[3px]"
             style="background:var(--surface-page); border-color:var(--border-default);">
            <button type="button" wire:click="$set('tipo', '')"
                    class="rounded-md px-3 py-[5px] text-[12.5px] font-semibold transition-colors"
                    style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                        'background:var(--neutral-800); color:#fff' => $tipo === '',
                        'background:transparent; color:var(--text-muted)' => $tipo !== '',
                    ]) ?>">
                Todos
            </button>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $tipos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unTipo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <button type="button" wire:click="$set('tipo', '<?php echo e($unTipo); ?>')"
                        class="rounded-md px-3 py-[5px] font-mono text-[12.5px] font-semibold transition-colors"
                        style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                            'background:var(--neutral-800); color:#fff' => $tipo === $unTipo,
                            'background:transparent; color:var(--text-muted)' => $tipo !== $unTipo,
                        ]) ?>">
                    <?php echo e($unTipo); ?>

                </button>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>

        <div class="ml-auto flex flex-none items-center gap-2.5 text-[12.5px]" style="color:var(--text-muted);">
            <span>
                <strong class="font-bold" style="color:var(--text-strong);"><?php echo e($products->count()); ?></strong>
                de <?php echo e($resumen['total']); ?>

            </span>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($search !== '' || $tipo !== ''): ?>
                <button type="button" wire:click="limpiarFiltros"
                        class="inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-[12.5px] font-semibold hover:underline"
                        style="color:var(--text-link);">
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="flex-none"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>
                    Limpiar filtros
                </button>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>

    
    <?php $cajones = \App\Livewire\Products\Index::cajones(); ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($products->isNotEmpty()): ?>
        <div class="grid grid-cols-1 gap-[18px] xl:grid-cols-2">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                    $suyos = $publicado[$product->id] ?? [];
                    $ultima = \App\Livewire\Products\Index::ultimaPublicacion($suyos);

                    // Los dos flags, y los tres estados que salen de combinarlos.
                    $operativo = (bool) $product->actived;
                    $aLaVenta = (bool) $product->enabled;
                    $retirado = $operativo && ! $aLaVenta;
                ?>

                <div class="flex flex-col overflow-hidden rounded-[14px] border transition-all"
                     style="background:var(--surface-card); border-color:var(--border-subtle); opacity:<?php echo e($operativo ? '1' : '0.7'); ?>;">
                <a href="<?php echo e(route('products.show', $product->id)); ?>" wire:navigate
                   class="flex flex-1 flex-col"
                   style="background:var(--surface-card); border-color:var(--border-subtle); opacity:<?php echo e($operativo ? '1' : '0.7'); ?>;"
                   onmouseover="this.style.boxShadow='var(--shadow-md)'"
                   onmouseout="this.style.boxShadow='none'">

                    <div class="px-[26px] pt-6">
                        <div class="flex items-center gap-[18px]">
                            
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($product->image_url): ?>
                                <img src="<?php echo e($product->image_url); ?>" alt="<?php echo e($product->name); ?>"
                                     class="h-[72px] w-[72px] flex-none rounded-[18px] bg-white object-contain"
                                     style="box-shadow:var(--shadow-xs);">
                            <?php else: ?>
                                <span class="flex h-[72px] w-[72px] flex-none items-center justify-center rounded-[18px] text-[26px] font-bold"
                                      style="background:var(--surface-brand-subtle); color:var(--orange-600);">
                                    <?php echo e(Str::upper(Str::substr($product->name, 0, 2))); ?>

                                </span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                            <div class="min-w-0 flex-1">
                                <div class="flex items-center gap-2.5">
                                    <span class="truncate" style="font-family:'Plus Jakarta Sans',sans-serif; font-size:18px; font-weight:700; letter-spacing:-0.01em; color:var(--text-strong);">
                                        <?php echo e($product->name); ?>

                                    </span>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($operativo && $aLaVenta): ?>
                                        
                                        <span class="h-[9px] w-[9px] flex-none rounded-full"
                                              style="background:var(--success-500);"
                                              title="Operativo y a la venta"></span>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                </div>

                                <div class="mt-1.5 flex flex-wrap items-center gap-1.5">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($product->type): ?>
                                        <span class="rounded-full px-2.5 py-0.5 text-[10.5px] font-semibold uppercase tracking-[0.04em]"
                                              style="color:var(--orange-600); background:var(--surface-brand-subtle);">
                                            <?php echo e($product->type); ?>

                                        </span>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    <span class="rounded-full px-2.5 py-0.5 font-mono text-[11.5px]"
                                          style="color:var(--text-muted); background:var(--surface-sunken);">
                                        <?php echo e($product->slug); ?>

                                    </span>
                                </div>

                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($retirado): ?>
                                    <div class="mt-1.5">
                                        <span class="rounded-full px-2 py-px text-[10.5px] font-semibold"
                                              style="color:var(--warning-500); background:var(--warning-50);">
                                            Operativo · retirado de la venta
                                        </span>
                                    </div>
                                <?php elseif(! $operativo): ?>
                                    <div class="mt-1.5">
                                        <span class="rounded-full px-2 py-px text-[10.5px] font-semibold"
                                              style="color:var(--danger-500); background:var(--danger-50);">
                                            Inactivo — no sirve contenido
                                        </span>
                                    </div>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </div>
                        </div>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($product->summary): ?>
                            <div class="mt-3 text-[13px] leading-relaxed" style="color:var(--text-muted);">
                                <?php echo preg_replace('/\*\*(.+?)\*\*/', '<strong>$1</strong>', e($product->summary)); ?>

                            </div>
                        <?php elseif($product->description): ?>
                            <div class="mt-3 text-[13px] leading-relaxed" style="color:var(--text-muted);">
                                <?php echo e(Str::limit(strip_tags($product->description), 150)); ?>

                            </div>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                        
                        <div class="mt-3.5 flex gap-6 border-t pt-3.5" style="border-color:var(--divider);">
                            <div>
                                <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">
                                    Licencias
                                </div>
                                <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:18px; font-weight:700; color:var(--text-strong); margin-top:1px;">
                                    <?php echo e($product->tokens_count); ?>

                                </div>
                            </div>
                            <div>
                                <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">
                                    Entornos
                                </div>
                                <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:18px; font-weight:700; color:var(--text-strong); margin-top:1px;">
                                    <?php echo e($product->environments_count); ?>

                                </div>
                            </div>
                            <div class="min-w-0 flex-1">
                                <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">
                                    Publicado
                                </div>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($suyos !== []): ?>
                                    <div class="mt-1 grid grid-cols-2 gap-x-5 gap-y-[3px]">
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $suyos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $clave => $datos): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="flex items-baseline gap-1.5 text-[12px]">
                                                <span class="min-w-[16px] font-bold" style="color:var(--text-strong);"><?php echo e($datos['n']); ?></span>
                                                <span style="color:var(--text-muted);"><?php echo e(Str::lower($cajones[$clave]['nombre'])); ?></span>
                                            </div>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </div>
                                <?php else: ?>
                                    
                                    <div class="mt-1">
                                        <span class="rounded-full border border-dashed px-2.5 py-0.5 text-[11.5px]"
                                              style="color:var(--text-subtle); border-color:var(--border-default);">
                                            Nada todavía
                                        </span>
                                    </div>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </div>
                        </div>
                    </div>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($ultima): ?>
                        <div class="mt-3.5 flex items-center gap-2 border-t px-[26px] py-2.5 text-[12px]"
                             style="background:var(--surface-alt); border-color:var(--divider); color:var(--text-muted);">
                            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--text-subtle)" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="flex-none"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
                            Última publicación:
                            <strong class="font-semibold" style="color:var(--text-body);"><?php echo e($ultima['cajon']); ?></strong>
                            <span class="font-mono text-[11.5px]"><?php echo e($ultima['version']); ?></span>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($ultima['fecha']): ?>
                                · <?php echo e($ultima['fecha']->translatedFormat('j M Y')); ?>

                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    <?php else: ?>
                        <div class="mt-3.5"></div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </a>

                
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->any(['admin.products.edit', 'admin.products.destroy'])): ?>
                    <div class="-mt-[18px] flex justify-end gap-3 px-[26px] pb-2.5">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.products.edit')): ?>
                            <a href="<?php echo e(route('products.edit', $product)); ?>" wire:navigate
                               class="text-[12px] font-semibold" style="color:var(--text-muted);">Editar</a>
                        <?php endif; ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.products.destroy')): ?>
                            
                            <button type="button" wire:click="abrirBorrado(<?php echo e($product->id); ?>)"
                                    class="border-none bg-transparent p-0 text-[12px] font-semibold"
                                    style="color:var(--danger-500);">
                                Borrar…
                            </button>
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    <?php else: ?>
        <div class="rounded-xl border px-6 py-8 text-center text-[13px]"
             style="background:var(--surface-card); border-color:var(--border-subtle); color:var(--text-muted);">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($search !== '' || $tipo !== ''): ?>
                Ningún producto coincide con los filtros.
                <button type="button" wire:click="limpiarFiltros"
                        class="border-none bg-transparent p-0 text-[13px] font-semibold"
                        style="color:var(--text-link);">Limpiar filtros</button>
            <?php else: ?>
                Ningún producto todavía.
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div><?php /**PATH /var/www/html/resources/views/livewire/products/index.blade.php ENDPATH**/ ?>