@layout('theme::layouts/admin')

@section('title')Mod Log@endsection
@section('page_title')Moderation Log@endsection

@section('content')

<div class="admin-card">
    <div class="admin-card-header">{{ $total }} log entries</div>

    @notempty($entries)
    <table class="admin-table">
        <thead>
            <tr>
                <th>Moderator</th>
                <th>Action</th>
                <th>Content</th>
                <th>Date</th>
            </tr>
        </thead>
        <tbody>
            @each ($entries as $entry)
            <tr>
                <td><strong>{{ $users[(int)$entry['user_id']]['username'] ?? 'Unknown' }}</strong></td>
                <td>
                    <span class="mod-action-badge mod-action-{{ $entry['action'] }}">{{ $entry['action'] }}</span>
                </td>
                <td>
                    <span class="type-badge type-{{ $entry['content_type'] }}">{{ $entry['content_type'] }}</span>
                    @notempty($entry['content_title'] ?? '')
                    {{ $entry['content_title'] }}
                    @endnotempty
                    @if(empty($entry['content_title']))
                    #{{ $entry['content_id'] }}
                    @endif
                </td>
                <td class="admin-cell-note">{{ date('M j, Y g:ia', strtotime($entry['created_at'])) }}</td>
            </tr>
            @endeach
        </tbody>
    </table>
    @endnotempty

    @if(empty($entries))
    <div class="admin-empty">
        <p>No moderation actions recorded yet.</p>
    </div>
    @endif
</div>

@if($totalPages > 1)
<div class="admin-pagination">
    @if($page > 1)
    <a href="/admin/moderation/log?page={{ $page - 1 }}" class="admin-btn admin-btn-outline admin-btn-sm">&laquo; Previous</a>
    @endif
    <span class="admin-pagination-info">Page {{ $page }} of {{ $totalPages }}</span>
    @if($page < $totalPages)
    <a href="/admin/moderation/log?page={{ $page + 1 }}" class="admin-btn admin-btn-outline admin-btn-sm">Next &raquo;</a>
    @endif
</div>
@endif

@endsection
