<div>
    
    
    <?php if (isset($component)) { $__componentOriginal2544aeb3df80db4e8cf42f27632fe7f3 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal2544aeb3df80db4e8cf42f27632fe7f3 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.cabecera','data' => ['rotulo' => 'Monitorización','titulo' => 'Peticiones API','descripcion' => 'Cada llamada que los Moodle de los clientes hacen al Manager: qué pidieron, qué se les respondió y cuánto tardó. Es donde se comprueba si un sitio está recibiendo su licencia y su contenido, y por qué no si algo falla. Se guarda una fila por petición y el histórico se recorta según la retención configurada.']] + (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' => 'Monitorización','titulo' => 'Peticiones API','descripcion' => 'Cada llamada que los Moodle de los clientes hacen al Manager: qué pidieron, qué se les respondió y cuánto tardó. Es donde se comprueba si un sitio está recibiendo su licencia y su contenido, y por qué no si algo falla. Se guarda una fila por petición y el histórico se recorta según la retención configurada.']); ?>

         <?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' => 'clipboard','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' => 'clipboard','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 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; ?>

    
    <div class="w-full mt-4 mb-8">
        <?php echo $__env->make('livewire.monitoring.components.menu', ['selected' => 'logs'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>

    
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = [
        ['success', 'var(--success-500)', 'var(--success-50)'],
        ['warning', 'var(--warning-500)', 'var(--warning-50)'],
        ['error', 'var(--danger-500)', 'var(--danger-50)'],
        ['info', 'var(--info-500)', 'var(--info-50)'],
    ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$clave, $color, $fondo]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session($clave)): ?>
            <div class="mb-4 rounded-xl border px-4 py-3 text-[13px]"
                 style="border-color:<?php echo e($color); ?>; background:<?php echo e($fondo); ?>; color:var(--text-body);">
                <?php echo e(session($clave)); ?>

            </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    <?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(($indicadoresAgotados ?? false) || ($listadoAgotado ?? false)): ?>
        <div class="mb-6 rounded-xl border px-4 py-3.5"
             style="background:var(--warning-50); border-color:var(--warning-500);">
            <div class="flex items-start gap-3">
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--warning-500)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex:none; margin-top:1px;"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>
                <div class="min-w-0 text-[13px]" style="color:var(--text-body);">
                    <div class="font-semibold" style="color:var(--text-strong);">
                        <?php if(($indicadoresAgotados ?? false) && ($listadoAgotado ?? false)): ?>
                            La consulta tardaba demasiado y se ha cortado
                        <?php elseif($listadoAgotado ?? false): ?>
                            El listado tardaba demasiado y se ha cortado
                        <?php else: ?>
                            Los indicadores tardaban demasiado y se han cortado
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                    <div class="mt-0.5" style="color:var(--text-muted);">
                        Se corta a los <?php echo e($topeSegundos ?? 8); ?> segundos para que la pantalla se pueda usar en vez de
                        quedarse pensando. Esta tabla es la que más crece del sistema:
                        
                        <strong>acota el rango de fechas</strong>
                        o quita los filtros de texto —IP, identificador de petición, dominio—, que son
                        los que no aprovechan ningún índice.
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(! ($indicadoresAgotados ?? false) && ($listadoAgotado ?? false)): ?>
                            Los indicadores de arriba sí han llegado, y son del mismo rango.
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <div class="space-y-6">
        
        <div class="bg-white rounded-2xl border border-gray-200 shadow-sm overflow-hidden" x-data="{ filtersOpen: false }">
            <div class="px-5 py-4 border-b border-gray-100 bg-gray-50/50 cursor-pointer hover:bg-gray-50/70 transition-colors"
                 role="button"
                 tabindex="0"
                 @click="filtersOpen = ! filtersOpen"
                 @keydown.enter.prevent="filtersOpen = ! filtersOpen"
                 @keydown.space.prevent="filtersOpen = ! filtersOpen"
                 x-bind:aria-expanded="filtersOpen">
                <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-3">
                    <h2 class="text-sm font-semibold text-gray-800 flex items-center gap-2">
                        <span class="w-8 h-8 rounded-lg bg-gray-200 flex items-center justify-center">
                            <svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"/></svg>
                        </span>
                        Filtros
                        <?php $counts = $this->appliedFiltersCounts; ?>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($counts['total'] > 0): ?>
                            <span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full text-xs font-semibold bg-orange-100 text-orange-800"><?php echo e($counts['total']); ?></span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                        <svg class="w-4 h-4 text-gray-500 transition-transform ml-1" :class="filtersOpen ? '-rotate-90' : 'rotate-90'" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/></svg>
                    </h2>
                    <div class="flex flex-wrap items-center gap-3" @click.stop>
                        <div class="flex flex-wrap items-center gap-2">
                            <select wire:model.live="rangePreset" class="rounded-xl border-2 border-gray-200 pl-4 pr-10 py-2.5 text-sm font-medium text-gray-700 focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400 transition-shadow">
                                <option value="24h">Últimas 24 h</option>
                                <option value="7d">Últimos 7 días</option>
                                <option value="30d">Últimos 30 días</option>
                                <option value="custom">Personalizado</option>
                            </select>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($rangePreset === 'custom'): ?>
                                <input type="datetime-local" wire:model.live="dateFrom" class="rounded-xl border-2 border-gray-200 px-3 py-2.5 text-xs md:text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                                <span class="text-gray-500 text-xs md:text-sm">hasta</span>
                                <input type="datetime-local" wire:model.live="dateTo" class="rounded-xl border-2 border-gray-200 px-3 py-2.5 text-xs md:text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                        <div class="flex flex-wrap items-center gap-2">
                            <button type="button" wire:click="resetFilters"
                                class="inline-flex items-center gap-2 rounded-lg border-2 border-gray-200 px-4 py-2.5 text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 hover:border-gray-300 transition-colors">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
                                Limpiar filtros
                            </button>

                            
                            <button type="button"
                                    x-data="{ copiado: false }"
                                    @click="navigator.clipboard?.writeText(window.location.href).then(() => { copiado = true; setTimeout(() => copiado = false, 1500) })"
                                    title="Los filtros van en la URL: el enlace reproduce esta búsqueda"
                                    class="inline-flex items-center gap-2 rounded-lg border-2 border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 010 5.656l-1.415 1.415a4 4 0 01-5.656-5.657l1.414-1.414M10.172 13.828a4 4 0 010-5.656l1.415-1.415a4 4 0 015.656 5.657l-1.414 1.414"/></svg>
                                <span x-text="copiado ? 'Enlace copiado' : 'Copiar enlace'">Copiar enlace</span>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div x-show="filtersOpen" x-collapse class="p-5 space-y-6">
                
                <div class="rounded-xl border border-gray-200 bg-gray-50/30 p-4">
                    <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 flex items-center gap-2">
                        <svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/></svg>
                        Cliente y entorno
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($counts['cliente_entorno'] > 0): ?>
                            <span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full text-xs font-semibold bg-orange-100 text-orange-800"><?php echo e($counts['cliente_entorno']); ?></span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                        
                        <div x-data="{ abierto: false }" @click.outside="abierto = false" class="relative">
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Cliente</label>

                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($cliente = $this->clienteElegido()): ?>
                                <button type="button" wire:click="elegirCliente(null)"
                                        title="Quitar el filtro de cliente"
                                        class="flex w-full items-center justify-between gap-2 rounded-xl border-2 border-orange-300 bg-orange-50 px-3 py-2.5 text-sm text-left">
                                    <span class="truncate font-medium text-orange-800"><?php echo e($cliente->name); ?></span>
                                    <svg class="w-4 h-4 flex-none text-orange-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
                                </button>
                            <?php else: ?>
                                <div class="flex items-center gap-2 rounded-xl border-2 border-gray-200 px-3 py-2.5 focus-within:ring-2 focus-within:ring-orange-300 focus-within:border-orange-400">
                                    <svg class="w-4 h-4 flex-none text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 21-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z"/></svg>
                                    <input type="text" wire:model.live.debounce.300ms="clientSearch"
                                           @focus="abierto = true" x-on:input="abierto = true"
                                           placeholder="Todos — escribe para buscar"
                                           class="min-w-0 flex-1 border-none bg-transparent p-0 text-sm focus:ring-0">
                                    <div wire:loading wire:target="clientSearch" class="flex-none">
                                        <svg class="w-3.5 h-3.5 animate-spin text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2"><path d="M21 12a9 9 0 1 1-6.22-8.56"/></svg>
                                    </div>
                                </div>

                                <?php $clientes = $this->sugerenciasDeClientes(); ?>

                                <div x-show="abierto" x-cloak
                                     class="absolute left-0 right-0 top-full z-30 mt-1 max-h-64 overflow-y-auto rounded-xl border-2 border-gray-200 bg-white p-1 shadow-lg">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $clientes['filas']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <button type="button" wire:click="elegirCliente(<?php echo e($c->id); ?>)" @click="abierto = false"
                                                class="block w-full truncate rounded-lg px-2.5 py-1.5 text-left text-sm hover:bg-orange-50">
                                            <?php echo e($c->name); ?>

                                        </button>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <p class="px-2.5 py-2 text-xs text-gray-500">
                                            Ningún cliente coincide con «<?php echo e(trim($clientSearch)); ?>».
                                        </p>
                                    <?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($clientes['total'] > $clientes['filas']->count()): ?>
                                        <p class="border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-500">
                                            y <?php echo e($clientes['total'] - $clientes['filas']->count()); ?> más — escribe para acotar
                                        </p>
                                    <?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>

                        
                        <div x-data="{ abierto: false }" @click.outside="abierto = false" class="relative">
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Sitio (entorno)</label>

                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($entorno = $this->entornoElegido()): ?>
                                <button type="button" wire:click="elegirEntorno(null)"
                                        title="Quitar el filtro de sitio"
                                        class="flex w-full items-center justify-between gap-2 rounded-xl border-2 border-orange-300 bg-orange-50 px-3 py-2.5 text-sm text-left">
                                    <span class="truncate font-medium text-orange-800">
                                        <?php echo e($entorno->name); ?>

                                        
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if (! ($entorno->active)): ?>
                                            <span class="font-normal text-orange-700">— apagado</span>
                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </span>
                                    <svg class="w-4 h-4 flex-none text-orange-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
                                </button>
                            <?php else: ?>
                                <div class="flex items-center gap-2 rounded-xl border-2 border-gray-200 px-3 py-2.5 focus-within:ring-2 focus-within:ring-orange-300 focus-within:border-orange-400">
                                    <svg class="w-4 h-4 flex-none text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 21-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z"/></svg>
                                    <input type="text" wire:model.live.debounce.300ms="environmentSearch"
                                           @focus="abierto = true" x-on:input="abierto = true"
                                           placeholder="Todos — nombre o dominio"
                                           class="min-w-0 flex-1 border-none bg-transparent p-0 text-sm focus:ring-0">
                                    <div wire:loading wire:target="environmentSearch" class="flex-none">
                                        <svg class="w-3.5 h-3.5 animate-spin text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2"><path d="M21 12a9 9 0 1 1-6.22-8.56"/></svg>
                                    </div>
                                </div>

                                <?php $entornos = $this->sugerenciasDeEntornos(); ?>

                                <div x-show="abierto" x-cloak
                                     class="absolute left-0 right-0 top-full z-30 mt-1 max-h-64 overflow-y-auto rounded-xl border-2 border-gray-200 bg-white p-1 shadow-lg">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $entornos['filas']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <button type="button" wire:click="elegirEntorno(<?php echo e($e->id); ?>)" @click="abierto = false"
                                                class="block w-full rounded-lg px-2.5 py-1.5 text-left hover:bg-orange-50">
                                            <span class="block truncate text-sm">
                                                <?php echo e($e->name); ?>

                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if (! ($e->active)): ?>
                                                    <span class="ms-1 rounded bg-gray-100 px-1.5 py-0.5 text-[10.5px] font-semibold uppercase tracking-wide text-gray-500">apagado</span>
                                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                            </span>
                                            <span class="block truncate font-mono text-[11px] text-gray-500"><?php echo e($e->domain); ?></span>
                                        </button>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <p class="px-2.5 py-2 text-xs text-gray-500">
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($this->clientId): ?>
                                                Este cliente no tiene ningún sitio que coincida con «<?php echo e(trim($environmentSearch)); ?>».
                                            <?php else: ?>
                                                Ningún sitio coincide con «<?php echo e(trim($environmentSearch)); ?>».
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </p>
                                    <?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($entornos['total'] > $entornos['filas']->count()): ?>
                                        <p class="border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-500">
                                            y <?php echo e($entornos['total'] - $entornos['filas']->count()); ?> más — escribe para acotar
                                        </p>
                                    <?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>
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Token licencia (ID)</label>
                            <input type="number" wire:model.live.debounce.300ms="licenseTokenId" placeholder="ID"
                                class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                        </div>
                        <div class="flex items-end">
                            <label class="flex items-center gap-2.5 cursor-pointer rounded-xl border-2 border-gray-200 px-4 py-2.5 w-full hover:bg-gray-50 transition-colors">
                                <input type="checkbox" wire:model.live="onlyWithoutEnvironment" class="rounded border-gray-300 text-orange-600 focus:ring-orange-300">
                                <span class="text-sm font-medium text-gray-700">Solo peticiones sin sitio reconocido</span>
                            </label>
                        </div>
                        
                        <div class="flex items-end">
                            <label class="flex items-center gap-2.5 cursor-pointer rounded-xl border-2 px-4 py-2.5 w-full transition-colors <?php echo e($incluirApagados ? 'border-amber-300 bg-amber-50' : 'border-gray-200 hover:bg-gray-50'); ?>">
                                <input type="checkbox" wire:model.live="incluirApagados" class="rounded border-gray-300 text-orange-600 focus:ring-orange-300">
                                <span class="text-sm font-medium text-gray-700">
                                    Incluir entornos apagados
                                    <span class="block text-xs font-normal text-gray-500">
                                        Por defecto no se cuentan: ya no están en servicio
                                    </span>
                                </span>
                            </label>
                        </div>
                        
                        <div x-data="{ abierto: false }" @click.outside="abierto = false"
                             class="relative md:col-span-2 lg:col-span-2">
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">
                                Host que llama
                                <span class="font-normal text-gray-400">— incluidos los que no son de ningún entorno</span>
                            </label>

                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($host): ?>
                                <button type="button" wire:click="clearHostFilter"
                                        title="Quitar el filtro de host"
                                        class="flex w-full items-center justify-between gap-2 rounded-xl border-2 border-amber-300 bg-amber-50 px-3 py-2.5 text-left">
                                    <span class="truncate font-mono text-sm font-medium text-amber-800"><?php echo e($host); ?></span>
                                    <svg class="w-4 h-4 flex-none text-amber-700" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
                                </button>
                            <?php else: ?>
                                <div class="flex items-center gap-2 rounded-xl border-2 border-gray-200 px-3 py-2.5 focus-within:ring-2 focus-within:ring-orange-300 focus-within:border-orange-400">
                                    <svg class="w-4 h-4 flex-none text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 21-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z"/></svg>
                                    <input type="text" wire:model.live.debounce.300ms="hostSearch"
                                           @focus="abierto = true" x-on:input="abierto = true"
                                           placeholder="Cualquiera — escribe un dominio"
                                           class="min-w-0 flex-1 border-none bg-transparent p-0 font-mono text-sm focus:ring-0">
                                    <div wire:loading wire:target="hostSearch" class="flex-none">
                                        <svg class="w-3.5 h-3.5 animate-spin text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="2"><path d="M21 12a9 9 0 1 1-6.22-8.56"/></svg>
                                    </div>
                                </div>

                                <?php $hosts = $this->sugerenciasDeHosts(); ?>

                                <div x-show="abierto" x-cloak
                                     class="absolute left-0 right-0 top-full z-30 mt-1 max-h-64 overflow-y-auto rounded-xl border-2 border-gray-200 bg-white p-1 shadow-lg">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $hosts['filas']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <button type="button" wire:click="elegirHost(<?php echo \Illuminate\Support\Js::from($h->host)->toHtml() ?>)" @click="abierto = false"
                                                class="flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left hover:bg-orange-50">
                                            <span class="min-w-0 flex-1">
                                                <span class="block truncate font-mono text-[12.5px]"><?php echo e($h->host); ?></span>
                                                
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($h->sin_entorno > 0): ?>
                                                    <span class="mt-0.5 inline-flex items-center gap-1 rounded bg-amber-100 px-1.5 py-0.5 text-[10.5px] font-semibold text-amber-800">
                                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($h->sin_entorno == $h->peticiones): ?>
                                                            ningún entorno responde a este host
                                                        <?php else: ?>
                                                            <?php echo e($h->sin_entorno); ?> sin entorno reconocido
                                                        <?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; ?>
                                            </span>
                                            <span class="flex-none text-[11px] text-gray-500"><?php echo e($h->peticiones); ?></span>
                                        </button>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <p class="px-2.5 py-2 text-xs text-gray-500">
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(trim($hostSearch) !== ''): ?>
                                                Ningún host que coincida con «<?php echo e(trim($hostSearch)); ?>» ha llamado en este rango de fechas. Amplíalo si buscas algo más antiguo.
                                            <?php else: ?>
                                                Ningún host ha llamado en este rango de fechas.
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </p>
                                    <?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($hosts['total'] > $hosts['filas']->count()): ?>
                                        <p class="border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-500">
                                            y <?php echo e($hosts['total'] - $hosts['filas']->count()); ?> más — escribe para acotar
                                        </p>
                                    <?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>
                    </div>
                </div>

                
                <div class="rounded-xl border border-gray-200 bg-gray-50/30 p-4">
                    <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 flex items-center gap-2">
                        <svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
                        Petición y respuesta
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($counts['peticion_respuesta'] > 0): ?>
                            <span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full text-xs font-semibold bg-orange-100 text-orange-800"><?php echo e($counts['peticion_respuesta']); ?></span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Action</label>
                            <select wire:model.live="action" class="w-full rounded-xl border-2 border-gray-200 pl-3 pr-10 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                                <option value="">— Todas —</option>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $actionOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($val); ?>"><?php echo e($label); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </select>
                        </div>
                        <div class="md:col-span-2 lg:col-span-3">
                            <label class="block text-xs font-medium text-gray-500 mb-2">Estados HTTP</label>
                            <div class="flex flex-wrap gap-2">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = [200,400,401,403,404,422,429,500]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <label class="inline-flex items-center gap-1.5 rounded-full border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700 bg-white hover:bg-gray-50 cursor-pointer">
                                        <input type="checkbox" value="<?php echo e($status); ?>" wire:model.live="httpStatuses" class="rounded border-gray-300 text-orange-600 focus:ring-orange-300">
                                        <span><?php echo e($status); ?></span>
                                    </label>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </div>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Duración (ms) min / max</label>
                            <div class="flex gap-2">
                                <input type="number" wire:model.live.debounce.300ms="durationMin" placeholder="min" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                                <input type="number" wire:model.live.debounce.300ms="durationMax" placeholder="max" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                            </div>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Tamaño respuesta (bytes)</label>
                            <div class="flex gap-2">
                                <input type="number" wire:model.live.debounce.300ms="responseSizeMin" placeholder="min" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                                <input type="number" wire:model.live.debounce.300ms="responseSizeMax" placeholder="max" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                            </div>
                        </div>
                    </div>
                </div>

                
                <div class="rounded-xl border border-gray-200 bg-gray-50/30 p-4">
                    <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 flex items-center gap-2">
                        <svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/></svg>
                        Filtros avanzados
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($counts['avanzados'] > 0): ?>
                            <span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full text-xs font-semibold bg-orange-100 text-orange-800"><?php echo e($counts['avanzados']); ?></span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        
                        <span class="ms-1 text-[11px] font-semibold normal-case tracking-normal" style="color:var(--warning-500);">
                            no aprovechan índices: acota antes el rango de fechas o irán lentos
                        </span>
                    </h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">IP</label>
                            <input type="text" wire:model.live.debounce.300ms="ip" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-gray-500 mb-1.5">Request UUID</label>
                            <input type="text" wire:model.live.debounce.300ms="requestUuid" placeholder="UUID" class="w-full rounded-xl border-2 border-gray-200 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-400">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        
        <?php
            $tonoVeredicto = [
                'ok' => ['dot' => 'var(--success-500)', 'texto' => 'var(--text-strong)'],
                'aviso' => ['dot' => 'var(--warning-500)', 'texto' => 'var(--text-strong)'],
                'malo' => ['dot' => 'var(--danger-500)', 'texto' => 'var(--danger-500)'],
            ][$veredicto['tono']];

            $n = fn ($v) => number_format((int) $v, 0, ',', '.');
        ?>

        <section class="overflow-hidden rounded-xl border"
                 style="background:var(--surface-card); border-color:var(--border-subtle);">
            <div class="flex flex-wrap items-start gap-3 px-6 pb-3.5 pt-4">
                <span class="mt-[5px] h-[11px] w-[11px] flex-none rounded-full" style="background:<?php echo e($tonoVeredicto['dot']); ?>;"></span>
                <div class="min-w-0">
                    <h1 style="font-family:'Plus Jakarta Sans',sans-serif; font-size:19px; font-weight:700; letter-spacing:-0.01em; color:<?php echo e($tonoVeredicto['texto']); ?>; margin:0;">
                        <?php echo e($veredicto['titulo']); ?>

                    </h1>
                    <div class="mt-[3px] max-w-[720px] text-[12.5px] leading-relaxed" style="color:var(--text-muted);">
                        <?php echo e($veredicto['detalle']); ?>

                    </div>
                </div>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($errores > 0): ?>
                    
                    <button type="button" wire:click="filtrarPorSeveridad('error')"
                            class="ms-auto flex-none rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                            style="border-color:var(--danger-500); background:var(--danger-50); color:var(--danger-500);">
                        Ver solo los errores
                    </button>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(($apagadosOcultos ?? 0) > 0): ?>
                <div class="flex flex-wrap items-center gap-2 border-t px-6 py-2 text-[12px]"
                     style="border-color:var(--divider); background:var(--surface-alt); color:var(--text-subtle);">
                    <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">
                        <path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.53 13.53 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>
                    </svg>
                    <span>
                        <strong style="color:var(--text-body);"><?php echo e($n($apagadosOcultos)); ?></strong>
                        <?php echo e($apagadosOcultos === 1 ? 'petición' : 'peticiones'); ?> de entornos apagados
                        no se están contando
                    </span>
                    <button type="button" wire:click="$set('incluirApagados', true)"
                            class="border-none bg-transparent p-0 font-semibold hover:underline"
                            style="color:var(--text-link);">
                        incluirlas
                    </button>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="grid grid-cols-1 border-t sm:grid-cols-2 lg:grid-cols-5" style="border-color:var(--divider);">
                
                <div class="border-b px-5 py-3 sm:border-e lg:border-b-0" style="border-color:var(--divider);">
                    <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">Errores de verdad</div>
                    
                    <div class="mt-0.5" style="font-family:'Plus Jakarta Sans',sans-serif; font-size:24px; font-weight:700; color:<?php echo e($erroresSinRevisar > 0 ? 'var(--danger-500)' : 'var(--success-500)'); ?>;">
                        <?php echo e($n($erroresSinRevisar)); ?>

                    </div>
                    <div class="text-[11px]" style="color:var(--text-subtle);">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($errores > $erroresSinRevisar): ?>
                            de <?php echo e($n($errores)); ?> · <?php echo e($n($errores - $erroresSinRevisar)); ?> ya vistos
                        <?php else: ?>
                            el objetivo es cero
                        <?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($prevErrores !== null && $prevErrores !== $errores): ?>
                            · antes <?php echo e($n($prevErrores)); ?>

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

                
                <div class="border-b px-5 py-3 sm:border-e-0 lg:border-b-0 lg:border-e" style="border-color:var(--divider);">
                    <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">Peticiones</div>
                    <div class="mt-0.5" style="font-family:'Plus Jakarta Sans',sans-serif; font-size:24px; font-weight:700; color:var(--text-strong);">
                        <?php echo e($n($total)); ?>

                    </div>
                    <div class="mt-0.5 flex flex-wrap gap-2 text-[11px]" style="color:var(--text-muted);">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = [
                            ['ok', 'var(--success-500)', 'correctas'],
                            ['sin_contenido', 'var(--neutral-400)', 'sin contenido'],
                            ['negocio', 'var(--info-500)', 'no contratado'],
                        ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$clave, $color, $nombre]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(($porSeveridad[$clave] ?? 0) > 0): ?>
                                <span class="inline-flex items-center gap-1">
                                    <span class="h-[7px] w-[7px] flex-none rounded-full" style="background:<?php echo e($color); ?>;"></span>
                                    <?php echo e($n($porSeveridad[$clave])); ?> <?php echo e($nombre); ?>

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

                
                <div class="border-b px-5 py-3.5 sm:border-e lg:border-b-0" style="border-color:var(--divider);">
                    <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">Latencia</div>
                    <div class="mt-2 flex gap-6">
                        <div>
                            <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:22px; font-weight:700; color:var(--text-strong);">
                                <?php echo e($p50 !== null ? $n($p50) : '—'); ?> <span class="text-[12px] font-semibold" style="color:var(--text-muted);">ms</span>
                            </div>
                            <div class="mt-px text-[10.5px] font-semibold uppercase tracking-[0.05em]" style="color:var(--text-subtle);">P50 · mediana</div>
                        </div>
                        <div>
                            <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:22px; font-weight:700; color:var(--text-strong);">
                                <?php echo e($p95 !== null ? $n($p95) : '—'); ?> <span class="text-[12px] font-semibold" style="color:var(--text-muted);">ms</span>
                            </div>
                            <div class="mt-px text-[10.5px] font-semibold uppercase tracking-[0.05em]" style="color:var(--text-subtle);">P95 · las lentas</div>
                        </div>
                    </div>
                    <div class="mt-2.5 text-[11px]" style="color:var(--text-subtle);">Lo que tarda el Manager en responder</div>
                </div>

                
                <div class="border-b px-5 py-3 sm:border-e-0 lg:border-b-0 lg:border-e" style="border-color:var(--divider);">
                    <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">Top acciones</div>
                    <div class="mt-1.5 flex flex-col gap-0.5 text-[11.5px]">
                        
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $topActions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fila): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <?php $colorTop = \App\Support\ColorDeAccion::de($fila->action); ?>
                            <div class="flex items-center justify-between gap-2">
                                <span class="truncate rounded px-1.5 py-px font-mono font-semibold"
                                      style="color:<?php echo e($colorTop['texto']); ?>; background:<?php echo e($colorTop['fondo']); ?>;"><?php echo e($fila->action); ?></span>
                                <span class="flex-none" style="color:var(--text-muted);"><?php echo e($n($fila->c)); ?></span>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <span style="color:var(--text-muted);">—</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                </div>

                
                <div class="px-5 py-3">
                    <div class="text-[10.5px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">Sitios con errores</div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sitiosConErrores->isNotEmpty()): ?>
                        <div class="mt-1.5 flex flex-col gap-0.5 text-[11.5px]">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $sitiosConErrores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fila): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="flex items-center justify-between gap-2">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fila['entorno'] && auth()->user()?->can('admin.environments.index')): ?>
                                        <a href="<?php echo e(route('environments.show', $fila['entorno'])); ?>" wire:navigate
                                           class="truncate font-semibold hover:underline" style="color:var(--text-link);"><?php echo e($fila['entorno']->name); ?></a>
                                    <?php else: ?>
                                        <span class="truncate" style="color:var(--text-body);" title="<?php echo e($fila['host']); ?>">
                                            <?php echo e($fila['entorno']->name ?? $fila['host'] ?? 'sin sitio'); ?>

                                        </span>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    <span class="flex flex-none items-center gap-1.5">
                                        <span class="font-bold" style="color:var(--danger-500);"><?php echo e($n($fila['errores'])); ?></span>

                                        
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(($fila['entorno'] || $fila['host']) && auth()->user()?->can('admin.api-logs.destroy')): ?>
                                            <button type="button"
                                                    <?php if($fila['entorno']): ?>
                                                        wire:click="openPurgeErroresDeSitioModal(<?php echo e($fila['entorno']->id); ?>)"
                                                    <?php else: ?>
                                                        wire:click="openPurgeErroresDeSitioModal(null, <?php echo \Illuminate\Support\Js::from($fila['host'])->toHtml() ?>)"
                                                    <?php endif; ?>
                                                    title="Borrar los errores de <?php echo e($fila['entorno']->name ?? $fila['host']); ?> en el rango visible"
                                                    class="flex-none rounded p-0.5 hover:bg-[var(--danger-50)]">
                                                <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--text-muted)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/></svg>
                                            </button>
                                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </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.5 text-[11.5px]" style="color:var(--text-muted);">Ninguno — nada que arreglar</div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </div>
        </section>
        
        <?php
            $etiquetasSev = \App\Services\Api\Severidad::ETIQUETAS;

            $tonoSev = [
                'ok' => ['texto' => 'var(--success-500)', 'fondo' => 'var(--success-50)'],
                'error' => ['texto' => 'var(--danger-500)', 'fondo' => 'var(--danger-50)'],
                'sin_contenido' => ['texto' => 'var(--neutral-600)', 'fondo' => 'var(--surface-sunken)'],
                'negocio' => ['texto' => 'var(--info-500)', 'fondo' => 'var(--info-50)'],
            ];

            // Una petición lenta se dice en la propia fila: es el dato que se busca cuando
            // la pregunta es «¿por qué va lenta la API?».
            $umbralLento = 1000;

            $chips = [
                [null, 'Todo', $total],
                ['error', 'Errores', $errores],
                ['sin_contenido', 'Sin contenido', $porSeveridad['sin_contenido'] ?? 0],
                ['negocio', 'No contratado', $porSeveridad['negocio'] ?? 0],
            ];
        ?>

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

            
            
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($porMotivo->isNotEmpty()): ?>

                <div class="border-b px-5 py-3.5" style="border-color:var(--divider);">
                    <div class="flex flex-wrap items-baseline justify-between gap-3">
                        <div class="text-[11px] font-semibold uppercase tracking-[0.06em]" style="color:var(--text-muted);">
                            Por qué falla
                        </div>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($reason): ?>
                            <button type="button" wire:click="filtrarPorMotivo(null)"
                                    class="border-none bg-transparent p-0 text-[12px] font-semibold hover:underline"
                                    style="color:var(--text-link);">
                                quitar el filtro de motivo
                            </button>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>

                    <div class="mt-2 flex flex-wrap gap-1.5">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $porMotivo; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $motivo => $cuantas): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php
                                $ficha = $catalogoDeMotivos[$motivo] ?? null;
                                $etiqueta = $ficha['etiqueta'] ?? 'Sin clasificar';
                                $puesto = $reason === $motivo;
                            ?>
                            
                            <button type="button" wire:click="filtrarPorMotivo('<?php echo e($motivo); ?>')"
                                    title="<?php echo e(($ficha['detalle'] ?? '')); ?>"
                                    class="flex items-center gap-2 rounded-lg border px-2.5 py-1.5 text-left text-[12px] transition-colors"
                                    style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                                        'border-color:var(--neutral-800); background:var(--neutral-800); color:#fff' => $puesto,
                                        'border-color:var(--border-default); background:var(--surface-page)' => ! $puesto,
                                    ]) ?>">
                                <span class="font-semibold" style="<?php echo e($puesto ? 'color:#fff;' : 'color:var(--text-body);'); ?>"><?php echo e($etiqueta); ?></span>
                                <span class="font-bold" style="<?php echo e($puesto ? 'color:#fff;' : 'color:var(--text-strong);'); ?>"><?php echo e($n($cuantas)); ?></span>
                            </button>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(($porMotivo['otro'] ?? 0) > 0): ?>
                        <p class="mt-2 text-[11.5px]" style="color:var(--text-subtle);">
                            Hay <?php echo e($n($porMotivo['otro'])); ?> sin clasificar: son respuestas que no encajan
                            en ningún motivo conocido. Si el número crece, hay una situación nueva que
                            merece su propio nombre.
                        </p>
                    <?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 class="flex flex-wrap items-center gap-1.5 border-b px-5 py-3" style="border-color:var(--divider);">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $chips; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$clave, $nombre, $cuantas]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php $puesto = $severity === $clave; ?>
                    <button type="button" wire:click="filtrarPorSeveridad(<?php echo e($clave === null ? 'null' : "'" . $clave . "'"); ?>)"
                            class="rounded-full border px-3 py-1 text-[12px] font-semibold transition-colors"
                            style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                                'border-color:var(--neutral-800); background:var(--neutral-800); color:#fff' => $puesto && $clave !== 'error',
                                'border-color:var(--danger-500); background:var(--danger-50); color:var(--danger-500)' => $puesto && $clave === 'error',
                                'border-color:var(--border-default); background:var(--surface-page); color:var(--text-muted)' => ! $puesto,
                            ]) ?>">
                        <?php echo e($nombre); ?> · <?php echo e(number_format((int) $cuantas, 0, ',', '.')); ?>

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

                
                <span class="mx-1 h-4 w-px" style="background:var(--divider);"></span>
                <button type="button" wire:click="$toggle('onlyUnreviewed')"
                        title="<?php echo e($onlyUnreviewed
                            ? 'Ahora se esconden las que alguien ya ha marcado como vistas. Pulsa para verlas también.'
                            : 'Ahora se ven también las que alguien ya ha marcado como vistas. Pulsa para esconderlas.'); ?>"
                        class="rounded-full border px-3 py-1 text-[12px] font-semibold transition-colors"
                        style="<?php echo \Illuminate\Support\Arr::toCssStyles([
                            'border-color:var(--neutral-800); background:var(--neutral-800); color:#fff' => $onlyUnreviewed,
                            'border-color:var(--border-default); background:var(--surface-page); color:var(--text-muted)' => ! $onlyUnreviewed,
                        ]) ?>">
                    
                    <?php
                        $etiquetaDeVistos = $onlyUnreviewed
                            ? 'Sin los vistos' . (($vistosOcultos ?? 0) > 0 ? ' · ' . $n($vistosOcultos) . ' escondidas' : '')
                            : 'Con los vistos';
                    ?>
                    <?php echo e($etiquetaDeVistos); ?>

                </button>

                
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($host): ?>
                    <button type="button" wire:click="clearHostFilter"
                            title="Quitar el filtro"
                            class="rounded-full border px-3 py-1 text-[12px] font-semibold"
                            style="border-color:var(--orange-500); background:var(--surface-brand-subtle); color:var(--orange-600);">
                        Host: <?php echo e(\Illuminate\Support\Str::limit($host, 28)); ?> ✕
                    </button>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                <span class="flex-1"></span>
                
                <span class="max-w-[520px] text-[11.5px] leading-relaxed" style="color:var(--text-subtle);">
                    <strong class="font-semibold">Sin contenido</strong> (no hay nada publicado para la versión que pide) y
                    <strong class="font-semibold">No contratado</strong> (su licencia no lo incluye, ha caducado, el cliente
                    está de baja o el sitio está apagado) son respuestas correctas: el único número que debe ser cero es
                    <strong class="font-semibold">Errores</strong>.
                </span>
            </div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($logs && count($logs) > 0): ?>
                <div class="overflow-x-auto">
                    <div class="min-w-[880px]">
                        <div class="grid grid-cols-[104px_minmax(0,1.5fr)_minmax(0,0.9fr)_minmax(0,1.4fr)_72px_150px] gap-3 border-b px-5 py-1.5 text-[11px] font-semibold uppercase tracking-[0.06em]"
                             style="border-color:var(--divider); color:var(--text-muted);">
                            <span>Cuándo</span><span>Sitio</span><span>Acción</span><span>Resultado</span><span>Dur.</span>
                            <span class="text-end">Acciones</span>
                        </div>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $logs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php
                                $tono = $tonoSev[$log->severity] ?? ['texto' => 'var(--text-muted)', 'fondo' => 'var(--surface-sunken)'];
                                $lenta = (int) $log->duration_ms >= $umbralLento;
                            ?>
                            
                            <div wire:click="openLogModal(<?php echo e($log->id); ?>)"
                                 class="grid cursor-pointer grid-cols-[104px_minmax(0,1.5fr)_minmax(0,0.9fr)_minmax(0,1.4fr)_72px_150px] items-center gap-3 border-b px-5 py-[7px] text-[12.5px] transition-colors"
                                 style="border-color:var(--divider);"
                                 onmouseover="this.style.background='var(--surface-alt)'"
                                 onmouseout="this.style.background=''">

                                <span class="font-mono text-[11.5px]" style="color:var(--text-muted);"
                                      title="<?php echo e($log->started_at?->format('d/m/Y H:i:s')); ?>">
                                    <?php echo e($log->started_at?->format('d/m H:i')); ?>

                                </span>

                                <div class="min-w-0">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->site && auth()->user()?->can('admin.environments.index')): ?>
                                        <a href="<?php echo e(route('environments.show', $log->site)); ?>" wire:navigate wire:click.stop
                                           class="block truncate font-semibold hover:underline" style="color:var(--text-strong);"><?php echo e($log->site->name); ?></a>
                                    <?php elseif($log->site): ?>
                                        <span class="block truncate font-semibold" style="color:var(--text-strong);"><?php echo e($log->site->name); ?></span>
                                    <?php else: ?>
                                        
                                        <span class="block truncate font-semibold" style="color:var(--warning-500);"
                                              title="Ningún entorno responde a este host: alta sin terminar o dominio cambiado">
                                            <?php echo e($log->host ?? 'sin sitio'); ?>

                                        </span>
                                    <?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($log->client && auth()->user()?->can('admin.clients.index')): ?>
                                        <a href="<?php echo e(route('clients.show', $log->client)); ?>" wire:navigate wire:click.stop
                                           class="block truncate text-[11px] hover:underline" style="color:var(--text-subtle);"><?php echo e($log->client->name); ?></a>
                                    <?php elseif($log->client): ?>
                                        <span class="block truncate text-[11px]" style="color:var(--text-subtle);"><?php echo e($log->client->name); ?></span>
                                    <?php else: ?>
                                        <span class="block truncate text-[11px]" style="color:var(--text-subtle);">sin cliente reconocido</span>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                                    
                                    <span class="block truncate font-mono text-[10.5px]"
                                          style="color:var(--text-subtle);"
                                          title="<?php echo e($log->ip ? 'Desde la IP ' . $log->ip : 'Sin IP registrada'); ?>">
                                        <?php echo e($log->ip ?? 'sin IP'); ?>

                                    </span>
                                </div>

                                
                                <?php $colorAccion = \App\Support\ColorDeAccion::de($log->action); ?>
                                <div class="flex min-w-0 items-center">
                                    <span class="truncate rounded px-2 py-0.5 font-mono text-[12px] font-semibold"
                                          style="color:<?php echo e($colorAccion['texto']); ?>; background:<?php echo e($colorAccion['fondo']); ?>;"
                                          <?php if($log->plugin): ?> title="La pide <?php echo e($log->plugin); ?>" <?php endif; ?>>
                                        <?php echo e($log->action ?? '—'); ?>

                                    </span>
                                </div>

                                
                                <div class="min-w-0 whitespace-nowrap">
                                    <span class="inline-block max-w-[72%] truncate rounded-full px-2.5 py-px align-middle text-[11px] font-semibold"
                                          style="color:<?php echo e($tono['texto']); ?>; background:<?php echo e($tono['fondo']); ?>; <?php echo e($log->reviewed_at ? 'opacity:0.55;' : ''); ?>"
                                          <?php if($log->error_code || $log->error): ?> title="<?php echo e(($log->error_code ? $log->error_code . ' – ' : '') . ($log->error ?? '')); ?>" <?php endif; ?>>
                                        <?php echo e($etiquetasSev[$log->severity] ?? $log->severity); ?>

                                    </span>
                                    <span class="ms-1.5 text-[10.5px]" style="color:var(--text-subtle);">
                                        <?php echo e($log->http_status); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((int) $log->error_code !== 0): ?> · <?php echo e($log->error_code); ?><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                    </span>

                                    
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->reason && $log->reason !== 'ninguno'): ?>
                                        <span class="ms-1 block truncate text-[10.5px]"
                                              style="color:var(--text-muted); <?php echo e($log->reviewed_at ? 'opacity:0.55;' : ''); ?>"
                                              title="<?php echo e(\App\Services\Api\Motivo::detalle($log->reason)); ?>">
                                            <?php echo e(\App\Services\Api\Motivo::etiqueta($log->reason)); ?>

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

                                <span class="font-mono text-[11.5px]"
                                      style="color:<?php echo e($lenta ? 'var(--danger-500)' : 'var(--text-body)'); ?>;"
                                      <?php if($lenta): ?> title="Por encima de <?php echo e(number_format($umbralLento, 0, ',', '.')); ?> ms" <?php endif; ?>>
                                    <?php echo e(number_format((int) $log->duration_ms, 0, ',', '.')); ?> ms
                                </span>

                                
                                <div class="flex items-center justify-end gap-1.5 whitespace-nowrap">
                                    <button type="button" wire:click.stop="openLogModal(<?php echo e($log->id); ?>)"
                                            class="rounded-md border px-2.5 py-1 text-[11.5px] font-semibold transition-colors"
                                            style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);"
                                            onmouseover="this.style.borderColor='var(--orange-500)'; this.style.color='var(--orange-600)'"
                                            onmouseout="this.style.borderColor='var(--border-default)'; this.style.color='var(--text-body)'">
                                        Detalle
                                    </button>

                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->environment_id || $log->host): ?>
                                        <button type="button" wire:click.stop="filterBySiteOrHost(<?php echo e($log->environment_id ?? 'null'); ?>, <?php echo e(json_encode($log->host ?? '')); ?>)"
                                                title="Ver solo las de este sitio"
                                                class="flex flex-none rounded-md p-1 transition-colors"
                                                style="color:var(--text-subtle);"
                                                onmouseover="this.style.background='var(--surface-sunken)'; this.style.color='var(--text-body)'"
                                                onmouseout="this.style.background=''; this.style.color='var(--text-subtle)'">
                                            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>
                                        </button>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                                    <button type="button" wire:click.stop="copyUuid(<?php echo e(json_encode($log->request_uuid)); ?>)"
                                            title="Copiar el identificador de la petición"
                                            class="flex flex-none rounded-md p-1 transition-colors"
                                            style="color:var(--text-subtle);"
                                            onmouseover="this.style.background='var(--surface-sunken)'; this.style.color='var(--text-body)'"
                                            onmouseout="this.style.background=''; this.style.color='var(--text-subtle)'">
                                        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 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>

                                    
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->severity !== 'ok'): ?>
                                        <button type="button" wire:click.stop="alternarRevision(<?php echo e($log->id); ?>)"
                                                title="<?php echo e($log->reviewed_at
                                                    ? 'Visto el ' . $log->reviewed_at->format('d/m/Y H:i') . ($log->reviewedBy ? ' por ' . $log->reviewedBy->name : '') . ' — pulsa para desmarcarlo'
                                                    : 'Marcar como visto: deja de contar en «sin revisar»'); ?>"
                                                class="flex flex-none rounded-md p-1 transition-colors"
                                                style="color:<?php echo e($log->reviewed_at ? 'var(--success-500)' : 'var(--text-subtle)'); ?>;"
                                                onmouseover="this.style.background='var(--surface-sunken)'"
                                                onmouseout="this.style.background=''">
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->reviewed_at): ?>
                                                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
                                            <?php else: ?>
                                                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m8.5 12 2.5 2.5 4.5-5"/></svg>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </button>
                                    <?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; ?>
                    </div>
                </div>

                <div class="border-t px-5 py-3" style="border-color:var(--divider);">
                    <?php echo e($logs->links('livewire.components.table-pagination')); ?>

                </div>
            <?php else: ?>
                
                <div class="px-6 py-10 text-center">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($listadoAgotado ?? false): ?>
                        <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:15px; font-weight:700; color:var(--text-strong);">
                            No se ha podido leer el listado a tiempo
                        </div>
                        <div class="mx-auto mt-1.5 max-w-[540px] text-[12.5px] leading-relaxed" style="color:var(--text-muted);">
                            Se corta a los <?php echo e($topeSegundos ?? 8); ?> segundos para que la pantalla se pueda usar.
                            Acota el rango de fechas o quita los filtros de texto —IP, identificador
                            de petición, dominio—, que son los que no aprovechan ningún índice.
                        </div>
                    <?php elseif($this->appliedFiltersCounts()['total'] > 0 || $severity !== null): ?>
                        <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:15px; font-weight:700; color:var(--text-strong);">
                            Nada con estos filtros
                        </div>
                        <div class="mx-auto mt-1.5 max-w-[540px] text-[12.5px] leading-relaxed" style="color:var(--text-muted);">
                            Hay <?php echo e(number_format((int) $total, 0, ',', '.')); ?> peticiones en el rango, pero ninguna
                            cumple los filtros puestos. Si buscas un sitio que no aparece nunca, puede
                            que no haya llamado: su ficha lo dice.
                        </div>
                        <button type="button" wire:click="resetFilters"
                                class="mt-3.5 rounded-lg border px-3.5 py-1.5 text-[13px] font-semibold"
                                style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                            Quitar los filtros
                        </button>
                    <?php else: ?>
                        <div style="font-family:'Plus Jakarta Sans',sans-serif; font-size:15px; font-weight:700; color:var(--text-strong);">
                            Sin peticiones en este rango
                        </div>
                        <div class="mx-auto mt-1.5 max-w-[540px] text-[12.5px] leading-relaxed" style="color:var(--text-muted);">
                            Ningún Moodle ha llamado en las fechas elegidas. Si esperabas peticiones de
                            un sitio concreto, comprueba que su plugin está instalado y configurado con
                            su dominio y su token.
                        </div>
                    <?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; ?>
        </section>

        
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.api-logs.destroy')): ?>
            <div class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-dashed px-5 py-3"
                 style="border-color:var(--border-default);">
                <span class="min-w-0 text-[12px] leading-relaxed" style="color:var(--text-subtle);">
                    <strong class="font-semibold" style="color:var(--text-muted);">Limpieza del histórico</strong>
                    — borra peticiones para siempre, por antigüedad, por rango de fechas o de un
                    sitio concreto. La retención automática vive en
                    <a href="<?php echo e(route('configurations.manager.index')); ?>" wire:navigate
                       class="font-semibold hover:underline" style="color:var(--text-link);">Ajustes del Manager</a>.
                </span>
                <button type="button" wire:click="abrirLimpieza"
                        class="flex-none rounded-lg border px-3 py-1.5 text-[12.5px] font-semibold"
                        style="border-color:var(--border-default); background:var(--surface-page); color:var(--danger-500);">
                    Abrir limpieza…
                </button>
            </div>
        <?php endif; ?>
    </div>

        <?php
        $__scriptKey = '1369237307-0';
        ob_start();
    ?>
    <script>
        // Comprobaba `navigator.clipboard` —bien— pero sin respaldo: por HTTP no hay
        // portapapeles moderno y el botón no hacía nada en silencio. El helper global
        // resuelve las dos cosas.
        $wire.on('copy-to-clipboard', (e) => {
            copiarAlPortapapeles(e.text);
        });
    </script>
        <?php
        $__output = ob_get_clean();

        \Livewire\store($this)->push('scripts', $__output, $__scriptKey)
    ?>
</div><?php /**PATH /var/www/html/resources/views/livewire/api-logs/index.blade.php ENDPATH**/ ?>