<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('title', null, []); ?> <?php echo e($device->name); ?> <?php $__env->endSlot(); ?>
     <?php $__env->slot('breadcrumb', null, []); ?> 
        <a href="<?php echo e(route('devices.index')); ?>" class="hover:text-gray-600 dark:hover:text-gray-300 transition-colors">Dispositivos</a>
        <svg class="w-3 h-3 mx-1" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/></svg>
        <span class="text-gray-400"><?php echo e($device->name); ?></span>
     <?php $__env->endSlot(); ?>

    <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6">
        <div class="flex items-center gap-3">
            <div class="w-11 h-11 rounded-xl bg-gradient-to-br from-primary-500 to-primary-700 flex items-center justify-center">
                <svg class="w-5 h-5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2"/>
                </svg>
            </div>
            <div>
                <h1 class="text-xl font-bold text-gray-900 dark:text-white"><?php echo e($device->name); ?></h1>
                <code class="text-xs text-gray-400 font-mono"><?php echo e($device->host); ?>:<?php echo e($device->port); ?></code>
            </div>
        </div>
        <div class="flex items-center gap-2 flex-wrap">
            <button onclick="testConnection(<?php echo e($device->id); ?>, this)"
                    class="btn-outline btn-sm" id="testBtn">
                <svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"/>
                </svg>
                Probar SSH
            </button>
            <a href="<?php echo e(route('devices.edit', $device)); ?>" class="btn-ghost btn-sm">
                <svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
                </svg>
                Editar
            </a>
            <a href="<?php echo e(route('onus.create', ['device_id' => $device->id])); ?>" class="btn-accent btn-sm">
                <svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M12 4v16m8-8H4"/>
                </svg>
                Autorizar ONU
            </a>
            <a href="<?php echo e(route('rogue.index', ['device_id' => $device->id])); ?>" class="btn btn-sm bg-yellow-500 text-white hover:bg-yellow-400 focus:ring-yellow-400">
                <svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
                </svg>
                Rogue ONUs
            </a>
        </div>
    </div>

    <?php $__empty_1 = true; $__currentLoopData = $device->ports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $port): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <div class="card mb-4">
            <div class="card-header">
                <div class="flex items-center gap-3">
                    <div class="w-8 h-8 rounded-lg bg-primary-100 dark:bg-primary-900/30 flex items-center justify-center">
                        <svg class="w-4 h-4 text-primary-600 dark:text-primary-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                  d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                        </svg>
                    </div>
                    <div>
                        <code class="text-sm font-semibold text-primary-600 dark:text-primary-400 font-mono">
                            interface <?php echo e($port->interface_name); ?>

                        </code>
                        <?php if($port->description): ?>
                            <span class="text-gray-400 text-xs ml-2">— <?php echo e($port->description); ?></span>
                        <?php endif; ?>
                    </div>
                </div>
                <span class="badge-purple"><?php echo e($port->onus->count()); ?> ONUs</span>
            </div>

            <div class="table-wrapper rounded-b-xl overflow-hidden">
                <table class="table">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Serial (SN)</th>
                            <th>Tipo</th>
                            <th>Cliente</th>
                            <th>VLAN</th>
                            <th>Perfil</th>
                            <th>Estado</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_2 = true; $__currentLoopData = $port->onus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $onu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_2 = false; ?>
                            <tr>
                                <td>
                                    <span class="badge-gray font-mono"><?php echo e($onu->onu_number); ?></span>
                                </td>
                                <td>
                                    <code class="text-xs font-mono font-semibold text-primary-700 dark:text-primary-300
                                                 bg-primary-50 dark:bg-primary-900/20 px-2 py-0.5 rounded">
                                        <?php echo e($onu->serial_number); ?>

                                    </code>
                                </td>
                                <td class="text-xs text-gray-500 dark:text-gray-400"><?php echo e($onu->onu_type); ?></td>
                                <td>
                                    <div class="font-medium text-gray-800 dark:text-gray-200 text-sm">
                                        <?php echo e($onu->customer_name ?? '—'); ?>

                                    </div>
                                    <?php if($onu->customer_description): ?>
                                        <div class="text-xs text-gray-400 truncate max-w-xs"><?php echo e($onu->customer_description); ?></div>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <span class="badge-gray font-mono"><?php echo e($onu->vlan); ?></span>
                                </td>
                                <td>
                                    <code class="text-xs text-gray-500 dark:text-gray-400"><?php echo e($onu->tcont_profile); ?></code>
                                </td>
                                <td>
                                    <?php if($onu->status === 'authorized'): ?>
                                        <span class="badge-green">
                                            <span class="w-1 h-1 rounded-full bg-accent-500 animate-pulse-slow"></span>
                                            Activa
                                        </span>
                                    <?php elseif($onu->status === 'pending'): ?>
                                        <span class="badge-yellow">Pendiente</span>
                                    <?php else: ?>
                                        <span class="badge-red">Deshabilitada</span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <a href="<?php echo e(route('onus.show', $onu)); ?>"
                                       class="text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 text-xs font-medium transition-colors">
                                        Ver →
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_2): ?>
                            <tr>
                                <td colspan="8" class="py-6 text-center text-gray-400 text-sm">
                                    Sin ONUs en este puerto.
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <div class="card p-16 text-center">
            <div class="flex flex-col items-center gap-3 text-gray-400">
                <svg class="w-12 h-12 opacity-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
                          d="M9 3H5a2 2 0 00-2 2v4m6-6h10a2 2 0 012 2v4"/>
                </svg>
                <p class="text-sm">No hay puertos configurados.</p>
                <a href="<?php echo e(route('onus.create', ['device_id' => $device->id])); ?>" class="btn-accent btn-sm">
                    Autorizar primera ONU
                </a>
            </div>
        </div>
    <?php endif; ?>

    <script>
    function testConnection(deviceId, btn) {
        const original = btn.innerHTML;
        const spinner  = '<svg class="w-3.5 h-3.5 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>';
        btn.innerHTML = spinner + ' Probando...';
        btn.disabled  = true;

        fetch(`<?php echo e(url('/')); ?>/devices/${deviceId}/test-connection`, {
            method: 'POST',
            headers: {
                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
                'Accept': 'application/json',
            }
        })
        .then(r => r.json())
        .then(data => {
            showModal({
                type:    data.success ? 'success' : 'error',
                title:   data.success ? 'Conexión exitosa' : 'Error de conexión SSH',
                message: data.message,
            });
        })
        .catch(err => {
            showModal({
                type:    'error',
                title:   'Error inesperado',
                message: 'No se pudo completar la prueba de conexión.',
                detail:  err.message ?? '',
            });
        })
        .finally(() => { btn.innerHTML = original; btn.disabled = false; });
    }
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\adminolt\resources\views/devices/show.blade.php ENDPATH**/ ?>