@extends('layouts.admin')

@section('title', __('admin.audit_logs.title'))

@section('content')
<form method="GET" class="card-arena p-4 mb-4">
    <div class="input-group">
        <input type="search" name="action" value="{{ request('action') }}" class="form-control" placeholder="{{ __('admin.audit_logs.action') }}">
        <button class="btn-arena btn-primary">{{ __('admin.actions.search') }}</button>
    </div>
</form>

<div class="card-arena overflow-hidden">
    <div class="table-responsive">
        <table class="table table-dark table-hover mb-0">
            <thead>
                <tr>
                    <th>{{ __('admin.audit_logs.timestamp') }}</th>
                    <th>{{ __('admin.audit_logs.actor') }}</th>
                    <th>{{ __('admin.audit_logs.action') }}</th>
                    <th>{{ __('admin.audit_logs.subject') }}</th>
                </tr>
            </thead>
            <tbody>
                @forelse($logs as $log)
                    <tr>
                        <td>{{ $log->created_at->format('Y-m-d H:i:s') }}</td>
                        <td>{{ $log->user?->username ?? 'System' }}</td>
                        <td><code>{{ $log->action }}</code></td>
                        <td>{{ $log->subject_type ? class_basename($log->subject_type).' #'.$log->subject_id : '—' }}</td>
                    </tr>
                @empty
                    <tr><td colspan="4" class="text-center py-5 text-muted">{{ __('admin.empty.no_results') }}</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>

<div class="mt-4">{{ $logs->links() }}</div>
@endsection
