@extends('admin.layouts.app')
@section('title','Customer Details')
@section('content')
<div class="page-shell">
    <div class="page-head"><div><h1 class="page-title">{{ $customer->name }}</h1><div class="page-subtitle">Phone: {{ $customer->phone_number ?: 'N/A' }} · Group: {{ $customer->customer_group }} · Membership: {{ $customer->membership_tier ?? 'General' }}</div></div><a href="{{ route('admin.customers.edit',$customer) }}" class="btn">Edit Customer</a></div>
    <div class="grid-5">
        <div class="stat"><div class="k">Opening Balance</div><div class="v">{{ number_format($customer->opening_balance,2) }}</div></div>
        <div class="stat"><div class="k">Purchase Amount</div><div class="v">{{ number_format($totalPurchase,2) }}</div></div>
        <div class="stat"><div class="k">Current Due</div><div class="v">{{ number_format($totalDue,2) }}</div></div>
        <div class="stat"><div class="k">Loyalty Points</div><div class="v">{{ $customer->points ?? 0 }}</div></div>
        <div class="stat"><div class="k">Wallet / Store Credit</div><div class="v">{{ number_format($customer->wallet_balance ?? 0,2) }}</div></div>
    </div><div class="alert alert-info" style="margin-top:12px">Membership Card: {{ $customer->membership_no ?: 'Not assigned' }} · Special Discount: {{ $customer->special_discount_percent ?? 0 }}% · SMS Reminder: {{ ($customer->sms_opt_in ?? 1) ? 'Enabled' : 'Disabled' }}</div>
    <div class="card panel-tight table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>Date</th><th>Product</th><th>Qty</th><th>Amount</th><th>Due</th></tr></thead><tbody>@forelse($sales as $sale)<tr><td>{{ $sale->invoice_no }}</td><td>{{ $sale->sale_date }}</td><td>{{ $sale->product_name }}</td><td>{{ $sale->quantity_sold }}</td><td>{{ number_format($sale->total_amount,2) }}</td><td>{{ number_format($sale->due_amount,2) }}</td></tr>@empty<tr><td colspan="6">No sales found.</td></tr>@endforelse</tbody></table></div>
    {{ $sales->links() }}
</div>
@endsection
