@php
    use Illuminate\Support\Carbon;
@endphp

<div class="card border-0 shadow-sm h-100">
    <div class="card-header bg-white fw-semibold" style="color: {{ config('theme.colors.text') }};">
        {{ __('operational_ui.workflow_inbox.section_sales') }}
    </div>
    <div class="card-body small">
        @if ($salesInbox === null)
            <p class="text-muted mb-0">{{ __('operational_ui.workflow_inbox.empty_sales') }}</p>
        @else
            <ul class="list-unstyled mb-0">
                @forelse ($salesInbox as $o)
                    @php
                        $hours = $o->updated_at ? Carbon::parse($o->updated_at)->diffInHours(Carbon::now()) : 0;
                        $variant = $hours >= 72 ? 'danger' : ($hours >= 24 ? 'warning' : 'muted');
                    @endphp
                    <li class="mb-2 d-flex flex-wrap justify-content-between gap-2 align-items-center">
                        <a href="{{ route('sales.orders.show', $o) }}">{{ $o->displayOrderNumber() }}</a>
                        <x-ui.operational.status-badge
                            :label="__('operational_ui.workflow_inbox.aging_label').': '.$hours.'h'"
                            :variant="$variant"
                        />
                    </li>
                @empty
                    <li class="text-muted">—</li>
                @endforelse
            </ul>
        @endif
    </div>
</div>
