<div>
    <div style="margin-bottom: 10px;">
        <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">{{ trans('mytransactions.close') }}</button>
    </div>

    <table class="table table-bordered" style="margin-bottom: 15px;">
        <tbody>
            <tr>
                <th style="width: 25%;">{{ trans('mytransactions.order-id') }}</th>
                <td>{{ $order->order_id ?? '' }}</td>
            </tr>
            <tr>
                <th>{{ trans('mytransactions.carrier') }}</th>
                <td>{{ strtoupper(str_replace('_', ' ', (string) $carrier)) }}</td>
            </tr>
            <tr>
                <th>{{ trans('mytransactions.service') }}</th>
                <td>{{ $shippingService !== '' ? $shippingService : '-' }}</td>
            </tr>
            <tr>
                <th>{{ trans('mytransactions.tracking-number') }}</th>
                <td>{{ $trackingNumber !== '' ? $trackingNumber : '-' }}</td>
            </tr>
        </tbody>
    </table>

    @if(!empty($errorMessage))
        <div class="alert alert-warning">
            {{ $errorMessage }}
        </div>
    @endif

    @if(is_array($trackingData) && !($trackingData['error'] ?? false))

        @if($carrier === 'canada_post')
            @php
                $info = $trackingData['tracking_info'][0] ?? null;
            @endphp

            @if(is_array($info))
                <div class="alert alert-info" style="margin-bottom: 10px;">
                    <b>{{ trans('mytransactions.status') }}:</b> {{ $info['status'] ?? trans('mytransactions.unknown') }}
                    @if(!empty($info['event_description']))
                        <br />
                        <b>{{ trans('mytransactions.last-update') }}:</b> {{ $info['event_description'] }}
                    @endif
                    @if(!empty($info['event_date_time']))
                        <br />
                        <b>{{ trans('mytransactions.date') }}:</b> {{ $info['event_date_time'] }}
                    @endif
                    @if(!empty($info['event_location']))
                        <br />
                        <b>{{ trans('mytransactions.location') }}:</b> {{ $info['event_location'] }}
                    @endif
                    @if(!empty($info['expected_delivery_date']))
                        <br />
                        <b>{{ trans('mytransactions.expected-delivery') }}:</b> {{ $info['expected_delivery_date'] }}
                    @endif
                    @if(!empty($info['actual_delivery_date']))
                        <br />
                        <b>{{ trans('mytransactions.delivered') }}:</b> {{ $info['actual_delivery_date'] }}
                    @endif
                </div>
            @else
                <div class="alert alert-warning">{{ trans('mytransactions.no-tracking-updates-found') }}</div>
            @endif

        @else
            @if(!empty($trackingData['summary']))
                <div class="alert alert-info" style="margin-bottom: 10px;">
                    {{ $trackingData['summary'] }}
                </div>
            @endif

            @if(!empty($trackingData['details']) && is_array($trackingData['details']))
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <b>{{ trans('mytransactions.tracking-history') }}</b>
                    </div>
                    <div class="panel-body">
                        <ul style="margin:0; padding-left: 18px;">
                            @foreach($trackingData['details'] as $line)
                                <li style="margin: 6px 0;">{{ $line }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
            @endif
        @endif

    @elseif(empty($errorMessage))
        <div class="alert alert-warning">{{ trans('mytransactions.tracking-not-available') }}</div>
    @endif
</div>
