<?php
    /** @var \App\Models\Router|null $router */
    $router = $router ?? null;
    $owners = $owners ?? collect();
    $isEdit = isset($router) && $router->exists;
    $val = function (string $field, $default = null) use ($router) {
        return old($field, $router?->{$field} ?? $default);
    };
?>

<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
    <?php if (isset($component)) { $__componentOriginalb95fb6157a10b6449458ef38a3dd045c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.form-section','data' => ['title' => 'Identity','description' => 'Friendly name and where this device lives.']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('form-section'); ?>
<?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(['title' => 'Identity','description' => 'Friendly name and where this device lives.']); ?>
        <div class="space-y-4">
            <div>
                <label class="isp-form-label mb-1">Router name *</label>
                <input type="text" name="name" value="<?php echo e($val('name')); ?>" required
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="Edge-Nairobi-01" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Branch / site</label>
                <input type="text" name="branch" value="<?php echo e($val('branch')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="Westlands" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Location notes</label>
                <input type="text" name="location" value="<?php echo e($val('location')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="Rack A2, second floor" />
            </div>
            <div class="grid grid-cols-2 gap-3">
                <div>
                    <label class="isp-form-label mb-1">Latitude</label>
                    <input type="number" step="0.0000001" name="latitude" value="<?php echo e($val('latitude')); ?>"
                           class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
                </div>
                <div>
                    <label class="isp-form-label mb-1">Longitude</label>
                    <input type="number" step="0.0000001" name="longitude" value="<?php echo e($val('longitude')); ?>"
                           class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
                </div>
            </div>
            <div>
                <label class="isp-form-label mb-1">Tags <span class="text-slate-400">(comma-separated)</span></label>
                <input type="text" name="tags" value="<?php echo e($val('tags')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="core, ccr1036, hotspot" />
            </div>
        </div>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $attributes = $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $component = $__componentOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginalb95fb6157a10b6449458ef38a3dd045c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.form-section','data' => ['title' => 'RouterOS API','description' => 'Credentials used by the polling job and bulk operations.']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('form-section'); ?>
<?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(['title' => 'RouterOS API','description' => 'Credentials used by the polling job and bulk operations.']); ?>
        <div class="space-y-4">
            <div>
                <label class="isp-form-label mb-1">IP / hostname *</label>
                <input type="text" name="ip_address" id="ip_address" value="<?php echo e($val('ip_address')); ?>" required
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="192.168.88.1" />
            </div>
            <div class="grid grid-cols-3 gap-3">
                <div>
                    <label class="isp-form-label mb-1">Port *</label>
                    <input type="number" name="port" id="port" value="<?php echo e($val('port', 8728)); ?>" required
                           class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
                </div>
                <div class="col-span-2 flex items-end gap-3">
                    <label class="inline-flex items-center gap-2 text-sm text-slate-700 dark:text-slate-300">
                        <input type="checkbox" name="use_ssl" value="1" <?php echo e($val('use_ssl') ? 'checked' : ''); ?>

                               class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-500">
                        Use SSL
                    </label>
                    <label class="inline-flex items-center gap-2 text-sm text-slate-700 dark:text-slate-300">
                        <input type="checkbox" name="is_active" value="1" <?php echo e($val('is_active', true) ? 'checked' : ''); ?>

                               class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-500">
                        Active
                    </label>
                </div>
            </div>
            <div>
                <label class="isp-form-label mb-1">Username *</label>
                <input type="text" name="username" id="username" value="<?php echo e($val('username')); ?>" required
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="admin" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Password <?php echo e($isEdit ? '' : '*'); ?></label>
                <input type="password" name="password" id="password" <?php echo e($isEdit ? '' : 'required'); ?>

                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="<?php echo e($isEdit ? 'Leave empty to keep current password' : '*****'); ?>" />
                <p class="mt-1 text-[11px] text-slate-500">Stored encrypted at rest.</p>
            </div>
        </div>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $attributes = $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $component = $__componentOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginalb95fb6157a10b6449458ef38a3dd045c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.form-section','data' => ['title' => 'Asset / CMDB','description' => 'Treats the router as a fixed asset for ERP reporting.']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('form-section'); ?>
<?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(['title' => 'Asset / CMDB','description' => 'Treats the router as a fixed asset for ERP reporting.']); ?>
        <div class="grid grid-cols-2 gap-3">
            <div>
                <label class="isp-form-label mb-1">Vendor</label>
                <input type="text" name="vendor" value="<?php echo e($val('vendor')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="MikroTik" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Model</label>
                <input type="text" name="model" value="<?php echo e($val('model')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="CCR1036-12G-4S" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Serial number</label>
                <input type="text" name="serial_number" value="<?php echo e($val('serial_number')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
            </div>
            <div>
                <label class="isp-form-label mb-1">MAC address</label>
                <input type="text" name="mac_address" value="<?php echo e($val('mac_address')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900"
                       placeholder="AA:BB:CC:DD:EE:FF" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Purchase date</label>
                <input type="date" name="purchase_date" value="<?php echo e($val('purchase_date') ? \Illuminate\Support\Carbon::parse($val('purchase_date'))->toDateString() : ''); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Warranty expiry</label>
                <input type="date" name="warranty_expiry" value="<?php echo e($val('warranty_expiry') ? \Illuminate\Support\Carbon::parse($val('warranty_expiry'))->toDateString() : ''); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Monthly cost</label>
                <input type="number" step="0.01" name="monthly_cost" value="<?php echo e($val('monthly_cost')); ?>"
                       class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900" />
            </div>
            <div>
                <label class="isp-form-label mb-1">Lifecycle</label>
                <select name="lifecycle_status" class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900">
                    <?php $__currentLoopData = ['live', 'stock', 'maintenance', 'retired']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($opt); ?>" <?php if($val('lifecycle_status', 'live') === $opt): echo 'selected'; endif; ?>><?php echo e(ucfirst($opt)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $attributes = $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $component = $__componentOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginalb95fb6157a10b6449458ef38a3dd045c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.form-section','data' => ['title' => 'Ownership','description' => 'Who is responsible for this router?']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('form-section'); ?>
<?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(['title' => 'Ownership','description' => 'Who is responsible for this router?']); ?>
        <div class="space-y-4">
            <div>
                <label class="isp-form-label mb-1">Owner / on-call engineer</label>
                <select name="owner_user_id" class="w-full rounded-md border-slate-300 bg-white text-sm dark:border-slate-700 dark:bg-slate-900">
                    <option value="">— Unassigned —</option>
                    <?php $__currentLoopData = $owners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $owner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($owner->id); ?>" <?php if((string) $val('owner_user_id') === (string) $owner->id): echo 'selected'; endif; ?>>
                            <?php echo e($owner->name); ?> <span class="text-slate-400">(<?php echo e($owner->email); ?>)</span>
                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <p class="mt-1 text-[11px] text-slate-500">Used for routing outage notifications.</p>
            </div>
        </div>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $attributes = $__attributesOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__attributesOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c)): ?>
<?php $component = $__componentOriginalb95fb6157a10b6449458ef38a3dd045c; ?>
<?php unset($__componentOriginalb95fb6157a10b6449458ef38a3dd045c); ?>
<?php endif; ?>
</div>
<?php /**PATH C:\xampp\htdocs\ispbilling\resources\views/isp/routers/partials/form.blade.php ENDPATH**/ ?>