<?php
    /** @var \App\Support\Works\WorkOperationalEfficiencySnapshot $snap */
?>

<div class="setel-card border border-[var(--setel-card-border)] bg-gradient-to-br from-[var(--setel-content-bg)] via-[var(--setel-card)]/40 to-[var(--setel-primary)]/5 p-5 md:p-6">
    <div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
        <div>
            <h2 class="text-lg font-semibold text-[var(--setel-text)]">Eficiencia operativa</h2>
            <p class="mt-1 text-sm text-[var(--setel-text-muted)]">
                Tiempo de ejecución respecto a lo programado y cumplimiento del SLA desde la escala.
            </p>
        </div>
        <span class="<?php echo e($snap->slaVerdictBadgeClass); ?> w-fit shrink-0 text-xs"><?php echo e($snap->slaVerdictLabel); ?></span>
    </div>

    <dl class="mt-5 grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
        <div class="rounded-lg border border-[var(--setel-card-border)] bg-[var(--setel-content-bg)]/80 p-4">
            <dt class="text-xs font-semibold uppercase tracking-wide text-[var(--setel-text-muted)]">Ejecución (clareo − programado)</dt>
            <dd class="mt-2 text-base font-semibold tabular-nums text-[var(--setel-text)]">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($snap->executionHours !== null): ?>
                    <?php echo e($snap->executionLabel); ?>

                    <span class="mt-1 block text-xs font-normal text-[var(--setel-text-muted)]">(<?php echo e(number_format($snap->executionHours, 2, ',', '.')); ?> h)</span>
                <?php else: ?>
                    <span class="text-sm font-normal text-[var(--setel-text-muted)]"><?php echo e($snap->executionLabel ?? '—'); ?></span>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </dd>
        </div>
        <div class="rounded-lg border border-[var(--setel-card-border)] bg-[var(--setel-content-bg)]/80 p-4">
            <dt class="text-xs font-semibold uppercase tracking-wide text-[var(--setel-text-muted)]">Ventana SLA</dt>
            <dd class="mt-2 text-sm text-[var(--setel-text)]">
                <span class="block font-medium">Escala + <?php echo e(number_format((int) $work->sla_hours)); ?> h</span>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($snap->slaDeadlineLabel !== null): ?>
                    <span class="mt-1 block text-xs tabular-nums text-[var(--setel-text-muted)]">Límite: <?php echo e($snap->slaDeadlineLabel); ?></span>
                <?php else: ?>
                    <span class="mt-1 block text-xs text-[var(--setel-text-muted)]">Sin fecha de escala</span>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </dd>
        </div>
        <div class="rounded-lg border border-[var(--setel-card-border)] bg-[var(--setel-content-bg)]/80 p-4">
            <dt class="text-xs font-semibold uppercase tracking-wide text-[var(--setel-text-muted)]">Clareo vs límite SLA</dt>
            <dd class="mt-2 text-sm text-[var(--setel-text)]">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($snap->slaMet !== null && $snap->slaMarginHours !== null): ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($snap->slaMet): ?>
                        <span class="font-medium text-emerald-700 dark:text-emerald-400">Con margen de <?php echo e(number_format($snap->slaMarginHours, 2, ',', '.')); ?> h</span>
                        <span class="mt-1 block text-xs text-[var(--setel-text-muted)]">El clareo fue antes o a la hora del límite.</span>
                    <?php else: ?>
                        <span class="font-medium text-red-700 dark:text-red-400">Retraso de <?php echo e(number_format(abs($snap->slaMarginHours), 2, ',', '.')); ?> h</span>
                        <span class="mt-1 block text-xs text-[var(--setel-text-muted)]">El clareo superó el límite (escala + SLA).</span>
                    <?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($snap->slaEffectivenessPercent !== null): ?>
                        <span class="mt-2 block text-base font-semibold tabular-nums text-[var(--setel-text)]">
                            Efectividad SLA: <?php echo e(number_format($snap->slaEffectivenessPercent, 1, ',', '.')); ?>%
                        </span>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($snap->slaEffectivenessHint): ?>
                            <span class="mt-0.5 block text-xs text-[var(--setel-text-muted)]"><?php echo e($snap->slaEffectivenessHint); ?></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; ?>
                <?php else: ?>
                    <span class="text-[var(--setel-text-muted)]">—</span>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </dd>
        </div>
        <div class="rounded-lg border border-[var(--setel-card-border)] bg-[var(--setel-content-bg)]/80 p-4">
            <dt class="text-xs font-semibold uppercase tracking-wide text-[var(--setel-text-muted)]">Referencia rápida</dt>
            <dd class="mt-2 space-y-1 text-xs tabular-nums text-[var(--setel-text-muted)]">
                <div>Programado: <?php echo e($work->scheduled_date?->format('d/m/Y H:i') ?? '—'); ?></div>
                <div>Escala: <?php echo e($work->scale_datetime?->format('d/m/Y H:i') ?? '—'); ?></div>
                <div>Clareo: <?php echo e($work->clearance_datetime?->format('d/m/Y H:i') ?? '—'); ?></div>
            </dd>
        </div>
    </dl>
</div>
<?php /**PATH C:\laragon\www\setelsat-gilat-manager\resources\views/livewire/works/partials/operational-efficiency-card.blade.php ENDPATH**/ ?>