
<?php
    $etiquetas = \App\Services\Api\Severidad::ETIQUETAS;

    // Un solo sitio donde se decide el color de una severidad. `sin_contenido` y
    // `negocio` NO son rojos: son respuestas correctas.
    $tono = [
        '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)'],
    ][$log->severity] ?? ['texto' => 'var(--text-muted)', 'fondo' => 'var(--surface-sunken)'];

    $colorDe = fn (?string $severidad) => [
        'ok' => 'var(--success-500)',
        'error' => 'var(--danger-500)',
        'sin_contenido' => 'var(--neutral-400)',
        'negocio' => 'var(--info-500)',
    ][$severidad] ?? 'var(--text-muted)';

    // El mismo color que lleva esta acción en la tabla, para que la modal se lea como la
    // continuación de la fila que se acaba de pulsar. Ver `ColorDeAccion`.
    $colorAccion = \App\Support\ColorDeAccion::de($log->action);

    // El marco del bloque de patrón: verde si ya está resuelto, rojo si sigue roto, y
    // neutro cuando solo informa.
    $patron = match (true) {
        $contexto['resuelto'] => ['borde' => 'var(--success-500)', 'fondo' => 'var(--success-50)'],
        $log->severity === 'error' => ['borde' => 'var(--danger-500)', 'fondo' => 'var(--danger-50)'],
        default => ['borde' => 'var(--border-subtle)', 'fondo' => 'var(--surface-alt)'],
    };

    $rotulo = 'text-[11px] font-semibold uppercase tracking-[0.06em]';
?>

