@extends('layouts.app')

@push('styles')
<link rel="stylesheet" href="{{ asset('css/adminHeader.css') }}">
@endpush

@section('content')
<div class="container">
    <div class="admin-header-box mb-4">
        <div>
            <h4>Responden: {{ $survey->title }}</h4>
            <p>Senarai pengguna yang telah menjawab borang ini.</p>
        </div>
        <a href="{{ route('admin.responses.list') }}" class="btn btn-sm btn-light px-3 fw-bold text-primary">
            <i class="bi bi-arrow-left"></i> Kembali
        </a>
    </div>

    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white">
            <h5 class="mb-0">Jumlah Responden: {{ $responses->count() }}</h5>
        </div>
        <div class="card-body p-0">
            @if($responses->isEmpty())
                <div class="alert alert-info mb-0 p-4">
                    Belum ada responden yang menjawab borang ini.
                </div>
            @else
                <div class="table-responsive">
                    <table class="table table-striped table-hover mb-0">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Responden</th>
                                <th>Nombor Pekerja</th>
                                <th>Tarikh Jawab</th>
                                <th>Tindakan</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($responses as $index => $response)
                            <tr>
                                <td>{{ $index + 1 }}</td>
                                <td>
                                    {{-- Klik nama/butang untuk ke halaman detail.blade.php --}}
                                    <a href="{{ route('admin.responses.detail', $response->id) }}" class="text-primary fw-bold">
                                        {{ $response->respondent_name ?? '-' }}
                                    </a>
                                </td>
                                <td>{{ $response->respondent_no_pekerja ?? '-' }}</td>
                                <td>{{ $response->created_at->format('d M Y') }}</td>
                                <td>
                                    <a href="{{ route('admin.responses.detail', $response->id) }}" class="btn btn-sm btn-info text-white">
                                        Lihat Jawapan
                                    </a>
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            @endif
        </div>
    </div>
</div>
@endsection
