@extends('layouts.app')

@section('title', __('labCore::lang.lab_core') . ' — ' . __('labCore::lang.logs'))

@section('content')
<section class="content-header">
    <h1><i class="fas fa-vials"></i> {{ __('labCore::lang.lab_core') }} <small>{{ __('labCore::lang.logs') }}</small></h1>
</section>

<section class="content">
    @include('labCore::partials._nav')

    <div class="box box-solid">
        <div class="box-header with-border">
            <h3 class="box-title">Communication Logs</h3>
            <div class="box-tools">
                <form method="POST" action="{{ route('lab.logs.clear') }}" onsubmit="return confirm('Clear all communication logs?');">
                    @csrf @method('DELETE')
                    <button class="btn btn-danger btn-sm"><i class="fa fa-trash"></i> Clear</button>
                </form>
            </div>
        </div>
        <div class="box-body no-padding">
            <table class="table table-striped">
                <thead>
                    <tr><th>Time</th><th>Level</th><th>Category</th><th>Vendor</th><th>Message</th></tr>
                </thead>
                <tbody>
                @forelse($logs as $log)
                    <tr>
                        <td><small>{{ $log->created_at?->format('Y-m-d H:i:s') }}</small></td>
                        <td><span class="label {{ $log->level_badge }}">{{ $log->level }}</span></td>
                        <td>{{ $log->category }}</td>
                        <td>{{ $log->vendor ?: '—' }}</td>
                        <td>{{ $log->message }}</td>
                    </tr>
                @empty
                    <tr><td colspan="5" class="text-muted">{{ __('labCore::lang.no_data') }}</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        @if($logs->hasPages())
            <div class="box-footer">{{ $logs->links() }}</div>
        @endif
    </div>
</section>
@endsection
