<div class="relative">
    <button wire:click="closeModal"
            class="absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors z-10"
            aria-label="Cerrar">
        <svg class="w-6 h-6" 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"></path>
        </svg>
    </button>

    <div class="p-6 space-y-4 text-lg font-semibold text-gray-900 pr-8 mb-4">
        Detalle del log
    </h2>

    <div class="space-y-6 max-h-[70vh] overflow-y-auto">
        <section class="rounded-xl bg-gray-50/80 p-4 border border-gray-100">
            <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3">Resumen</h3>
            <dl class="grid grid-cols-2 gap-x-4 gap-y-2.5 text-sm">
                <dt class="text-gray-500">started_at</dt><dd class="font-medium text-gray-900"><?php echo e($log->started_at?->format('Y-m-d H:i:s')); ?></dd>
                <dt class="text-gray-500">ended_at</dt><dd class="font-medium text-gray-900"><?php echo e($log->ended_at?->format('Y-m-d H:i:s')); ?></dd>
                <dt class="text-gray-500">duration_ms</dt><dd class="font-medium text-gray-900"><?php echo e($log->duration_ms); ?></dd>
                <dt class="text-gray-500">response_size</dt><dd class="font-medium text-gray-900"><?php echo e($log->response_size !== null ? number_format($log->response_size) : '—'); ?></dd>
                <dt class="text-gray-500">client_id</dt><dd class="font-medium text-gray-900"><?php echo e($log->client_id ?? '—'); ?> <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->client): ?> <span class="text-gray-500">(<?php echo e($log->client->name); ?>)</span> <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?></dd>
                <dt class="text-gray-500">environment_id</dt><dd class="font-medium text-gray-900"><?php echo e($log->environment_id ?? '—'); ?> <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->site): ?> <span class="text-gray-500">(<?php echo e($log->site->name); ?>)</span> <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?></dd>
                <dt class="text-gray-500">license_token_id</dt><dd class="font-medium text-gray-900"><?php echo e($log->license_token_id ?? '—'); ?></dd>
                <dt class="text-gray-500">plugin</dt><dd class="font-medium text-gray-900"><?php echo e($log->plugin ?? '—'); ?></dd>
                <dt class="text-gray-500">action</dt><dd class="font-medium text-gray-900"><?php echo e($log->action ?? '—'); ?></dd>
                <dt class="text-gray-500">host</dt><dd class="font-medium text-gray-900 break-all"><?php echo e($log->host ?? '—'); ?></dd>
                <dt class="text-gray-500">projectid</dt><dd class="font-medium text-gray-900"><?php echo e($log->projectid ?? '—'); ?></dd>
                <dt class="text-gray-500">http_status</dt><dd><span class="inline-flex rounded-lg px-2 py-0.5 text-xs font-semibold <?php echo e($log->http_status >= 400 ? 'bg-amber-100 text-amber-800' : 'bg-emerald-100 text-emerald-800'); ?>"><?php echo e($log->http_status); ?></span></dd>
                <dt class="text-gray-500">error_code</dt><dd class="font-medium text-gray-900"><?php echo e($log->error_code ?? '—'); ?></dd>
                <dt class="text-gray-500">error</dt><dd class="col-span-2 font-medium text-gray-900"><?php echo e($log->error ?? '—'); ?></dd>
            </dl>
            <div class="mt-4 flex flex-wrap gap-2">
                <button type="button" wire:click="copyUuid(<?php echo e(json_encode($log->request_uuid)); ?>)" class="rounded-lg bg-gray-200 px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-300">Copiar UUID</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="filterBySiteOrHostAndClose(<?php echo e($log->environment_id ?? 'null'); ?>, <?php echo e(json_encode($log->host ?? '')); ?>)" class="rounded-lg bg-orange-100 px-3 py-1.5 text-xs font-medium text-orange-800 hover:bg-orange-200"><?php echo e($log->environment_id ? 'Filtrar por mismo sitio' : 'Filtrar por mismo host'); ?></button>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </section>
        <section class="rounded-xl bg-gray-50/80 p-4 border border-gray-100">
            <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3">Request técnico</h3>
            <dl class="grid grid-cols-2 gap-x-4 gap-y-2.5 text-sm">
                <dt class="text-gray-500">method</dt><dd class="font-mono font-medium"><?php echo e($log->method); ?></dd>
                <dt class="text-gray-500">path</dt><dd class="font-mono font-medium"><?php echo e($log->path); ?></dd>
                <dt class="text-gray-500">ip</dt><dd class="font-medium"><?php echo e($log->ip ?? '—'); ?></dd>
                <dt class="text-gray-500">user_agent</dt><dd class="col-span-2 break-all text-gray-700 text-xs"><?php echo e(Str::limit($log->user_agent, 120)); ?></dd>
                <dt class="text-gray-500">query</dt><dd class="col-span-2"><pre class="text-xs bg-white border border-gray-200 rounded-lg p-3 overflow-x-auto max-h-32 overflow-y-auto"><?php echo e(json_encode($log->query, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); ?></pre></dd>
                <dt class="text-gray-500">headers</dt><dd class="col-span-2"><pre class="text-xs bg-white border border-gray-200 rounded-lg p-3 overflow-x-auto max-h-40 overflow-y-auto"><?php echo e(json_encode($log->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); ?></pre></dd>
            </dl>
        </section>
        <section class="rounded-xl bg-gray-50/80 p-4 border border-gray-100">
            <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3">Payload</h3>
            <pre class="text-xs bg-white border border-gray-200 rounded-lg p-3 overflow-x-auto max-h-60 overflow-y-auto"><?php echo e(json_encode($log->payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); ?></pre>
        </section>
    </div>
</div><?php /**PATH /var/www/html/resources/views/livewire/api-logs/log-detail-modal.blade.php ENDPATH**/ ?>