@php $v = $selected; @endphp
<div class="billing-client-detail card border-0 shadow-sm">
    <div class="card-body p-4">
        <div class="billing-client-detail__header">
            <div class="billing-client-detail__icon billing-client-detail__icon--vendor"><i class="ri-store-2-line"></i></div>
            <div>
                <h4 class="mb-1 fw-semibold">{{ $v->name }}</h4>
                @if($v->vendor_code)<p class="text-muted small mb-0">Code: {{ $v->vendor_code }}</p>@endif
                @if($v->city)<p class="text-muted small mb-0"><i class="ri-map-pin-line me-1"></i>{{ $v->city }}{{ $v->state ? ', '.$v->state : '' }}</p>@endif
            </div>
        </div>

        <ul class="billing-client-detail__meta list-unstyled mb-0">
            @if($v->gstin)
                <li><span class="label">GSTIN</span><span class="value"><code>{{ $v->gstin }}</code></span></li>
            @endif
            @if($v->email)
                <li><span class="label">Email</span><span class="value"><i class="ri-mail-line me-1 text-muted"></i>{{ $v->email }}</span></li>
            @endif
            @if($v->phone)
                <li><span class="label">Phone</span><span class="value"><i class="ri-phone-line me-1 text-muted"></i>{{ $v->phone }}</span></li>
            @endif
            @if($v->gst_treatment)
                <li><span class="label">GST Treatment</span><span class="value">{{ $v->gstTreatmentLabel() }}</span></li>
            @endif
        </ul>

        <hr class="billing-client-detail__divider">

        <h6 class="billing-client-detail__section-title">Contact Persons</h6>
        <ul class="list-unstyled mb-0">
            @foreach($v->contactPersonsList() as $person)
                <li class="mb-1">{{ $person }}</li>
            @endforeach
        </ul>

        <hr class="billing-client-detail__divider">

        <h6 class="billing-client-detail__section-title">Address</h6>
        <div class="billing-client-detail__address">
            <div class="fw-medium mb-2"><i class="ri-building-line me-1 text-muted"></i> Billing Address</div>
            @if(count($v->billingAddressLines()))
                <address class="mb-0">
                    @foreach($v->billingAddressLines() as $line)
                        {{ $line }}<br>
                    @endforeach
                </address>
            @else
                <p class="text-muted mb-0">No billing address on file.</p>
            @endif
        </div>

        <hr class="billing-client-detail__divider">

        <p class="text-muted small mb-0">
            Opening Balance added by user {{ auth()->user()->name ?? 'Admin' }} :
            <span class="fw-medium text-body">₹{{ number_format($v->opening_balance, 2) }}</span>
            <span class="text-muted">({{ $v->balance_type }})</span>
            · Current balance: <span class="fw-medium text-body">₹{{ number_format($v->currentBalance(), 2) }}</span>
        </p>

        @if($v->notes)
            <hr class="billing-client-detail__divider">
            <h6 class="billing-client-detail__section-title">Notes</h6>
            <p class="text-muted mb-0">{{ $v->notes }}</p>
        @endif
    </div>
</div>
