@extends('layouts.app')
@section('title', 'Concessions')
@section('page_title', 'Concessions & Scholarships')
@section('breadcrumbs')
    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Home</a></li><li class="breadcrumb-item active">Concessions</li>
@endsection
@section('page_actions')
    @can('fees.update')<a href="{{ route('concessions.create') }}" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>Add Concession</a>@endcan
@endsection

@section('content')
    <div class="card"><div class="card-body">
        <table class="table table-hover align-middle js-datatable">
            <thead><tr><th>Student</th><th>Scholarship</th><th>Applies To</th><th>Discount</th><th>Reason</th><th class="text-end">Actions</th></tr></thead>
            <tbody>
                @foreach($concessions as $c)
                    <tr>
                        <td><a href="{{ route('students.show', $c->student_id) }}" class="fw-semibold text-decoration-none">{{ $c->student?->name }}</a></td>
                        <td><span class="badge bg-soft-warning text-capitalize">{{ str_replace('_',' ',$c->scholarship_type) }}</span></td>
                        <td class="small">{{ $c->feeType?->name ?? 'All heads' }}</td>
                        <td><span class="badge bg-soft-primary">{{ $c->type === 'percentage' ? rtrim(rtrim($c->value,'0'),'.').'%' : 'Rs '.number_format($c->value) }}</span></td>
                        <td class="small text-muted">{{ $c->reason ?: '—' }}</td>
                        <td class="text-end">
                            @can('fees.update')<form method="POST" action="{{ route('concessions.destroy', $c) }}" class="d-inline" data-confirm="Remove concession?">@csrf @method('DELETE')<button class="btn btn-sm btn-light border text-danger"><i class="bi bi-trash"></i></button></form>@endcan
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div></div>
@endsection
