@extends('layouts.app')
@section('title', 'My Payslips')
@section('content')
<div class="card">
    <div class="card-header pb-0"><h6>My Payslips</h6></div>
    <div class="card-body">
        <div class="row">
        @forelse($payslips as $p)
            <div class="col-md-4 mb-3">
                <div class="card border">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-start">
                            <div><h6 class="mb-0">{{ $p->periodLabel() }}</h6>
                                <span class="text-sm text-muted">Nett RM {{ number_format($p->nett_pay,2) }}</span></div>
                            <div class="icon icon-shape bg-gradient-primary rounded-circle text-center" style="width:38px;height:38px"><i class="bi bi-cash text-white"></i></div>
                        </div>
                        <a href="{{ route('payslips.pdf', $p) }}" class="btn btn-sm btn-primary w-100 mt-3 mb-0"><i class="bi bi-download me-1"></i>Download PDF</a>
                    </div>
                </div>
            </div>
        @empty
            <div class="col-12 text-center text-muted py-4">No payslips available yet.</div>
        @endforelse
        </div>
        <div class="mt-2">{{ $payslips->links() }}</div>
    </div>
</div>
@endsection
