<div class="w-full flex items-center mt-4 bg-white">
    <table class="w-full border-separate rounded-lg border border-gray-200 text-sm">
        <thead>
            <tr>
                <th class="text-left border-b px-4 py-3">Tokens</th>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showClient): ?>
                    <th class="border-b px-4 py-3">Cliente</th>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <th class="border-b px-4 py-3">Fechas</th>
                <th class="border-b px-4 py-3">Entornos</th>
                <th class="text-left border-b px-4 py-3">Productos</th>
                <th class="text-left border-b px-4 py-3">Estado</th>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showActions): ?>
                    <th class="text-left border-b px-4 py-3"></th>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </tr>
        </thead>
        <tbody>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $tokens; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $token): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4">
                        <div class="flex items-center gap-2">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showRadio): ?>
                                <input type="radio" name="token" value="<?php echo e($token->id); ?>"
                                    wire:model.live="selectedTokenId">
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <button x-data="{ copied: false }"
                                @click="navigator.clipboard.writeText('<?php echo e($token->token); ?>').then(() => { copied = true; setTimeout(() => copied = false, 2000); })"
                                class="flex items-center justify-center p-1 hover:bg-gray-100 rounded transition-colors"
                                title="Copiar token">
                                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/copy.svg')); ?>" alt="Copiar"
                                    class="w-4 h-4" x-cloak x-show="!copied">
                                <span x-cloak x-show="copied" class="text-green-600 text-xs font-semibold">✓</span>
                            </button>
                            <div class="flex flex-col">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($token->name): ?>
                                    <span class="font-semibold truncate" title="<?php echo e($token->name); ?>">
                                        <?php echo e($token->name); ?>

                                    </span>
                                    <span class="text-xs text-gray-500 truncate font-mono" title="<?php echo e($token->token); ?>">
                                        <?php echo e(Str::limit($token->token, 13, '...')); ?>

                                    </span>
                                <?php else: ?>
                                    <span class="truncate" title="<?php echo e($token->token); ?>">
                                        <?php echo e(Str::limit($token->token, 13, '...')); ?>

                                    </span>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </div>
                        </div>
                    </td>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showClient): ?>
                        <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4">
                            <?php echo e($token->client->name); ?>

                        </td>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4 text-center">
                        <?php echo e($token->start_at->format('d/m/Y')); ?> - <?php echo e($token->end_at->format('d/m/Y')); ?></td>
                    <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4 text-center">
                        <?php echo e($token->sites_count); ?></td>
                    <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4">
                        <div class="flex items-center">
                            <?php
                                $tokenProducts = $token->products->whereNotNull('image')->unique('id');
                            ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($tokenProducts->count() > 0): ?>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $tokenProducts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="relative group"
                                        style="z-index: <?php echo e($tokenProducts->count() - $index); ?>; margin-left: <?php echo e($index > 0 ? '-8px' : '0'); ?>;">
                                        <img src="<?php echo e($product->image_url ?? asset('images/placeholder.png')); ?>"
                                            alt="<?php echo e($product->name); ?>"
                                            class="w-8 h-8 bg-white rounded-full object-contain border-2 border-gray-200 hover:border-3ip transition-all cursor-pointer"
                                            title="<?php echo e($product->name); ?>">
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <?php else: ?>
                                <span class="text-gray-500 text-sm">Sin productos</span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </td>
                    <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4">
                        <?php
                            $status = $token->getStatus();
                        ?>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($status === 'activo'): ?>
                            <span
                                class="inline-flex items-center gap-1 text-green-600 font-semibold bg-green-100 border border-green-200 rounded px-2 py-1">
                                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/check-circle.svg')); ?>" alt="Activo"
                                    class="w-4 h-4 svg-fill-green">
                                <span>Activo</span>
                            </span>
                        <?php elseif($status === 'vencen_pronto'): ?>
                            <span
                                class="inline-flex items-center gap-1 text-orange-600 font-semibold bg-orange-100 border border-orange-200 rounded px-2 py-1">
                                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/alert-triangle.svg')); ?>"
                                    alt="Vencen pronto" class="w-4 h-4 svg-fill-orange">
                                <span>Vence pronto</span>
                            </span>
                        <?php elseif($status === 'vencida'): ?>
                            <span
                                class="inline-flex items-center gap-1 text-red-600 font-semibold bg-red-100 border border-red-200 rounded px-2 py-1">
                                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/alert-circle.svg')); ?>" alt="Vencida"
                                    class="w-4 h-4 svg-fill-red">
                                <span>Vencida</span>
                            </span>
                        <?php else: ?>
                            <span
                                class="inline-flex items-center gap-1 text-gray-400 font-semibold bg-gray-100 border border-gray-200 rounded px-2 py-1">
                                <img src="<?php echo e(asset('vendor/blade-untitledui-icons/hourglass.svg')); ?>" alt="Desactivada"
                                    class="w-4 h-4 svg-fill-gray">
                                <span>Desactivada</span>
                            </span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </td>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showActions): ?>
                        <td class="<?php echo e(!$loop->last ? 'border-b' : ''); ?> p-4">
                            <div class="flex items-center gap-2">
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.license-tokens.show')): ?>
                                <a href="<?php echo e(route('license_tokens.show', $token->id)); ?>" class="group">
                                    <img src="<?php echo e(asset('vendor/blade-untitledui-icons/settings.svg')); ?>" alt="Ver"
                                        class="w-6 h-6 svg-fill-gray group-hover:svg-fill-orange">
                                </a>
                                <?php endif; ?>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.license-tokens.destroy')): ?>
                                <button wire:click="openDeleteModal(<?php echo e($token->id); ?>)" class="group">
                                    <img src="<?php echo e(asset('vendor/blade-untitledui-icons/trash.svg')); ?>" alt="Eliminar"
                                        class="w-6 h-6 svg-fill-red group-hover:svg-fill-orange">
                                </button>
                                <?php endif; ?>
                            </div>
                        </td>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </tbody>
    </table>
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(method_exists($tokens, 'links')): ?>
        <div class="mt-4">
            <?php echo e($tokens->links()); ?>

        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div><?php /**PATH /var/www/html/resources/views/livewire/license-tokens/components/licenses-table.blade.php ENDPATH**/ ?>