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

<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item active" aria-current="page">Customers</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-actions'); ?>
    <!-- Export Button -->
    <a id="exportCsvBtn" href="#" class="btn-secondary flex items-center gap-1.5 text-xs font-semibold px-3 py-2 border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 rounded-lg shadow-soft hover:bg-slate-50 dark:hover:bg-slate-800 transition">
        <i class="bi bi-file-earmark-arrow-down text-emerald-600 dark:text-emerald-400"></i> Export CSV
    </a>

    <!-- Add Customer Button -->
    <?php if (isset($component)) { $__componentOriginal60a020e5340f3f52bbc4501dc9f93102 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal60a020e5340f3f52bbc4501dc9f93102 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.button','data' => ['href' => route('admin.customers.create'),'icon' => 'bi-plus']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['href' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('admin.customers.create')),'icon' => 'bi-plus']); ?>Add Customer <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal60a020e5340f3f52bbc4501dc9f93102)): ?>
<?php $attributes = $__attributesOriginal60a020e5340f3f52bbc4501dc9f93102; ?>
<?php unset($__attributesOriginal60a020e5340f3f52bbc4501dc9f93102); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal60a020e5340f3f52bbc4501dc9f93102)): ?>
<?php $component = $__componentOriginal60a020e5340f3f52bbc4501dc9f93102; ?>
<?php unset($__componentOriginal60a020e5340f3f52bbc4501dc9f93102); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<!-- Filters Panel -->
<form id="customersFilterForm" onsubmit="return false;" class="mb-6 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4 bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-2xl p-4 shadow-soft">
    <div>
        <div>
            <?php if (isset($component)) { $__componentOriginal5cb383ddee3a6dc44b6e82e90e14b261 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal5cb383ddee3a6dc44b6e82e90e14b261 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.search-input','data' => ['id' => 'customersSearch','placeholder' => 'Name, email, phone...']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin.search-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['id' => 'customersSearch','placeholder' => 'Name, email, phone...']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal5cb383ddee3a6dc44b6e82e90e14b261)): ?>
<?php $attributes = $__attributesOriginal5cb383ddee3a6dc44b6e82e90e14b261; ?>
<?php unset($__attributesOriginal5cb383ddee3a6dc44b6e82e90e14b261); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal5cb383ddee3a6dc44b6e82e90e14b261)): ?>
<?php $component = $__componentOriginal5cb383ddee3a6dc44b6e82e90e14b261; ?>
<?php unset($__componentOriginal5cb383ddee3a6dc44b6e82e90e14b261); ?>
<?php endif; ?>
        </div>
    </div>
</form>

<!-- Reusable DataTable Component -->
<?php if (isset($component)) { $__componentOriginal8aaf9779783cdf64609094123653a0b9 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8aaf9779783cdf64609094123653a0b9 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.datatable','data' => ['id' => 'customersTable','ajaxUrl' => route('admin.customers.index'),'columns' => [
        ['data' => 'name', 'orderable' => true],
        ['data' => 'email', 'orderable' => true],
        ['data' => 'phone', 'orderable' => false],
        ['data' => 'orders_count', 'orderable' => false],
        ['data' => 'total_spend', 'orderable' => false],
        ['data' => 'last_order', 'orderable' => false],
        ['data' => 'status', 'orderable' => false],
        ['data' => 'actions', 'orderable' => false, 'searchable' => false]
    ],'order' => [[0, 'asc']],'columnDefs' => [
        ['orderable' => false, 'targets' => [2, 3, 4, 5, 6, 7]],
        ['className' => 'text-left align-middle', 'targets' => [0, 1, 2, 3, 4, 5, 6]],
        ['className' => 'text-right align-middle', 'targets' => [7]]
    ],'searchId' => 'customersSearch','filterFormId' => 'customersFilterForm','padding' => false,'drawCallback' => 'updateExportUrl']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('datatable'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['id' => 'customersTable','ajax-url' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(route('admin.customers.index')),'columns' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute([
        ['data' => 'name', 'orderable' => true],
        ['data' => 'email', 'orderable' => true],
        ['data' => 'phone', 'orderable' => false],
        ['data' => 'orders_count', 'orderable' => false],
        ['data' => 'total_spend', 'orderable' => false],
        ['data' => 'last_order', 'orderable' => false],
        ['data' => 'status', 'orderable' => false],
        ['data' => 'actions', 'orderable' => false, 'searchable' => false]
    ]),'order' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute([[0, 'asc']]),'column-defs' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute([
        ['orderable' => false, 'targets' => [2, 3, 4, 5, 6, 7]],
        ['className' => 'text-left align-middle', 'targets' => [0, 1, 2, 3, 4, 5, 6]],
        ['className' => 'text-right align-middle', 'targets' => [7]]
    ]),'search-id' => 'customersSearch','filter-form-id' => 'customersFilterForm','padding' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(false),'draw-callback' => 'updateExportUrl']); ?>
     <?php $__env->slot('thead', null, []); ?> 
        <th>Name</th>
        <th>Email</th>
        <th>Phone</th>
        <th>Total Orders</th>
        <th>Total Spend</th>
        <th>Last Order</th>
        <th>Status</th>
        <th class="no-export text-right">Actions</th>
     <?php $__env->endSlot(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8aaf9779783cdf64609094123653a0b9)): ?>
<?php $attributes = $__attributesOriginal8aaf9779783cdf64609094123653a0b9; ?>
<?php unset($__attributesOriginal8aaf9779783cdf64609094123653a0b9); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8aaf9779783cdf64609094123653a0b9)): ?>
<?php $component = $__componentOriginal8aaf9779783cdf64609094123653a0b9; ?>
<?php unset($__componentOriginal8aaf9779783cdf64609094123653a0b9); ?>
<?php endif; ?>

<script>
// Dynamic update of CSV Export link params
function updateExportUrl() {
    var baseUrl = "<?php echo e(route('admin.customers.export')); ?>";
    var params = [];

    var searchVal = $('#customersSearch').val();
    if (searchVal) params.push('search=' + encodeURIComponent(searchVal));

    var statusVal = $('#statusFilter').val();
    if (statusVal) params.push('status=' + encodeURIComponent(statusVal));

    var groupVal = $('#groupFilter').val();
    if (groupVal) params.push('customer_group=' + encodeURIComponent(groupVal));

    var verificationVal = $('#verificationFilter').val();
    if (verificationVal) params.push('verification=' + encodeURIComponent(verificationVal));

    var finalUrl = baseUrl + (params.length > 0 ? '?' + params.join('&') : '');
    $('#exportCsvBtn').attr('href', finalUrl);
}

// Toggle dropdown menu
function toggleDropdown(id) {
    var dropdown = document.getElementById('dropdown-' + id);
    if (dropdown) {
        dropdown.classList.toggle('hidden');
    }
}

// Close dropdown when clicking outside
document.addEventListener('click', function(event) {
    if (!event.target.closest('button') && !event.target.closest('div[id^="dropdown-"]')) {
        document.querySelectorAll('[id^="dropdown-"]').forEach(function(el) {
            el.classList.add('hidden');
        });
    }
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/mac/Documents/e-com/resources/views/admin/customers/index.blade.php ENDPATH**/ ?>