<div class="row">
    <div class="col-md-6">
        <h6 class="text-muted">{{ __('Request Information') }}</h6>
        <table class="table table-sm">
            <tr>
                <th width="30%">{{ __('ID') }}:</th>
                <td>{{ $log->id }}</td>
            </tr>
            <tr>
                <th>{{ __('User') }}:</th>
                <td>
                    @if($log->user)
                        {{ $log->user->name }} ({{ $log->user->email }})
                    @else
                        <span class="text-muted">{{ __('System') }}</span>
                    @endif
                </td>
            </tr>
            <tr>
                <th>{{ __('Module') }}:</th>
                <td><span class="badge bg-label-primary">{{ $log->module_name }}</span></td>
            </tr>
            <tr>
                <th>{{ __('Operation') }}:</th>
                <td>{{ $log->operation_type }}</td>
            </tr>
            <tr>
                <th>{{ __('Model') }}:</th>
                <td>
                    @if($log->model)
                        <span class="badge bg-label-info">
                            {{ $log->model->provider->name }} - {{ $log->model->name }}
                        </span>
                    @else
                        <span class="text-muted">{{ $log->model_name ?: __('Unknown') }}</span>
                    @endif
                </td>
            </tr>
            <tr>
                <th>{{ __('Status') }}:</th>
                <td>
                    @php
                        $statusClass = [
                            'success' => 'bg-label-success',
                            'error' => 'bg-label-danger',
                            'pending' => 'bg-label-warning',
                            'timeout' => 'bg-label-secondary'
                        ][$log->status] ?? 'bg-label-secondary';
                    @endphp
                    <span class="badge {{ $statusClass }}">{{ ucfirst($log->status) }}</span>
                </td>
            </tr>
            <tr>
                <th>{{ __('Created At') }}:</th>
                <td>{{ $log->created_at->format('Y-m-d H:i:s') }}</td>
            </tr>
        </table>
    </div>
    
    <div class="col-md-6">
        <h6 class="text-muted">{{ __('Usage & Performance') }}</h6>
        <table class="table table-sm">
            <tr>
                <th width="30%">{{ __('Prompt Tokens') }}:</th>
                <td>{{ number_format($log->prompt_tokens) }}</td>
            </tr>
            <tr>
                <th>{{ __('Completion Tokens') }}:</th>
                <td>{{ number_format($log->completion_tokens) }}</td>
            </tr>
            <tr>
                <th>{{ __('Total Tokens') }}:</th>
                <td><strong>{{ number_format($log->total_tokens) }}</strong></td>
            </tr>
            <tr>
                <th>{{ __('Cost') }}:</th>
                <td><strong>${{ number_format($log->cost, 4) }}</strong></td>
            </tr>
            <tr>
                <th>{{ __('Processing Time') }}:</th>
                <td>{{ $log->processing_time_ms ? number_format($log->processing_time_ms) . ' ms' : '-' }}</td>
            </tr>
            <tr>
                <th>{{ __('Flagged') }}:</th>
                <td>
                    @if($log->is_flagged)
                        <span class="badge bg-label-danger">{{ __('Yes') }}</span>
                    @else
                        <span class="badge bg-label-secondary">{{ __('No') }}</span>
                    @endif
                </td>
            </tr>
        </table>
    </div>
</div>

<div class="row mt-3">
    <div class="col-12">
        <h6 class="text-muted">{{ __('Request Prompt') }}</h6>
        <div class="card bg-light">
            <div class="card-body">
                <pre class="mb-0" style="white-space: pre-wrap; word-wrap: break-word;">{{ $log->request_prompt }}</pre>
            </div>
        </div>
    </div>
</div>

@if($log->response_content)
<div class="row mt-3">
    <div class="col-12">
        <h6 class="text-muted">{{ __('Response Content') }}</h6>
        <div class="card bg-light">
            <div class="card-body">
                <pre class="mb-0" style="white-space: pre-wrap; word-wrap: break-word;">{{ $log->response_content }}</pre>
            </div>
        </div>
    </div>
</div>
@endif

@if($log->error_message)
<div class="row mt-3">
    <div class="col-12">
        <h6 class="text-muted text-danger">{{ __('Error Details') }}</h6>
        <div class="card border-danger">
            <div class="card-body">
                <p class="mb-1"><strong>{{ __('Error Code') }}:</strong> {{ $log->error_code ?: '-' }}</p>
                <p class="mb-0"><strong>{{ __('Error Message') }}:</strong></p>
                <pre class="mb-0 text-danger" style="white-space: pre-wrap; word-wrap: break-word;">{{ $log->error_message }}</pre>
            </div>
        </div>
    </div>
</div>
@endif

@if($log->reviewed_at)
<div class="row mt-3">
    <div class="col-12">
        <h6 class="text-muted">{{ __('Review Information') }}</h6>
        <div class="card">
            <div class="card-body">
                <p class="mb-1">
                    <strong>{{ __('Reviewed By') }}:</strong> 
                    {{ $log->reviewer ? $log->reviewer->name : __('Unknown') }}
                </p>
                <p class="mb-1">
                    <strong>{{ __('Reviewed At') }}:</strong> 
                    {{ $log->reviewed_at->format('Y-m-d H:i:s') }}
                </p>
                @if($log->admin_notes)
                    <p class="mb-0"><strong>{{ __('Admin Notes') }}:</strong></p>
                    <div class="alert alert-info mb-0">
                        {{ $log->admin_notes }}
                    </div>
                @endif
            </div>
        </div>
    </div>
</div>
@endif

@if($log->request_options)
<div class="row mt-3">
    <div class="col-12">
        <h6 class="text-muted">{{ __('Request Options') }}</h6>
        <div class="card">
            <div class="card-body">
                <pre class="mb-0" style="white-space: pre-wrap; word-wrap: break-word;">{{ json_encode($log->request_options, JSON_PRETTY_PRINT) }}</pre>
            </div>
        </div>
    </div>
</div>
@endif