@extends('layout')

@section('title', __('store/reseller.my_orders'))

@section('content')
<div class="container py-5">
    <x-clientarea.page-header
        icon="fas fa-store"
        :title="__('store/reseller.my_orders')"
    >
        <a href="{{ route('store.auth.reseller.dashboard') }}" class="btn btn-outline-secondary">
            <i class="fas fa-arrow-left me-1"></i>{{ __('store/reseller.dashboard') }}
        </a>
    </x-clientarea.page-header>

    <div class="card shadow-sm border-0">
        <div class="card-body p-0">
            @if($orders->isEmpty())
                <div class="text-center py-5 text-muted">
                    <i class="fas fa-shopping-cart fa-3x mb-3 d-block"></i>
                    {{ __('store/reseller.no_orders') }}
                </div>
            @else
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead><tr>
                            <th>{{ __('store/reseller.order_number') }}</th>
                            <th>{{ __('store/reseller.order_client') }}</th>
                            <th>{{ __('store/reseller.order_total') }}</th>
                            <th>{{ __('store/reseller.order_status') }}</th>
                            <th>{{ __('store/reseller.order_date') }}</th>
                        </tr></thead>
                        <tbody>
                        @foreach($orders as $order)
                            <tr>
                                <td>{{ $order->order_number }}</td>
                                <td>{{ $order->client?->first_name }} {{ $order->client?->last_name }}</td>
                                <td>{{ number_format($order->total, 2) }}</td>
                                <td>
                                    @if($order->payment_status === 'completed')
                                        <span class="badge bg-success">Paid</span>
                                    @elseif($order->payment_status === 'pending')
                                        <span class="badge bg-warning">Pending</span>
                                    @else
                                        <span class="badge bg-secondary">{{ ucfirst($order->payment_status) }}</span>
                                    @endif
                                </td>
                                <td>{{ $order->created_at->format('d.m.Y H:i') }}</td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>

                <div class="d-flex justify-content-center py-3">
                    {{ $orders->links() }}
                </div>
            @endif
        </div>
    </div>
</div>
@endsection
