@php
    $emailPrimary = \App\Models\Setting::get('primary_color', '#b66420');
    $emailSecondary = \App\Models\Setting::get('secondary_color', '#d3901d');
@endphp
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Confirmation de commande</title>
    <style>
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #334155; margin: 0; padding: 0; background: #f8fafc; }
        .container { max-width: 600px; margin: 0 auto; padding: 24px; }
        .card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-top: 4px solid {{ $emailPrimary }}; }
        h1 { color: #0f172a; font-size: 20px; margin: 0 0 16px 0; }
        .order-number { font-weight: 700; color: {{ $emailPrimary }}; font-size: 18px; }
        table { width: 100%; border-collapse: collapse; margin: 16px 0; }
        th, td { padding: 10px 0; border-bottom: 1px solid #e2e8f0; text-align: left; }
        th { color: #64748b; font-weight: 500; font-size: 13px; }
        .total { font-weight: 700; font-size: 18px; color: {{ $emailSecondary }}; }
        .footer { margin-top: 24px; font-size: 13px; color: #94a3b8; }
    </style>
</head>
<body>
    <div class="container">
        <div class="card">
            <h1>Merci pour votre commande !</h1>
            <p>Bonjour {{ $order->customer_name }},</p>
            <p>Votre commande a bien été enregistrée.</p>
            <p class="order-number">N° de commande : {{ $order->number }}</p>

            <table>
                <thead>
                    <tr><th>Produit</th><th>Qté</th><th>Prix</th></tr>
                </thead>
                <tbody>
                    @foreach($order->items as $item)
                    <tr>
                        <td>{{ $item['name'] ?? 'Produit' }}</td>
                        <td>{{ $item['qty'] ?? 1 }}</td>
                        <td>{{ number_format(($item['total'] ?? 0), 2, ',', ' ') }} €</td>
                    </tr>
                    @endforeach
                </tbody>
            </table>

            <p><strong>Sous-total :</strong> {{ number_format($order->subtotal, 2, ',', ' ') }} €</p>
            @if($order->shipping_cost > 0)
            <p><strong>Livraison :</strong> {{ number_format($order->shipping_cost, 2, ',', ' ') }} €</p>
            @endif
            <p class="total">Total : {{ number_format($order->total, 2, ',', ' ') }} €</p>

            <p><strong>Adresse de livraison :</strong><br>
            {{ $order->customer_address }}<br>
            {{ $order->customer_postal_code }} {{ $order->customer_city }}<br>
            {{ $order->customer_country }}</p>

            @if($order->shipping_relay_label)
            <p><strong>Point relais :</strong> {{ $order->shipping_relay_label }}</p>
            @endif

            <p class="footer">Ne répondez pas à cet e-mail. Pour toute question, contactez-nous depuis le site.</p>
        </div>
    </div>
</body>
</html>
