@extends('layouts.app')
@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
  <div class="row g-4">
    <div class="col-md-4"><div class="card"><div class="card-header"><h6 class="mb-0">Add Trust Event</h6></div><div class="card-body">
      @can('create trust score')
      <form method="POST" action="{{ route('admin.trust-scores.store') }}" class="row g-2">@csrf
        <div class="col-12"><select name="user_id" class="form-select" required><option value="">Select user</option>@foreach($users as $user)<option value="{{ $user->id }}">{{ $user->name }} ({{ $user->email }})</option>@endforeach</select></div>
        <div class="col-12"><input type="number" step="0.01" name="score_change" class="form-control" placeholder="Score change" required></div>
        <div class="col-12"><input name="reason" class="form-control" placeholder="Reason"></div>
        <div class="col-12"><textarea name="notes" class="form-control" placeholder="Notes"></textarea></div>
        <div class="col-12 d-grid"><button class="btn btn-primary">Save</button></div>
      </form>
      @else
      <div class="text-muted">You do not have permission to add trust events.</div>
      @endcan
    </div></div></div>
    <div class="col-md-8"><div class="card"><div class="card-header"><h5 class="mb-0">Trust Score Logs</h5></div><div class="table-responsive"><table class="table"><thead><tr><th>User</th><th>Change</th><th>Reason</th><th>Reviewer</th><th></th></tr></thead><tbody>
      @foreach($trustScores as $score)
      <tr><td>{{ $score->user->name ?? 'N/A' }}</td><td>{{ $score->score_change }}</td><td>{{ $score->reason }}</td><td>{{ $score->reviewer->name ?? 'System' }}</td><td>@can('delete trust score')<form method="POST" action="{{ route('admin.trust-scores.destroy',$score) }}">@csrf @method('DELETE')<button class="btn btn-sm btn-outline-danger">Delete</button></form>@else<span class="text-muted">-</span>@endcan</td></tr>
      @endforeach
    </tbody></table></div><div class="card-body">{{ $trustScores->links() }}</div></div></div>
  </div>
</div>
@endsection
