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

    <div class="px-5 pb-2.5 pt-3.5">
        <h2 style="font-family:'Plus Jakarta Sans',sans-serif; font-size:15px; font-weight:700; color:var(--text-strong); margin:0;">
            Qué recibe cada entorno
        </h2>
        <div class="mt-0.5 text-[12px]" style="color:var(--text-muted);">
            La API sirve la versión más alta que no supere el plugin instalado de cada sitio — no la
            última. «Le corresponde» es el cálculo; «Ha pedido» es lo que de verdad pasó, del registro
            de la API de los últimos 30 días.
        </div>
    </div>

    <div class="cnt-cli-grid border-b px-5 py-1.5 text-[11px] font-semibold uppercase tracking-[0.06em]"
         style="border-color:var(--divider); color:var(--text-muted);">
        <div>Entorno</div>
        <div>Plugin instalado</div>
        <div>Le corresponde</div>
        <div>Ha pedido</div>
    </div>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $porEntorno; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fila): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="cnt-cli-grid border-b px-5 py-2.5 text-[12.5px] hover:bg-[var(--surface-alt)]"
             style="border-color:var(--divider);">

            
            <div class="min-w-0">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['entorno'] === null): ?>
                    
                    <div class="font-semibold" style="color:var(--text-body);">
                        <?php echo e($fila['agrupados']); ?> <?php echo e($fila['agrupados'] === 1 ? 'entorno más con licencia' : 'entornos más con licencia'); ?>

                    </div>
                <?php else: ?>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.environments.index')): ?>
                        <a href="<?php echo e(route('environments.index', ['q' => $fila['entorno']->name])); ?>" wire:navigate
                           class="block truncate font-semibold" style="color:var(--text-strong);"><?php echo e($fila['entorno']->name); ?></a>
                    <?php else: ?>
                        <span class="block truncate font-semibold" style="color:var(--text-strong);"><?php echo e($fila['entorno']->name); ?></span>
                    <?php endif; ?>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['recibe'] === null): ?>
                        <div class="mt-px text-[11px]" style="color:var(--text-subtle);">
                            Su plugin es más antiguo que la versión más antigua: tiene que actualizarlo
                        </div>
                    <?php elseif($fila['peticiones'] === 0): ?>
                        <div class="mt-px text-[11px]" style="color:var(--text-subtle);">
                            Instalado y sin llamar — revisar su tarea programada
                        </div>
                    <?php elseif($fila['siempreFalla']): ?>
                        <div class="mt-px text-[11px]" style="color:var(--text-subtle);">
                            Pide y nunca ha recibido nada
                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            
            <div class="truncate text-[11.5px]" style="font-family:ui-monospace,monospace;
                 color:<?php echo e($fila['entorno'] === null ? 'var(--text-subtle)' : ($fila['recibe'] === null ? 'var(--danger-500)' : 'var(--text-body)')); ?>;">
                <?php echo e($fila['instalada'] ?? 'sin instalar'); ?>

            </div>

            
            <div class="min-w-0">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['entorno'] === null): ?>
                    <span class="text-[11.5px]" style="color:var(--text-subtle);">Nada</span>
                <?php elseif($fila['recibe'] !== null): ?>
                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(! empty($fila['recibeId']) && ! empty($ficha['rutaVer'])): ?>
                        <a href="<?php echo e(route($ficha['rutaVer'], [$product, $fila['recibeId']])); ?>" wire:navigate
                           class="truncate hover:underline"
                           style="font-family:ui-monospace,monospace; font-weight:700; color:var(--text-link);"><?php echo e($fila['recibe']); ?></a>
                    <?php else: ?>
                        <span class="truncate" style="font-family:ui-monospace,monospace; font-weight:700; color:var(--text-strong);"><?php echo e($fila['recibe']); ?></span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <?php else: ?>
                    
                    <span class="text-[11.5px] font-semibold" style="color:var(--danger-500);">
                        Error <?php echo e($ficha['error'] ?? '3002'); ?>

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

            
            <div class="min-w-0 text-[12px]">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['entorno'] === null): ?>
                    <span style="color:var(--text-subtle);">Nada — no piden y no da error</span>
                <?php elseif($fila['peticiones'] === 0): ?>
                    <span class="tip font-semibold"
                          data-tip="Plugin instalado y sin llamar: o su tarea programada no corre, o su versión no pide este contenido"
                          style="color:var(--warning-500);">
                        <span class="mr-[5px] inline-block h-[7px] w-[7px] rounded-full" style="background:var(--warning-500);"></span>
                        Nunca ha pedido
                    </span>
                <?php elseif($fila['siempreFalla']): ?>
                    <span class="font-semibold" style="color:var(--danger-500);">
                        <span class="mr-[5px] inline-block h-[7px] w-[7px] rounded-full" style="background:var(--danger-500);"></span>
                        <?php echo e($fila['peticiones']); ?> <?php echo e($fila['peticiones'] === 1 ? 'petición' : 'peticiones'); ?> ·
                        <?php echo e($fila['ultimoError'] ? 'error ' . $fila['ultimoError'] : 'todas con error'); ?> — nunca ha recibido nada
                    </span>
                <?php else: ?>
                    <span style="color:var(--text-body);">
                        <span class="mr-[5px] inline-block h-[7px] w-[7px] rounded-full" style="background:var(--success-500);"></span>
                        <?php echo e($fila['ultima']?->diffForHumans(['short' => true])); ?> ·
                        <?php echo e($fila['peticiones']); ?> <?php echo e($fila['peticiones'] === 1 ? 'petición' : 'peticiones'); ?>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['fallidas'] > 0): ?>
                            
                            <span style="color:var(--warning-500);">(<?php echo e($fila['fallidas']); ?> con error antes)</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </span>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?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($peticiones['agotado'] ?? false): ?>
        
        <div class="px-5 py-2.5 text-[12px]" style="color:var(--text-muted); background:var(--surface-alt);">
            No se ha podido leer el registro de peticiones a tiempo, así que la columna «Ha pedido»
            está vacía. El resto de la tabla es el cálculo y no depende de eso.
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</section><?php /**PATH /var/www/html/resources/views/livewire/products/contenido/por-entorno.blade.php ENDPATH**/ ?>