<div class="relative" style="font-size:14px;">
    <button wire:click="closeModal"
            class="absolute end-5 top-5 z-10 transition-colors"
            style="color:var(--text-subtle);"
            onmouseover="this.style.color='var(--text-body)'"
            onmouseout="this.style.color='var(--text-subtle)'"
            aria-label="Cerrar">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M18 6 6 18"/><path d="m6 6 12 12"/>
        </svg>
    </button>

    
    <div class="px-6 pt-5">
        <div class="flex flex-wrap items-center gap-2.5 pe-8">
            <span class="flex-none rounded-full px-2.5 py-0.5 text-[11px] font-semibold"
                  style="color:<?php echo e($tono['texto']); ?>; background:<?php echo e($tono['fondo']); ?>;">
                <?php echo e($etiquetas[$log->severity] ?? $log->severity); ?>

            </span>
            <span class="rounded px-2 py-0.5 font-mono text-[13px] font-bold"
                  style="color:<?php echo e($colorAccion['texto']); ?>; background:<?php echo e($colorAccion['fondo']); ?>;">
                <?php echo e($log->action ?? $log->path); ?>

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

                · <?php echo e(number_format((int) $log->duration_ms, 0, ',', '.')); ?> ms
                · HTTP <?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): ?> · código <?php echo e($log->error_code); ?><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </span>
        </div>

        <div class="mt-1 text-[12px]" style="color:var(--text-muted);">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->plugin): ?>
                La pide <span class="font-mono text-[11.5px]"><?php echo e($log->plugin); ?></span>
            <?php else: ?>
                Sin plugin declarado
            <?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->response_size !== null): ?>
                · <?php echo e(number_format($log->response_size, 0, ',', '.')); ?> bytes de respuesta
            <?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->started_at): ?>
                · hace <?php echo e($log->started_at->diffForHumans(null, true)); ?>

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

        
        <div class="mt-3">
            <div class="<?php echo e($rotulo); ?>" style="color:var(--text-muted);">Qué significa</div>
            <div class="mt-0.5 text-[13.5px] font-semibold leading-relaxed" style="color:var(--text-strong);">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($explicacion): ?>
                    <?php echo e($explicacion); ?>.
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->severity === 'sin_contenido'): ?>
                        <span class="font-normal" style="color:var(--text-muted);">No es un fallo: es una lista vacía.</span>
                    <?php elseif($log->severity === 'negocio'): ?>
                        <span class="font-normal" style="color:var(--text-muted);">No es un fallo: el Manager está respondiendo bien.</span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <?php else: ?>
                    Se respondió con normalidad en <?php echo e(number_format((int) $log->duration_ms, 0, ',', '.')); ?> ms.
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>

        
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($detrasDelHost): ?>
            <?php $suyo = $detrasDelHost['entorno']; ?>
            <div class="mt-3 rounded-lg border px-3.5 py-2.5 text-[12.5px] leading-[1.55]"
                 style="border-color:var(--info-500); background:var(--info-50); color:var(--text-body);">
                <strong class="font-semibold">Este host sí está dado de alta.</strong>
                Es el entorno
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('admin.environments.index')): ?>
                    <a href="<?php echo e(route('environments.show', $suyo)); ?>" wire:navigate
                       class="font-semibold" style="color:var(--text-link);"><?php echo e($suyo->name); ?></a>,
                <?php else: ?>
                    <span class="font-semibold"><?php echo e($suyo->name); ?></span>,
                <?php endif; ?>
                <?php echo e($detrasDelHost['mismoCliente'] ? 'del mismo cliente' : 'de OTRO cliente'); ?>

                (<?php echo e($suyo->client?->name ?? '—'); ?>), vinculado a la licencia
                <span class="font-semibold"><?php echo e($suyo->licenseToken?->name ?? 'ninguna'); ?></span>.

                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($detrasDelHost['mismoCliente']): ?>
                    
                    No hay que crear nada: o se vincula este entorno a la licencia que llama,
                    o se cambia el token configurado en ese Moodle por el de su licencia.
                <?php else: ?>
                    Alguien está llamando con un token que no es de ese dominio. Antes de tocar
                    nada, conviene saber por qué.
                <?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 class="flex flex-col gap-4 px-6 pt-4">

        
        <div>
            <div class="<?php echo e($rotulo); ?> mb-1.5" style="color:var(--text-muted);">¿Le pasa siempre?</div>

            <div class="rounded-[10px] border px-3.5 py-2.5 text-[12.5px] leading-relaxed"
                 style="border-color:<?php echo e($patron['borde']); ?>; background:<?php echo e($patron['fondo']); ?>; color:var(--text-body);">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($contexto['resuelto']): ?>
                    
                    <strong class="font-semibold" style="color:var(--success-500);">Ya está resuelto.</strong>
                    Después de esta petición, el mismo sitio ha pedido lo mismo
                    <strong class="font-semibold"><?php echo e($contexto['posteriores']); ?> vez/veces y se le ha respondido bien</strong>.
                    Lo que falló entonces ya no falla.
                <?php elseif($contexto['total'] > 1): ?>
                    <strong class="font-semibold"><?php echo e($contexto['total']); ?> peticiones</strong> de este sitio
                    a <span class="font-mono text-[12px]"><?php echo e($log->action); ?></span>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->plugin): ?>
                        con <span class="font-mono text-[12px]"><?php echo e($log->plugin); ?></span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    en los últimos <?php echo e($contexto['dias']); ?> días.
                <?php else: ?>
                    Es la <strong class="font-semibold">única</strong> petición de este sitio a
                    <span class="font-mono text-[12px]"><?php echo e($log->action); ?></span>
                    en los últimos <?php echo e($contexto['dias']); ?> días.
                <?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($contexto['desglose'] !== []): ?>
                    <div class="mt-2 flex flex-wrap gap-1.5">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $contexto['desglose']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $severidad => $cuantas): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <span class="inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[11px] font-semibold"
                                  style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                                <span class="h-[6px] w-[6px] rounded-full" style="background:<?php echo e($colorDe($severidad)); ?>;"></span>
                                <?php echo e($cuantas); ?> <?php echo e(mb_strtolower($etiquetas[$severidad] ?? $severidad)); ?>

                            </span>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?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="<?php echo e($rotulo); ?> mb-2" style="color:var(--text-muted);">Quién llamó</div>

            <div class="grid grid-cols-2 gap-x-6 gap-y-3 text-[12.5px] sm:grid-cols-3">
                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">Sitio</div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->site): ?>
                        <a href="<?php echo e(route('environments.show', $log->site)); ?>" wire:navigate
                           class="block truncate font-semibold hover:underline" style="color:var(--text-link);"><?php echo e($log->site->name); ?></a>
                    <?php else: ?>
                        
                        <span class="block font-semibold" style="color:var(--warning-500);">no reconocido</span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">Cliente</div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->client): ?>
                        <a href="<?php echo e(route('clients.show', $log->client)); ?>" wire:navigate
                           class="block truncate font-semibold hover:underline" style="color:var(--text-link);"><?php echo e($log->client->name); ?></a>
                    <?php else: ?>
                        <span class="block" style="color:var(--text-subtle);">—</span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">Licencia</div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->licenseToken): ?>
                        <a href="<?php echo e(route('license_tokens.show', $log->licenseToken)); ?>" wire:navigate
                           class="block truncate font-semibold hover:underline" style="color:var(--text-link);"><?php echo e($log->licenseToken->name); ?></a>
                    <?php else: ?>
                        <span class="block" style="color:var(--text-subtle);">sin licencia reconocida</span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">Host desde el que llama</div>
                    <span class="block truncate font-mono text-[11.5px]" style="color:var(--text-body);"
                          title="<?php echo e($log->host); ?>"><?php echo e($log->host ?? '—'); ?></span>
                </div>

                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);"
                         title="La versión del plugin que manda el cliente: es con la que se decide qué contenido le sirve">
                        Versión que envía
                    </div>
                    <span class="block truncate font-mono text-[11.5px]" style="color:var(--text-body);"><?php echo e($log->version ?: '—'); ?></span>
                </div>

                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">IP · projectid</div>
                    <span class="block truncate font-mono text-[11.5px]" style="color:var(--text-body);">
                        <?php echo e($log->ip ?? '—'); ?> · <?php echo e($log->projectid ?? '—'); ?>

                    </span>
                </div>
            </div>
        </div>

        
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($anterior || $siguiente): ?>
        <div>
            <div class="<?php echo e($rotulo); ?> mb-2" style="color:var(--text-muted);">La secuencia del sitio</div>

            <div class="ms-[5px] flex flex-col border-s-2 ps-3.5" style="border-color:var(--border-default);">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = [['anterior', $anterior], ['esta', $log], ['siguiente', $siguiente]]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$cual, $fila]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($fila === null) continue; ?>
                    <?php $colorFila = \App\Support\ColorDeAccion::de($fila->action); ?>
                    <div class="relative <?php echo e($loop->last ? '' : 'pb-2.5'); ?>">
                        <span class="absolute h-[9px] w-[9px] rounded-full"
                              style="left:-19px; top:5px; background:<?php echo e($colorDe($fila->severity)); ?>; border:2px solid var(--surface-page);"></span>

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

                        </span>
                        <span class="ms-1 rounded px-1.5 py-px font-mono text-[12px] <?php echo e($cual === 'esta' ? 'font-bold' : 'font-semibold'); ?>"
                              style="color:<?php echo e($colorFila['texto']); ?>; background:<?php echo e($colorFila['fondo']); ?>;">
                            <?php echo e($fila->action); ?>

                        </span>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($cual === 'esta'): ?>
                            <span class="ms-1 text-[12px] font-semibold"
                                  style="color:<?php echo e($log->severity === 'error' ? 'var(--danger-500)' : 'var(--text-strong)'); ?>;">— esta petición</span>
                        <?php else: ?>
                            <span class="ms-1 text-[12px]" style="color:var(--text-muted);">
                                — <?php echo e($etiquetas[$fila->severity] ?? $fila->severity); ?>

                                <?php if((int) $fila->error_code !== 0): ?>
                                    · <?php echo e($fila->error_code); ?>

                                <?php else: ?>
                                    · <?php echo e(number_format((int) $fila->duration_ms, 0, ',', '.')); ?> ms
                                <?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($fila->plugin): ?>
                                <span class="ms-1 font-mono text-[11px]" style="color:var(--text-subtle);"><?php echo e($fila->plugin); ?></span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>

    
    <div class="px-6 pt-4" x-data="{ abierto: false }">
        <button type="button" x-on:click="abierto = ! abierto"
                class="inline-flex items-center gap-[7px] text-[12.5px] font-semibold"
                style="color:var(--text-link);">
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                 class="transition-transform" x-bind:class="abierto && 'rotate-90'">
                <path d="m9 18 6-6-6-6"/>
            </svg>
            Detalle técnico
        </button>

        <div x-show="abierto" x-collapse x-cloak class="mt-2.5">
            <div class="grid grid-cols-1 gap-x-6 gap-y-2.5 text-[12px] sm:grid-cols-2">
                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">method · path</div>
                    <span class="block truncate font-mono text-[11.5px]" style="color:var(--text-body);"><?php echo e($log->method); ?> <?php echo e($log->path); ?></span>
                </div>
                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">auth_type</div>
                    <span class="block font-mono text-[11.5px]" style="color:var(--text-body);"><?php echo e($log->auth_type ?? '—'); ?></span>
                </div>
                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">started_at → ended_at</div>
                    <span class="block font-mono text-[11.5px]" style="color:var(--text-body);">
                        <?php echo e($log->started_at?->format('H:i:s')); ?> → <?php echo e($log->ended_at?->format('H:i:s')); ?>

                    </span>
                </div>
                <div class="min-w-0">
                    <div class="text-[11px]" style="color:var(--text-subtle);">uuid</div>
                    <span class="block truncate font-mono text-[11.5px]" style="color:var(--text-body);"
                          title="<?php echo e($log->request_uuid); ?>"><?php echo e($log->request_uuid); ?></span>
                </div>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->user_agent): ?>
                    <div class="min-w-0 sm:col-span-2">
                        <div class="text-[11px]" style="color:var(--text-subtle);">user_agent</div>
                        <span class="block break-all font-mono text-[11.5px]" style="color:var(--text-body);"><?php echo e($log->user_agent); ?></span>
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->error): ?>
                    <div class="min-w-0 sm:col-span-2">
                        <div class="text-[11px]" style="color:var(--text-subtle);">Mensaje del servidor</div>
                        <span class="block break-all font-mono text-[11.5px]" style="color:var(--text-body);"><?php echo e($log->error); ?></span>
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            
            <div class="mt-3">
                <div class="<?php echo e($rotulo); ?>" style="color:var(--text-subtle);">
                    respuesta
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->response_size !== null): ?>
                        <span class="font-normal normal-case tracking-normal">
                            · <?php echo e(number_format($log->response_size, 0, ',', '.')); ?> bytes
                        </span>
                    <?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($log->response_body): ?>
                    <pre class="mt-1 max-h-44 overflow-auto rounded-[10px] p-3 font-mono text-[11px] leading-relaxed"
                         style="background:var(--neutral-900); color:#e8e8e8;"><?php echo e($log->response_body); ?></pre>
                <?php elseif($log->severity === 'ok'): ?>
                    <div class="mt-1 text-[11.5px]" style="color:var(--text-subtle);">
                        La respuesta fue correcta y su cuerpo no se guarda: son las grandes
                        —ficheros y bundles— y ocuparían más que todo el resto del registro.
                    </div>
                <?php else: ?>
                    
                    <div class="mt-1 text-[11.5px]" style="color:var(--text-subtle);">
                        No se guardó: esta petición es anterior al cambio que empezó a
                        registrar el cuerpo de las respuestas fallidas.
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            
            <div class="mt-3 flex flex-col gap-3">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = [['query', $log->query], ['headers', $log->headers], ['payload', $log->payload]]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$titulo, $contenido]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(! empty($contenido)): ?>
                        <div class="min-w-0">
                            <div class="<?php echo e($rotulo); ?>" style="color:var(--text-subtle);"><?php echo e($titulo); ?></div>
                            
                            <pre class="mt-1 max-h-44 overflow-auto rounded-[10px] p-3 font-mono text-[11px] leading-relaxed"
                                 style="background:var(--neutral-900); color:#e8e8e8;"><?php echo e(json_encode($contenido, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); ?></pre>
                        </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; ?>
            </div>
        </div>
    </div>

    
    <div class="mt-4 flex flex-wrap items-center justify-between gap-3 border-t px-6 py-4"
         style="border-color:var(--divider);">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->site): ?>
            <a href="<?php echo e(route('environments.show', $log->site)); ?>" wire:navigate
               class="text-[13px] font-semibold hover:underline" style="color:var(--text-link);">
                Ir a la ficha del sitio →
            </a>
        <?php else: ?>
            <span class="text-[12px]" style="color:var(--text-subtle);">
                No hay ficha a la que ir: ningún entorno responde a este host.
            </span>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

        <div class="flex flex-wrap items-center gap-2">
            
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->severity !== 'ok'): ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->reviewed_at): ?>
                    <span class="text-[12px]" style="color:var(--success-500);">
                        ✓ Visto el <?php echo e($log->reviewed_at->format('d/m/Y')); ?>

                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->reviewedBy): ?>
                            por <?php echo e($log->reviewedBy->name); ?>

                        <?php else: ?>
                            
                            <span style="color:var(--text-subtle);">(usuario borrado)</span>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </span>
                    <button type="button" wire:click="alternarRevision"
                            class="rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                            style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                        Desmarcar
                    </button>
                <?php else: ?>
                    <button type="button" wire:click="alternarRevision"
                            title="Deja de contar en «errores sin revisar». No arregla nada: dice que ya se conoce."
                            class="rounded-lg border-none px-4 py-1.5 text-[12.5px] font-semibold text-white"
                            style="background:var(--success-500);">
                        Marcar como visto
                    </button>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            
            <button type="button"
                    x-data="{ copiado: false }"
                    @click="copiarAlPortapapeles(<?php echo \Illuminate\Support\Js::from($promptParaClaude)->toHtml() ?>); copiado = true; setTimeout(() => copiado = false, 2000)"
                    title="Copia esta petición, su contexto y la pregunta, listo para pegar en Claude Code"
                    class="inline-flex items-center gap-1.5 rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                    style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
                <span x-text="copiado ? '¡Copiado!' : 'Copiar para Claude Code'">Copiar para Claude Code</span>
            </button>

            <button type="button" wire:click="copyUuid(<?php echo e(json_encode($log->request_uuid)); ?>)"
                    class="rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                    style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                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 ?? '')); ?>)"
                        title="Filtra el visor por este sitio y cierra"
                        class="rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                        style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                    <?php echo e($log->environment_id ? 'Mismo sitio' : 'Mismo host'); ?>

                </button>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <button type="button" wire:click="closeModal"
                    class="rounded-lg border px-3.5 py-1.5 text-[12.5px] font-semibold"
                    style="border-color:var(--border-default); background:var(--surface-page); color:var(--text-body);">
                Cerrar
            </button>
        </div>
    </div>
</div><?php /**PATH /var/www/html/resources/views/livewire/api-logs/log-detail-modal.blade.php ENDPATH**/ ?>