@extends('layouts.admin')
@section('title', 'Pedidos RGPD')
@section('content')
<div class="page-header"><h1>Pedidos RGPD</h1></div>
@forelse($requests as $r)
<div class="card">
    <div style="display:flex; justify-content:space-between; align-items:start; gap:1rem; flex-wrap:wrap;">
        <div>
            <strong>{{ $r->nome_completo }}</strong> · {{ $r->email }} @if($r->nif) · NIF: {{ $r->nif }} @endif<br>
            <span class="badge {{ $r->status === 'pendente' ? 'badge-warning' : ($r->status === 'concluido' ? 'badge-success' : 'badge-info') }}">{{ ucfirst(str_replace('_', ' ', $r->status)) }}</span>
            · {{ \App\Models\RgpdRequest::TIPOS[$r->tipo_pedido] ?? $r->tipo_pedido }}
            · {{ $r->created_at->format('d/m/Y H:i') }}
            <p style="margin-top:0.5rem;">{{ $r->descricao }}</p>
            @if($r->resposta)<p style="color:var(--success); margin-top:0.3rem;"><strong>Resposta:</strong> {{ $r->resposta }}</p>@endif
        </div>
        <form method="POST" action="{{ route('admin.rgpd-requests.update', $r) }}" style="min-width:200px;">@csrf
            <select name="status" class="form-control" style="margin-bottom:0.5rem;"><option value="pendente" {{ $r->status == 'pendente' ? 'selected' : '' }}>Pendente</option><option value="em_tratamento" {{ $r->status == 'em_tratamento' ? 'selected' : '' }}>Em tratamento</option><option value="concluido" {{ $r->status == 'concluido' ? 'selected' : '' }}>Concluido</option></select>
            <textarea name="resposta" class="form-control" rows="2" placeholder="Resposta...">{{ $r->resposta }}</textarea>
            <button type="submit" class="btn btn-primary btn-sm" style="width:100%; margin-top:0.5rem;">Atualizar</button>
        </form>
    </div>
</div>
@empty
<div class="card"><p style="text-align:center; color:var(--muted);">Sem pedidos RGPD.</p></div>
@endforelse
<div class="pagination">{{ $requests->links('components.pagination') }}</div>
@endsection
