@extends('layouts.admin')

@section('title', 'Customer Details')

@section('content')
    <section class="dashboard-head">
        <div>
            <span class="eyebrow">Customer</span>
            <h1>{{ $customer->name }}</h1>
        </div>
        <a class="button ghost" href="{{ route('admin.customers.index') }}">Back</a>
    </section>

    <section class="admin-grid">
        <article class="panel">
            <h2>Profile</h2>
            <dl class="account-details">
                <div><dt>Email</dt><dd>{{ $customer->email }}</dd></div>
                <div><dt>Phone</dt><dd>{{ $customer->phone ?: 'Not added' }}</dd></div>
                <div><dt>Status</dt><dd>{{ $customer->is_active ? 'Active' : 'Inactive' }}</dd></div>
            </dl>
        </article>

        <article class="panel">
            <h2>Cart Items</h2>
            <div class="inventory-list">
                @forelse ($customer->cartItems as $item)
                    <div class="inventory-top">
                        <span>{{ $item->product->name }}</span>
                        <span>x{{ $item->quantity }}</span>
                    </div>
                @empty
                    <p>No cart items.</p>
                @endforelse
            </div>
        </article>
    </section>

    <section class="panel">
        <h2>Favorites</h2>
        <div class="customer-grid">
            @forelse ($customer->favorites as $favorite)
                <article class="customer-card">
                    <strong>{{ $favorite->product->name }}</strong>
                    <span>{{ \App\Models\SiteSetting::formatPrice($favorite->product->sellingPrice()) }}</span>
                </article>
            @empty
                <p>No favorites.</p>
            @endforelse
        </div>
    </section>
@endsection
