
<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' => 'Licencias','descripcion' => 'El contrato técnico de cada cliente: el token que se pega en su Moodle, qué productos incluye y hasta cuándo. Entra en una para renovarla, apagarla, o ver qué entornos la están usando.']] + (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' => 'Licencias','descripcion' => 'El contrato técnico de cada cliente: el token que se pega en su Moodle, qué productos incluye y hasta cuándo. Entra en una para renovarla, apagarla, o ver qué entornos la están usando.']); ?>

         <?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' => 'check-done-02','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' => 'check-done-02','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.license-tokens.create')): ?>
                <a href="<?php echo e(route('license_tokens.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>
                    Nueva licencia
                </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; ?>

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

        </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="Token, nombre o cliente"
                   class="min-w-0 flex-1 border-none bg-transparent p-0 text-[13px] focus:ring-0"
                   style="color:var(--text-body);">
            <div wire:loading wire:target="search" class="flex-none">
                <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--text-subtle)" stroke-width="2" class="animate-spin"><path d="M21 12a9 9 0 1 1-6.22-8.56"/></svg>
            </div>
        </div>

        
        <div class="flex flex-none gap-0.5 rounded-lg border p-[3px]"
             style="background:var(--surface-page); border-color:var(--border-default);">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = ['todas' => 'Todas', 'activas' => 'Activas', 'caducadas' => 'Caducadas', 'apagadas' => 'Apagadas']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $clave => $etiqueta): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <button type="button" wire:click="$set('estado', '<?php echo e($clave); ?>')"
                        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' => $estado === $clave,
                            'background:transparent; color:var(--text-muted)' => $estado !== $clave,
                        ]) ?>">
                    <?php echo e($etiqueta); ?>

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

        <div class="flex flex-none items-center gap-2">
            <span class="text-[11px] font-semibold uppercase tracking-[0.04em]" style="color:var(--text-subtle);">
                Producto
            </span>
            <select wire:model.live="producto"
                    class="rounded-lg border py-1.5 pl-2.5 pr-9 text-[12.5px] font-semibold focus:ring-0"
                    style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                <option value="">Todos</option>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $productos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($p->id); ?>"><?php echo e($p->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </select>
        </div>

        <button type="button" wire:click="$toggle('soloPronto')"
                class="flex-none rounded-full border px-[11px] py-1 text-[12px] font-semibold transition-colors"
                style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                    'border-color:var(--warning-500); background:var(--warning-50); color:var(--warning-500)' => $soloPronto,
                    'border-color:var(--border-default); background:var(--surface-page); color:var(--text-muted)' => ! $soloPronto,
                ]) ?>">
            Caduca en ≤ 30 días<?php echo e($resumen['pronto'] > 0 ? ' (' . $resumen['pronto'] . ')' : ''); ?>

        </button>

        
        <button type="button" wire:click="$toggle('soloSinEntornos')"
                class="flex-none rounded-full border px-[11px] py-1 text-[12px] font-semibold transition-colors"
                style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                    'border-color:var(--orange-500); background:var(--surface-brand-subtle); color:var(--orange-600)' => $soloSinEntornos,
                    'border-color:var(--border-default); background:var(--surface-page); color:var(--text-muted)' => ! $soloSinEntornos,
                ]) ?>">
            Sin ningún entorno<?php echo e($resumen['sinUso'] > 0 ? ' (' . $resumen['sinUso'] . ')' : ''); ?>

        </button>

        <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($tokens->total()); ?></strong>
                de <?php echo e($resumen['total']); ?>

            </span>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hayFiltros): ?>
                <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>

    
    <div class="overflow-hidden rounded-xl border"
         style="background:var(--surface-card); border-color:var(--border-subtle);">

        <div class="lic-grid hidden border-b py-2 pl-[17px] pr-5 text-[11px] font-semibold uppercase tracking-[0.06em] lg:grid"
             style="color:var(--text-muted); border-color:var(--divider);">
            <span>Licencia</span>
            <span>Cliente</span>
            <span>Vigencia</span>
            <span>Productos</span>
            <span>Entornos</span>
            <span></span>
        </div>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $tokens; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $token): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <?php
                // El estado del modelo tiene cuatro valores y el diseño tres: «vence
                // pronto» no es un estado, es un aviso sobre una licencia activa. Se
                // traduce aquí y no en el modelo, que es el que usan las otras dos
                // pantallas.
                $estadoToken = $token->estado();
                $apagada = $estadoToken === 'desactivada';
                $caducada = $estadoToken === 'vencida';
                $pronto = $estadoToken === 'pronto';

                $dias = $token->end_at
                    ? (int) now()->startOfDay()->diffInDays($token->end_at->copy()->startOfDay(), false)
                    : null;

                // La franja de la izquierda: lo que está mal se ve antes de leer.
                $franja = match (true) {
                    $apagada => 'var(--neutral-700)',
                    $caducada => 'var(--danger-500)',
                    $pronto => 'var(--warning-500)',
                    default => 'transparent',
                };
            ?>

            <div class="lic-grid items-center border-b transition-colors hover:bg-[var(--surface-alt)]"
                 style="border-color:var(--divider); border-left:3px solid <?php echo e($franja); ?>; padding:9px 20px 9px 14px;"
                 x-data="{ copiado: false }">

                
                <div class="min-w-0">
                    <div class="flex min-w-0 items-center gap-2">
                        <a href="<?php echo e(route('license_tokens.show', $token)); ?>" wire:navigate
                           class="truncate text-[13.5px] font-semibold" style="color:var(--text-strong);">
                            <?php echo e($token->name ?: 'Sin nombre'); ?>

                        </a>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($apagada): ?>
                            <span class="flex-none rounded-full px-2 py-px text-[10.5px] font-semibold"
                                  style="color:#fff; background:var(--neutral-700);">Apagada</span>
                        <?php elseif($caducada): ?>
                            <span class="flex-none rounded-full px-2 py-px text-[10.5px] font-semibold"
                                  style="color:var(--danger-500); background:var(--danger-50);">Caducada</span>
                        <?php else: ?>
                            <span class="flex-none rounded-full px-2 py-px text-[10.5px] font-semibold"
                                  style="color:var(--success-500); background:var(--success-50);">Activa</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>

                    <div class="mt-0.5 flex items-center gap-1.5">
                        <span class="truncate rounded px-2 py-px font-mono text-[11.5px]"
                              style="color:var(--text-muted); background:var(--surface-sunken);"
                              title="El token completo está en la ficha de la licencia y en el botón de copiar, no en esta lista.">
                            <?php echo e($token->token_corto); ?>

                        </span>
                        <button type="button" title="Copiar el token completo"
                                @click="copiarAlPortapapeles('<?php echo e($token->token); ?>').then(ok => { if (ok) { copiado = true; setTimeout(() => copiado = false, 1500) } })"
                                class="flex flex-none border-none bg-transparent p-0.5" style="color:var(--text-subtle);">
                            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
                        </button>
                        <span x-show="copiado" x-cloak class="flex-none text-[11px] font-semibold" style="color:var(--success-500);">
                            Copiado
                        </span>
                    </div>
                </div>

                
                <span class="truncate text-[12.5px]" style="color:var(--text-body);">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($token->client): ?>
                        <a href="<?php echo e(route('clients.show', $token->client)); ?>" wire:navigate style="color:var(--text-body);">
                            <?php echo e($token->client->name); ?>

                        </a>
                    <?php else: ?>
                        <span style="color:var(--text-subtle);">Sin cliente</span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </span>

                
                <div class="min-w-0 text-[12.5px]">
                    <div style="color:var(--text-body);">
                        <?php echo e($token->start_at?->format('d/m/Y') ?? '—'); ?>

                        –
                        <?php echo e($token->end_at?->format('d/m/Y') ?? 'sin caducidad'); ?>

                    </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($caducada): ?>
                        <div class="mt-px text-[11.5px] font-semibold" style="color:var(--danger-500);">
                            Caducó hace <?php echo e(abs($dias)); ?> día(s)
                        </div>
                    <?php elseif($pronto): ?>
                        <div class="mt-px text-[11.5px] font-semibold" style="color:var(--warning-500);">
                            Caduca en <?php echo e($dias); ?> día(s)
                        </div>
                    <?php elseif($apagada): ?>
                        <div class="mt-px text-[11.5px] font-semibold" style="color:var(--text-muted);">
                            Apagada a mano
                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                
                <?php if (isset($component)) { $__componentOriginal8685aa302c3ddaba5d15945e3d14b127 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8685aa302c3ddaba5d15945e3d14b127 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.product-icons','data' => ['products' => $token->products,'empty' => 'Ninguno']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('product-icons'); ?>
<?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(['products' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($token->products),'empty' => 'Ninguno']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8685aa302c3ddaba5d15945e3d14b127)): ?>
<?php $attributes = $__attributesOriginal8685aa302c3ddaba5d15945e3d14b127; ?>
<?php unset($__attributesOriginal8685aa302c3ddaba5d15945e3d14b127); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8685aa302c3ddaba5d15945e3d14b127)): ?>
<?php $component = $__componentOriginal8685aa302c3ddaba5d15945e3d14b127; ?>
<?php unset($__componentOriginal8685aa302c3ddaba5d15945e3d14b127); ?>
<?php endif; ?>

                
                <div class="text-[12.5px]">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($token->environments_count > 0): ?>
                        <span class="font-semibold" style="color:var(--text-strong);"><?php echo e($token->environments_count); ?></span>
                    <?php else: ?>
                        <span class="rounded-full px-2 py-px text-[11px] font-semibold"
                              style="color:var(--warning-500); background:var(--warning-50);"
                              title="Ningún entorno usa esta licencia: un contrato que nadie ha instalado">
                            Sin uso
                        </span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <a href="<?php echo e(route('license_tokens.show', $token)); ?>" wire:navigate
                   class="hidden justify-self-end lg:block" title="Ver la licencia">
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="var(--text-subtle)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>
                </a>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="px-6 py-8 text-center text-[13px]" style="color:var(--text-muted);">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hayFiltros): ?>
                    Ninguna licencia 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: ?>
                    Ninguna licencia 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; ?>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($tokens->hasPages()): ?>
            <div class="px-5 py-2.5"><?php echo e($tokens->links()); ?></div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>
</div><?php /**PATH /var/www/html/resources/views/livewire/license-tokens/index.blade.php ENDPATH**/ ?>