@extends('layouts.app')

@section('title', 'Audit Log Detail - NGBVD')

@section('content')
<div class="ngbvd-page-hero">
    <div class="ngbvd-page-hero-icon"><i class="ti-search"></i></div>
    <div>
        <h2>Audit Log Detail</h2>
        <p>{{ optional($log->occurred_at)->format('Y-m-d H:i:s') }} · {{ $log->module }} · {{ $log->action }}</p>
    </div>
    <div class="ml-auto"><a href="{{ url('/audit/logs') }}" class="btn ngbvd-btn-soft"><i class="ti-arrow-left"></i> Back</a></div>
</div>

<div class="row">
    <div class="col-lg-5">
        <div class="ngbvd-modern-grid-card">
            <h4>Activity Summary</h4>
            <table class="table table-sm">
                <tr><th>User</th><td>{{ $log->username ?: 'System' }}<br><small>{{ $log->user_email }}</small></td></tr>
                <tr><th>Role</th><td>{{ $log->user_role }}</td></tr>
                <tr><th>Module</th><td>{{ $log->module }}</td></tr>
                <tr><th>Action</th><td>{{ $log->action }}</td></tr>
                <tr><th>Status</th><td>{{ $log->status }}</td></tr>
                <tr><th>Response</th><td>{{ $log->response_code }}</td></tr>
                <tr><th>IP</th><td>{{ $log->ip_address }}</td></tr>
                <tr><th>Method</th><td>{{ $log->method }}</td></tr>
                <tr><th>URL</th><td style="word-break:break-all;">{{ $log->url }}</td></tr>
            </table>
        </div>
    </div>
    <div class="col-lg-7">
        <div class="ngbvd-modern-grid-card mb-3">
            <h4>Request Payload</h4>
            <pre class="bg-light p-3 rounded" style="white-space:pre-wrap;max-height:360px;overflow:auto;">{{ json_encode($log->request_payload, JSON_PRETTY_PRINT) }}</pre>
        </div>
        <div class="ngbvd-modern-grid-card">
            <h4>Metadata</h4>
            <pre class="bg-light p-3 rounded" style="white-space:pre-wrap;max-height:360px;overflow:auto;">{{ json_encode($log->metadata, JSON_PRETTY_PRINT) }}</pre>
        </div>
    </div>
</div>
@endsection
