<x-app-layout>
    <x-slot name="header">{{ __('app.rosters') }}</x-slot>

    <div class="mb-3 d-flex justify-content-between align-items-center">
        <span class="text-muted small">{{ $rosters->total() }} {{ __('entries') }}</span>
        <a href="{{ route('rosters.create') }}" class="btn btn-primary btn-sm">
            <i class="bi bi-calendar-plus me-1"></i>{{ __('Add Roster') }}
        </a>
    </div>

    <div class="card shadow-sm">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="table-dark">
                        <tr>
                            <th>#</th>
                            <th>{{ __('Employee') }}</th>
                            <th>{{ __('Duty Date') }}</th>
                            <th>{{ __('Shift') }}</th>
                            <th>{{ __('Time') }}</th>
                            <th>{{ __('Duty Title') }}</th>
                            <th>{{ __('Notes') }}</th>
                            <th class="text-end">{{ __('Actions') }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($rosters as $roster)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td><strong>{{ $roster->employee->name ?? '-' }}</strong></td>
                                <td>{{ $roster->duty_date }}</td>
                                <td><span class="badge bg-info text-dark text-capitalize">{{ $roster->shift }}</span></td>
                                <td>{{ $roster->starts_at ? $roster->starts_at . ' - ' . $roster->ends_at : '-' }}</td>
                                <td>{{ $roster->duty_title ?? '-' }}</td>
                                <td>{{ $roster->notes ?? '-' }}</td>
                                <td class="text-end">
                                    <form method="POST" action="{{ route('rosters.destroy', $roster) }}" class="d-inline" onsubmit="return confirm('Delete this entry?')">
                                        @csrf @method('DELETE')
                                        <button class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
                                    </form>
                                </td>
                            </tr>
                        @empty
                            <tr><td colspan="8" class="text-center text-muted py-4">No roster entries found.</td></tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="mt-3">{{ $rosters->links() }}</div>
</x-app-layout>
