@extends('layouts.app')

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

@section('content')

<div class="row">
    <div class="col-lg-12">

        <div class="card card-transparent card-block card-stretch card-height border-none">

            <div class="card-body p-0 mt-lg-2 mt-0">

                <div class="d-flex flex-wrap align-items-center justify-content-between">

                    <div>
                        <h3 class="mb-1">Payment Details</h3>
                        <p class="mb-0 text-muted">
                            View complete payment information.
                        </p>
                    </div>

                    <div>

                        <a href="{{ route('payments.edit', $payment->payment_id) }}"
                           class="btn btn-warning mr-2">

                            <i class="ri-edit-line mr-1"></i>
                            Edit Payment

                        </a>

                        <a href="{{ route('payments.index') }}"
                           class="btn btn-secondary">

                            <i class="ri-arrow-left-line mr-1"></i>
                            Back to Payments

                        </a>

                    </div>

                </div>

            </div>

        </div>

    </div>
</div>


<div class="row">

    <div class="col-lg-12">

        <div class="card card-block card-stretch card-height">

            <div class="card-header">
                <h4 class="card-title">Payment Information</h4>
            </div>

            <div class="card-body">

                <div class="row">

                    <div class="col-lg-6 mb-3">

                        <strong>Payment ID</strong>

                        <div class="form-control bg-light">
                            #{{ $payment->payment_id }}
                        </div>

                    </div>


                    <div class="col-lg-6 mb-3">

                        <strong>Invoice / Order</strong>

                        <div class="form-control bg-light">

                            {{ $payment->order->invoice->invoice_number ?? 'No Invoice' }}

                            @if($payment->order)
                                — {{ $payment->order->serial_number }}
                            @endif

                        </div>

                    </div>


                    <div class="col-lg-6 mb-3">

                        <strong>Customer</strong>

                        <div class="form-control bg-light">

                            {{ $payment->customer->customer_name ?? 'N/A' }}

                        </div>

                    </div>


                    <div class="col-lg-6 mb-3">

                        <strong>Payment Method</strong>

                        <div class="form-control bg-light">

                            {{ $payment->method->method_type ?? 'N/A' }}

                        </div>

                    </div>


                    <div class="col-lg-4 mb-3">

                        <strong>Amount Paid</strong>

                        <div class="form-control bg-light">

                            Rs. {{ number_format((float)$payment->amount_paid, 2) }}

                        </div>

                    </div>


                    <div class="col-lg-4 mb-3">

                        <strong>Remaining Amount</strong>

                        <div class="form-control bg-light">

                            Rs. {{ number_format((float)$payment->remaining_amount, 2) }}

                        </div>

                    </div>


                    <div class="col-lg-4 mb-3">

                        <strong>Status</strong>

                        <div class="form-control bg-light">

                            {{ ucfirst($payment->status->status_name ?? 'N/A') }}

                        </div>

                    </div>


                    <div class="col-lg-6 mb-3">

                        <strong>Payment Date</strong>

                        <div class="form-control bg-light">

                            {{ $payment->payment_date
                                ? $payment->payment_date->format('d M Y, h:i A')
                                : 'N/A'
                            }}

                        </div>

                    </div>


                    <div class="col-lg-6 mb-3">

                        <strong>Received By</strong>

                        <div class="form-control bg-light">

                            {{ $payment->receiver->user_name ?? 'N/A' }}

                        </div>

                    </div>

                </div>

            </div>

        </div>

    </div>

</div>

@endsection