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

<h1 style="font-size:22px;margin-bottom:16px;">Salut, {{ $customer->name }}!</h1>

<div class="card" style="margin-bottom:16px;">
    <h3 style="font-size:15px;margin-bottom:10px;">Date contact</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;">Comenzile mele ({{ $orders->count() }})</h2>

@if ($orders->isEmpty())
    <div class="card" style="text-align:center;padding:32px;">
        <p class="muted">Nu ai nicio comandă încă.</p>
        <a class="btn" href="/shop" style="margin-top:12px;">Vezi catalogul</a>
    </div>
@else
    <div class="card">
        <table class="cart">
            <thead>
                <tr>
                    <th>Nr.</th><th>Data</th><th>Articole</th><th class="r">Total</th><th>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;">Detalii →</a></td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
@endif
@endsection
