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

@section('content')
    <div class="card"><div class="card-body">
        <table class="table table-hover align-middle">
            <thead><tr><th>Registration</th><th>Model</th><th class="text-center">Capacity</th><th>Driver</th><th>Phone</th><th>Route</th><th class="text-center">Status</th><th class="text-end">Actions</th></tr></thead>
            <tbody>
                @forelse($vehicles as $v)
                    <tr>
                        <td class="fw-semibold">{{ $v->registration_no }}</td>
                        <td>{{ $v->model ?: '—' }}</td>
                        <td class="text-center">{{ $v->capacity ?: '—' }}</td>
                        <td>{{ $v->driver_name ?: '—' }}</td>
                        <td class="small">{{ $v->driver_phone ?: '—' }}</td>
                        <td class="small">{{ $v->route?->name ?? '—' }}</td>
                        <td class="text-center">@if($v->is_active)<span class="badge bg-soft-success">Active</span>@else<span class="badge bg-soft-danger">Inactive</span>@endif</td>
                        <td class="text-end">
                            @can('transport.update')<a href="{{ route('vehicles.edit', $v) }}" class="btn btn-sm btn-light border"><i class="bi bi-pencil"></i></a>@endcan
                            @can('transport.delete')<form method="POST" action="{{ route('vehicles.destroy', $v) }}" class="d-inline" data-confirm="Delete vehicle?">@csrf @method('DELETE')<button class="btn btn-sm btn-light border text-danger"><i class="bi bi-trash"></i></button></form>@endcan
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="8" class="text-center text-muted py-4">No vehicles yet.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div></div>
@endsection
