<div>
    @if($history->isEmpty())
        <div class="text-center p-5 text-muted">
            <i class="mdi mdi-history" style="font-size: 48px;"></i>
            <p class="mt-3 fw-bold">No history found for this user.</p>
        </div>
    @else
        <div class="card shadow-sm border-0">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover mb-0 align-middle">
                        <thead class="table-light">
                            <tr>
                                <th>Action</th>
                                <th>Context</th>
                                <th>Date &amp; Time</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($history as $item)
                                <tr>
                                    <td>{{ $item->action }}</td>
                                    <td>
                                        @if($item->context)
                                            <code class="small">{{ json_encode($item->context) }}</code>
                                        @else
                                            <span class="text-muted">—</span>
                                        @endif
                                    </td>
                                    <td class="text-nowrap">
                                        <span title="{{ $item->created_at->format('d/m/Y H:i:s') }}">
                                            {{ $item->created_at->diffForHumans() }}
                                        </span>
                                        <div class="text-muted small">{{ $item->created_at->format('d/m/Y H:i') }}</div>
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="mt-3">
            {{ $history->links() }}
        </div>
    @endif
</div>
