@extends('shop.layout')
@section('title', __('portal.shop.my_account'))
@section('content')
@php
    $currency = $tenant->settings['currency'] ?? 'MDL';
    $statuses = \App\Models\Tenant\OnlineOrder::STATUSES;
@endphp

<h1 style="font-size:22px;margin-bottom:16px;">{{ __('portal.shop.hello_name', ['name' => $customer->name]) }}</h1>

<div class="card" style="margin-bottom:16px;">
    <h3 style="font-size:15px;margin-bottom:10px;">{{ __('portal.shop.contact_data') }}</h3>
    <p class="muted">📞 {{ $customer->phone }}</p>
    @if ($customer->email)<p class="muted">✉️ {{ $customer->email }}</p>@endif
</div>

<h2 style="font-size:18px;margin-bottom:12px;">{{ __('portal.shop.my_orders', ['count' => $orders->count()]) }}</h2>

@if ($orders->isEmpty())
    <div class="card" style="text-align:center;padding:32px;">
        <p class="muted">{{ __('portal.shop.no_orders_yet') }}</p>
        <a class="btn" href="/shop" style="margin-top:12px;">{{ __('portal.shop.view_catalog') }}</a>
    </div>
@else
    <div class="card">
        <table class="cart">
            <thead>
                <tr>
                    <th>{{ __('portal.shop.order_nr') }}</th><th>{{ __('portal.shop.order_date') }}</th><th>{{ __('portal.shop.order_items') }}</th><th class="r">{{ __('portal.common.total') }}</th><th>{{ __('portal.shop.status') }}</th><th></th>
                </tr>
            </thead>
            <tbody>
                @foreach ($orders as $order)
                    <tr>
                        <td><strong>#{{ $order->number }}</strong></td>
                        <td>{{ $order->created_at->format('d.m.Y') }}</td>
                        <td>{{ $order->items()->count() }}</td>
                        <td class="r">{{ number_format((float) $order->total, 2) }} {{ $currency }}</td>
                        <td><span class="status-pill" style="font-size:11px;">{{ $statuses[$order->status] ?? $order->status }}</span></td>
                        <td><a href="{{ $order->trackingUrl() }}" class="muted" style="text-decoration:underline;">{{ __('portal.shop.order_details_arrow') }}</a></td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
@endif
@endsection
