<?php $__env->startSection('title', 'Clients'); ?>
<?php $__env->startSection('page-title', 'Clients'); ?>

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

<div class="d-flex align-items-center justify-content-between mb-4">
    <div>
        <h5 class="fw-700 mb-0" style="color:#1e293b;">All Clients</h5>
        <small class="text-muted"><?php echo e($clients->total()); ?> client<?php echo e($clients->total() !== 1 ? 's' : ''); ?></small>
    </div>
    <a href="<?php echo e(route('clients.create')); ?>" class="btn fw-600" style="background:#00a651;color:white;">
        <i class="bi bi-plus-lg me-2"></i>Add Client
    </a>
</div>

<div class="card table-card">
    
    <div class="p-3 border-bottom">
        <form method="GET" action="<?php echo e(route('clients.index')); ?>" class="d-flex gap-2">
            <div class="input-group input-group-sm" style="max-width:300px;">
                <span class="input-group-text bg-light border-end-0">
                    <i class="bi bi-search text-muted" style="font-size:0.75rem;"></i>
                </span>
                <input type="text" name="search" class="form-control border-start-0"
                       placeholder="Search by name, business or email..."
                       value="<?php echo e(request('search')); ?>">
            </div>
            <button type="submit" class="btn btn-sm btn-light">Search</button>
            <?php if(request('search')): ?>
                <a href="<?php echo e(route('clients.index')); ?>" class="btn btn-sm btn-light">
                    <i class="bi bi-x"></i> Clear
                </a>
            <?php endif; ?>
        </form>
    </div>

    <?php if($clients->isEmpty()): ?>
        <div class="empty-state">
            <div class="empty-icon"><i class="bi bi-people"></i></div>
            <h5>No clients yet</h5>
            <p><?php echo e(request('search') ? 'No clients match your search.' : 'Add your first client to start creating invoices.'); ?></p>
            <?php if(!request('search')): ?>
                <a href="<?php echo e(route('clients.create')); ?>" class="btn" style="background:#00a651;color:white;">
                    <i class="bi bi-plus-lg me-2"></i>Add Client
                </a>
            <?php endif; ?>
        </div>
    <?php else: ?>
        <div class="table-responsive">
            <table class="table table-hover mb-0">
                <thead>
                    <tr>
                        <th>Client</th>
                        <th class="d-none d-md-table-cell">Contact</th>
                        <th class="d-none d-lg-table-cell text-end">Total Billed</th>
                        <th class="d-none d-lg-table-cell text-end">Total Paid</th>
                        <th class="d-none d-md-table-cell text-center">Invoices</th>
                        <th style="width:100px;"></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $clients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $client): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td>
                            <a href="<?php echo e(route('clients.show', $client)); ?>" class="text-decoration-none">
                                <div class="fw-600" style="color:#1e293b;"><?php echo e($client->display_name); ?></div>
                                <?php if($client->business_name && $client->name !== $client->business_name): ?>
                                    <small class="text-muted"><?php echo e($client->name); ?></small>
                                <?php endif; ?>
                            </a>
                        </td>
                        <td class="d-none d-md-table-cell">
                            <?php if($client->email): ?>
                                <div class="small text-muted"><i class="bi bi-envelope me-1"></i><?php echo e($client->email); ?></div>
                            <?php endif; ?>
                            <?php if($client->phone): ?>
                                <div class="small text-muted"><i class="bi bi-phone me-1"></i><?php echo e($client->phone); ?></div>
                            <?php endif; ?>
                        </td>
                        <td class="d-none d-lg-table-cell text-end fw-500">
                            ₦<?php echo e(number_format($client->total_billed, 2)); ?>

                        </td>
                        <td class="d-none d-lg-table-cell text-end text-success fw-500">
                            ₦<?php echo e(number_format($client->total_paid, 2)); ?>

                        </td>
                        <td class="d-none d-md-table-cell text-center">
                            <span class="badge rounded-pill bg-light text-dark">
                                <?php echo e($client->invoices_count); ?>

                            </span>
                        </td>
                        <td>
                            <div class="d-flex gap-1 justify-content-end">
                                <a href="<?php echo e(route('clients.show', $client)); ?>" class="btn btn-sm btn-light" title="View">
                                    <i class="bi bi-eye"></i>
                                </a>
                                <a href="<?php echo e(route('clients.edit', $client)); ?>" class="btn btn-sm btn-light" title="Edit">
                                    <i class="bi bi-pencil"></i>
                                </a>
                                <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-light text-danger" title="Delete"
                                            onclick="return confirm('Delete <?php echo e($client->name); ?>? This cannot be undone.')">
                                        <i class="bi bi-trash3"></i>
                                    </button>
                                </form>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>

        <?php if($clients->hasPages()): ?>
            <div class="p-3 border-top"><?php echo e($clients->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/index.blade.php ENDPATH**/ ?>