@if (!blank($trips))
    <div class="col-md-12">
        <div class="radio-wrapper">
            <div class="form-check form--check">
                <input class="form-check-input" id="asc" name="order" type="radio" value="asc" @checked(request()->order == 'asc')>
                <label class="form-check-label" for="asc">
                    @lang('Low to High')
                </label>
            </div>
            <div class="form-check form--check">
                <input class="form-check-input"type="radio" id="desc" name="order" value="desc" @checked(request()->order == 'desc')>
                <label class="form-check-label" for="desc">
                    @lang('High to Low')
                </label>
            </div>
        </div>
    </div>
@endif

<div class="col-md-12">
    <div class="ticket-wrapper">
        @forelse ($trips as $trip)
            @php
                $start = Carbon\Carbon::parse($trip->start_time);
                $end = Carbon\Carbon::parse($trip->expected_end_time);

                if ($end->lt($start)) {
                    $end->addDay();
                }
                $diff = $start->diff($end);
            @endphp

            @if ($trip->base_price)
                <div class="ticket-item">
                    <div class="ticket-item-inner">
                        <h6 class="bus-name">{{ __($trip->title) }}</h6>
                        <p class="m-0">
                            <span class="fw-bold">@lang('Route'):</span>
                            {{ __($trip?->route?->name) }}
                        </p>
                        <span class="ratting"><i class="las la-bus"></i>{{ __($trip?->fleetType?->name) }}</span>
                    </div>
                    <div class="ticket-item-inner travel-time">
                        <div class="bus-time">
                            <p class="time">{{ showDateTime($trip->start_time, 'h:i A') }}</p>
                            <p class="place">{{ __($trip?->startFrom?->name) }}</p>
                        </div>
                        <div class=" bus-time">
                            <i class="las la-arrow-right"></i>
                            <p>{{ $diff->format('%H:%I min') }}</p>
                        </div>
                        <div class=" bus-time">
                            <p class="time">{{ showDateTime($trip->expected_end_time, 'h:i A') }}</p>
                            <p class="place">{{ __($trip?->endTo?->name) }}</p>
                        </div>
                    </div>
                    <div class="ticket-item-inner book-ticket">
                        <p class="rent mb-0">
                            {{ __(gs('cur_sym')) }}{{ showAmount($trip->stoppage_price ?? $trip->base_price, currencyFormat: false) }}
                        </p>
                    </div>
                    <button class="btn btn--base booketTicket" data-trip-id="{{ encrypt($trip->id) }}" data-trip-pickup="{{ request()->pickup }}" data-trip-destination="{{ request()->destination }}" href="{{ route('ticket.seats', [$trip->id, slug($trip->title)]) }}">@lang('Book Ticket')</button>
                    @if (!blank($trip?->fleetType?->facilities))
                        <div class="ticket-item-footer">
                            <div class="d-flex content-justify-center">
                                <span>
                                    <strong>@lang('Facilities')</strong>
                                    @foreach ($trip->fleetType->facilities as $key => $facility)
                                        <span class="facilities">{{ __($facility->name) }}</span>
                                    @endforeach
                                </span>
                            </div>
                        </div>
                    @endif
                </div>
            @endif
        @empty
            <div class="ticket-item justify-content-center">
                <p class="text-center h5 fw-bold">{{ __($emptyMessage) }}</p>
            </div>
        @endforelse
        @if ($trips->hasPages())
            <div>
                {{ paginateLinks($trips) }}
            </div>
        @endif
    </div>
</div>
