<?php $__env->startSection('title', $client->display_name); ?>
<?php $__env->startSection('page-title', 'Client Details'); ?>

<?php $__env->startSection('content'); ?>

<div class="d-flex align-items-center justify-content-between mb-4 flex-wrap gap-2">
    <div class="d-flex align-items-center gap-3">
        <a href="<?php echo e(route('clients.index')); ?>" class="btn btn-sm btn-light"><i class="bi bi-arrow-left"></i></a>
        <div>
            <h5 class="fw-700 mb-0" style="color:#1e293b;"><?php echo e($client->display_name); ?></h5>
            <?php if($client->business_name && $client->name !== $client->business_name): ?>
                <small class="text-muted">Contact: <?php echo e($client->name); ?></small>
            <?php endif; ?>
        </div>
    </div>
    <div class="d-flex gap-2">
        <a href="<?php echo e(route('invoices.create', ['client_id' => $client->id])); ?>"
           class="btn btn-sm fw-600" style="background:#00a651;color:white;">
            <i class="bi bi-plus-lg me-1"></i>New Invoice
        </a>
        <a href="<?php echo e(route('clients.edit', $client)); ?>" class="btn btn-sm btn-outline-secondary fw-600">
            <i class="bi bi-pencil me-1"></i>Edit
        </a>
    </div>
</div>

<div class="row g-3 mb-4">
    
    <div class="col-lg-4">
        <div class="card table-card p-3">
            <h6 class="fw-700 mb-3" style="font-size:0.75rem;text-transform:uppercase;letter-spacing:0.07em;color:#94a3b8;">
                <i class="bi bi-person me-1"></i>Contact Info
            </h6>
            <div class="d-flex flex-column gap-2" style="font-size:0.875rem;">
                <?php if($client->email): ?>
                <div class="d-flex gap-2">
                    <i class="bi bi-envelope text-muted mt-1" style="flex-shrink:0;"></i>
                    <a href="mailto:<?php echo e($client->email); ?>" class="text-decoration-none text-dark"><?php echo e($client->email); ?></a>
                </div>
                <?php endif; ?>
                <?php if($client->phone): ?>
                <div class="d-flex gap-2">
                    <i class="bi bi-phone text-muted mt-1" style="flex-shrink:0;"></i>
                    <span><?php echo e($client->phone); ?></span>
                </div>
                <?php endif; ?>
                <?php if($client->address): ?>
                <div class="d-flex gap-2">
                    <i class="bi bi-geo-alt text-muted mt-1" style="flex-shrink:0;"></i>
                    <span class="text-muted"><?php echo e($client->address); ?></span>
                </div>
                <?php endif; ?>
            </div>

            <?php if(!$client->hasInvoices()): ?>
            <div class="mt-3 pt-3 border-top">
                <form method="POST" action="<?php echo e(route('clients.destroy', $client)); ?>">
                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                    <button type="submit" class="btn btn-sm btn-outline-danger w-100"
                            onclick="return confirm('Delete <?php echo e($client->name); ?> permanently?')">
                        <i class="bi bi-trash3 me-1"></i>Delete Client
                    </button>
                </form>
            </div>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="col-lg-8">
        <div class="row g-3">
            <div class="col-6 col-md-3">
                <div class="card table-card p-3 text-center">
                    <div class="fw-700 fs-5" style="color:#1e293b;"><?php echo e($stats['total_invoices']); ?></div>
                    <div class="text-muted small">Invoices</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="card table-card p-3 text-center">
                    <div class="fw-700 fs-6" style="color:#1e293b;">₦<?php echo e(number_format($client->total_billed/1000,1)); ?>k</div>
                    <div class="text-muted small">Total Billed</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="card table-card p-3 text-center">
                    <div class="fw-700 fs-6 text-success">₦<?php echo e(number_format($stats['total_paid']/1000,1)); ?>k</div>
                    <div class="text-muted small">Total Paid</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="card table-card p-3 text-center">
                    <div class="fw-700 fs-6 <?php echo e($stats['total_overdue'] > 0 ? 'text-danger' : 'text-muted'); ?>">
                        ₦<?php echo e(number_format($stats['total_overdue']/1000,1)); ?>k
                    </div>
                    <div class="text-muted small">Overdue</div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="card table-card">
    <div class="d-flex align-items-center justify-content-between p-3 border-bottom">
        <h6 class="fw-700 mb-0" style="color:#1e293b;">Invoice History</h6>
    </div>

    <?php if($invoices->isEmpty()): ?>
        <div class="empty-state">
            <div class="empty-icon"><i class="bi bi-receipt"></i></div>
            <h5>No invoices yet</h5>
            <p>Create the first invoice for <?php echo e($client->display_name); ?>.</p>
            <a href="<?php echo e(route('invoices.create', ['client_id' => $client->id])); ?>"
               class="btn" style="background:#00a651;color:white;">
                <i class="bi bi-plus-lg me-2"></i>Create Invoice
            </a>
        </div>
    <?php else: ?>
        <div class="table-responsive">
            <table class="table table-hover mb-0">
                <thead>
                    <tr>
                        <th>Invoice #</th>
                        <th class="d-none d-md-table-cell">Issue Date</th>
                        <th class="d-none d-md-table-cell">Due Date</th>
                        <th>Amount</th>
                        <th>Status</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $invoice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><span style="font-family:monospace;font-weight:600;color:#1e293b;"><?php echo e($invoice->invoice_number); ?></span></td>
                        <td class="d-none d-md-table-cell text-muted small"><?php echo e($invoice->issue_date->format('d/m/Y')); ?></td>
                        <td class="d-none d-md-table-cell small <?php echo e($invoice->isOverdue() ? 'text-danger fw-600' : 'text-muted'); ?>">
                            <?php echo e($invoice->due_date->format('d/m/Y')); ?>

                        </td>
                        <td class="fw-600">₦<?php echo e(number_format($invoice->total, 2)); ?></td>
                        <td><span class="status-badge badge-<?php echo e($invoice->status); ?>"><?php echo e($invoice->status_badge['label']); ?></span></td>
                        <td>
                            <a href="<?php echo e(route('invoices.show', $invoice)); ?>" class="btn btn-sm btn-light">View</a>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <?php if($invoices->hasPages()): ?>
            <div class="p-3 border-top"><?php echo e($invoices->links()); ?></div>
        <?php endif; ?>
    <?php endif; ?>
</div>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Bunmi\Desktop\crud\resources\views/clients/show.blade.php ENDPATH**/ ?>