<?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([]); ?>
<style>
    .health-hero { border: 0; color: #fff; overflow: hidden; background: linear-gradient(135deg, #172554, #2563eb); }
    .health-dot { width: .7rem; height: .7rem; border-radius: 50%; flex: 0 0 auto; }
    .health-dot.healthy { background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.15); }
    .health-dot.warning { background: #f59e0b; box-shadow: 0 0 0 5px rgba(245,158,11,.15); }
    .health-dot.critical { background: #ef4444; box-shadow: 0 0 0 5px rgba(239,68,68,.15); }
    .health-check { height: 100%; border: 1px solid var(--bs-border-color); border-radius: 1rem; background: var(--bs-body-bg); padding: 1rem; }
    .health-metric { border-radius: .9rem; padding: .9rem 1rem; background: var(--bs-tertiary-bg); }
</style>

<div class="container-fluid py-2">
    <div class="card health-hero shadow-sm mb-4">
        <div class="card-body p-3 p-lg-4 d-flex flex-column flex-md-row align-items-md-center justify-content-between gap-3">
            <div>
                <div class="small text-uppercase opacity-75 mb-1">System operations</div>
                <h4 class="mb-1">Automation & Health</h4>
                <p class="mb-0 opacity-75">Queue, scheduler, backup and device availability at a glance.</p>
            </div>
            <div class="d-flex align-items-center gap-3">
                <span class="badge rounded-pill bg-white text-<?php echo e($health['overall'] === 'healthy' ? 'success' : ($health['overall'] === 'warning' ? 'warning' : 'danger')); ?> px-3 py-2">
                    <?php echo e(ucfirst($health['overall'])); ?>

                </span>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('scheduler.run')): ?>
                    <button id="run-daily" class="btn btn-light btn-sm px-3">Run Daily Tasks</button>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <div class="row g-3 mb-4">
        <?php $__currentLoopData = $health['checks']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $check): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="col-12 col-md-6 col-xl-4">
                <div class="health-check shadow-sm">
                    <div class="d-flex align-items-center gap-3 mb-2">
                        <span class="health-dot <?php echo e($check['status']); ?>"></span>
                        <strong><?php echo e($check['label']); ?></strong>
                        <span class="badge rounded-pill ms-auto text-bg-<?php echo e($check['status'] === 'healthy' ? 'success' : ($check['status'] === 'warning' ? 'warning' : 'danger')); ?>">
                            <?php echo e(ucfirst($check['status'])); ?>

                        </span>
                    </div>
                    <div class="small text-body-secondary"><?php echo e($check['message']); ?></div>
                    <?php if($check['meta']): ?>
                        <div class="small fw-semibold mt-2"><?php echo e($check['meta']); ?></div>
                    <?php endif; ?>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    <div class="card border-0 shadow-sm">
        <div class="card-header bg-transparent border-0 p-3 p-lg-4 pb-0">
            <h5 class="mb-1">Network snapshot</h5>
            <div class="small text-body-secondary">Uses the latest saved status, so this page never waits for a disconnected device.</div>
        </div>
        <div class="card-body p-3 p-lg-4">
            <div class="row g-3">
                <div class="col-6 col-lg-3"><div class="health-metric"><div class="small text-body-secondary">MikroTik</div><div class="fs-4 fw-bold"><?php echo e($health['metrics']['mikrotik_total']); ?></div></div></div>
                <div class="col-6 col-lg-3"><div class="health-metric"><div class="small text-body-secondary">MikroTik online</div><div class="fs-4 fw-bold text-success"><?php echo e($health['metrics']['mikrotik_online']); ?></div></div></div>
                <div class="col-6 col-lg-3"><div class="health-metric"><div class="small text-body-secondary">OLT</div><div class="fs-4 fw-bold"><?php echo e($health['metrics']['olt_total']); ?></div></div></div>
                <div class="col-6 col-lg-3"><div class="health-metric"><div class="small text-body-secondary">OLT online</div><div class="fs-4 fw-bold text-success"><?php echo e($health['metrics']['olt_online']); ?></div></div></div>
            </div>
            <div class="small text-body-secondary mt-3">Last checked: <?php echo e($health['checked_at']->format('d M Y, h:i:s A')); ?></div>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
$('#run-daily').on('click', function() {
    const button = $(this);
    button.prop('disabled', true).text('Running...');
    $.post('<?php echo e(route('admin.scheduler.run-daily')); ?>', {_token: '<?php echo e(csrf_token()); ?>'}, function(res) {
        if (window.Swal) Swal.fire({icon: 'success', title: 'Completed', text: res.message, timer: 2200, showConfirmButton: false});
        else alert(res.message || 'Executed');
    }).fail(function(xhr) {
        const message = xhr.responseJSON?.message || 'Daily tasks could not be started.';
        if (window.Swal) Swal.fire({icon: 'error', title: 'Failed', text: message});
        else alert(message);
    }).always(function() {
        button.prop('disabled', false).text('Run Daily Tasks');
    });
});
</script>
<?php $__env->stopPush(); ?>
 <?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 D:\herd\billing\laravel-app\resources\views/admin/scheduler/index.blade.php ENDPATH**/ ?>