<?php $__env->startSection('content'); ?>
    <div class="container-fluid px-4 py-3">

        
        <div class="d-flex align-items-center justify-content-between mb-4">
            <h1 class="h3 mb-0 fw-bold text-dark">
                <i class="bi bi-envelope-arrow-up me-2 text-primary"></i>MailMove
            </h1>
            <a href="<?php echo e(route('mailmove.create')); ?>" class="btn btn-primary" id="btn-new-mailmove">
                <i class="bi bi-plus-lg me-1"></i> New
            </a>
        </div>

        
        <?php if(session('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo e(session('success')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php endif; ?>

        
        <form method="GET" action="<?php echo e(route('mailmove.index')); ?>" id="filter-form" class="mb-3">
            <div class="row g-2 align-items-center">
                <div class="col-sm-5 col-md-4">
                    <div class="input-group">
                        <span class="input-group-text bg-white border-end-0">
                            <i class="bi bi-search text-muted"></i>
                        </span>
                        <input type="text" id="search" name="search" class="form-control border-start-0 ps-0"
                            placeholder="Search by suser…" value="<?php echo e(request('search')); ?>" autocomplete="off">
                    </div>
                </div>
                <div class="col-auto">
                    <div class="btn-group" role="group" aria-label="Status filter">
                        <a href="<?php echo e(route('mailmove.index', array_merge(request()->except('filter', 'page'), ['filter' => 'all']))); ?>"
                            id="filter-all"
                            class="btn btn-sm <?php echo e(in_array(request('filter'), ['all', null, '']) ? 'btn-primary' : 'btn-outline-primary'); ?>">
                            All
                        </a>
                        <a href="<?php echo e(route('mailmove.index', array_merge(request()->except('filter', 'page'), ['filter' => 'active']))); ?>"
                            id="filter-active"
                            class="btn btn-sm <?php echo e(request('filter') === 'active' ? 'btn-success' : 'btn-outline-success'); ?>">
                            Active
                        </a>
                        <a href="<?php echo e(route('mailmove.index', array_merge(request()->except('filter', 'page'), ['filter' => 'completed']))); ?>"
                            id="filter-completed"
                            class="btn btn-sm <?php echo e(request('filter') === 'completed' ? 'btn-secondary' : 'btn-outline-secondary'); ?>">
                            Completed
                        </a>
                    </div>
                </div>
                <div class="col-auto">
                    <button type="submit" class="btn btn-sm btn-outline-dark" id="btn-search">
                        <i class="bi bi-funnel me-1"></i>Search
                    </button>
                    <?php if(request()->hasAny(['search', 'filter'])): ?>
                        <a href="<?php echo e(route('mailmove.index')); ?>" class="btn btn-sm btn-link text-danger" id="btn-clear-filters">
                            <i class="bi bi-x-circle me-1"></i>Clear
                        </a>
                    <?php endif; ?>
                </div>
            </div>
        </form>

        
        <div class="card shadow-sm border-0">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0" id="mailmove-table">
                        <thead class="table-light">
                            <tr>
                                <th class="ps-3" style="width:80px">#</th>
                                <th>suser</th>
                                <th>duser</th>
                                <th style="width:100px">From</th>
                                <th style="width:100px">To</th>
                                <th style="width:80px">Active</th>
                                <th style="width:120px">Status</th>
                                <th class="text-end pe-3" style="width:120px">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $mailmoves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="ps-3 text-muted small"><?php echo e($item->id); ?></td>
                                    <td>
                                        <span class="fw-semibold"><?php echo e($item->suser); ?></span>
                                    </td>
                                    <td class="text-muted"><?php echo e($item->duser); ?></td>
                                    <td class="text-muted small"><?php echo e($item->fdate?->format('d-M-Y')); ?></td>
                                    <td class="text-muted small"><?php echo e($item->tdate?->format('d-M-Y')); ?></td>
                                    <td class="fw-semibold"><?php echo e($item->active); ?></td>
                                    <td>
                                        <?php if($item->active > 0): ?>
                                            <span
                                                class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
                                        <?php else: ?>
                                            <span
                                                class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">Completed</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="text-end pe-3">
                                        <div class="d-flex justify-content-end gap-1">
                                            
                                            <a href="<?php echo e(route('mailmove.edit', $item)); ?>" id="btn-edit-<?php echo e($item->id); ?>"
                                                class="btn btn-sm btn-outline-primary" data-bs-toggle="tooltip"
                                                data-bs-placement="top" title="Edit">
                                                <i class="bi bi-pencil"></i>
                                            </a>
                                            
                                            <a href="<?php echo e(route('mailmove.create', ['copy_from' => $item->id])); ?>"
                                                id="btn-copy-<?php echo e($item->id); ?>" class="btn btn-sm btn-outline-primary"
                                                data-bs-toggle="tooltip" data-bs-placement="top" title="Copy">
                                                <i class="bi bi-copy"></i>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="8" class="text-center text-muted py-5">
                                        <i class="bi bi-inbox fs-3 d-block mb-2"></i>
                                        No records found.
                                    </td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <?php if($mailmoves->hasPages()): ?>
                <div class="card-footer bg-white border-top-0 d-flex justify-content-between align-items-center px-3 py-2">
                    <small class="text-muted">
                        Showing <?php echo e($mailmoves->firstItem()); ?>–<?php echo e($mailmoves->lastItem()); ?> of <?php echo e($mailmoves->total()); ?> records
                    </small>
                    <?php echo e($mailmoves->withQueryString()->links('pagination::bootstrap-5')); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>

    <?php $__env->startPush('scripts'); ?>
        <script>
            // Activate Bootstrap tooltips
            document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(el => {
                new bootstrap.Tooltip(el);
            });

            // Auto-submit search on Enter (already works via form, but filters are links)
            // Preserve search value when clicking filter buttons
            document.querySelectorAll('#filter-form .btn-group a').forEach(link => {
                link.addEventListener('click', function (e) {
                    const searchVal = document.getElementById('search').value.trim();
                    if (searchVal) {
                        e.preventDefault();
                        const url = new URL(this.href);
                        url.searchParams.set('search', searchVal);
                        window.location.href = url.toString();
                    }
                });
            });
        </script>
    <?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\mailmove\resources\views/mailmove/index.blade.php ENDPATH**/ ?>