

<?php $__env->startSection('title', 'Coupons'); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-page-header">
    <h1>Coupons</h1>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('coupons.create')): ?>
    <a href="<?php echo e(route('admin.coupons.create')); ?>" class="admin-btn-primary">
        <i class="bi bi-plus"></i> Add Coupon
    </a>
    <?php endif; ?>
</div>

<div class="admin-card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="admin-table table table-hover">
                <thead>
                    <tr>
                        <th>Code</th>
                        <th>Type</th>
                        <th>Value</th>
                        <th>Valid Period</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $coupons; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $coupon): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><strong><?php echo e($coupon->code); ?></strong></td>
                            <td><span class="badge-modern badge-modern-info"><?php echo e(ucfirst($coupon->type)); ?></span></td>
                            <td>
                                <?php if($coupon->type === 'percentage'): ?>
                                    <?php echo e($coupon->value); ?>%
                                <?php else: ?>
                                    ₹<?php echo e(number_format($coupon->value, 2)); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <small><?php echo e($coupon->starts_at->format('M d, Y')); ?> - <?php echo e($coupon->ends_at->format('M d, Y')); ?></small>
                            </td>
                            <td>
                                <span class="badge-modern <?php echo e($coupon->is_active && $coupon->ends_at->isFuture() ? 'badge-modern-success' : 'badge-modern-danger'); ?>">
                                    <?php echo e($coupon->is_active && $coupon->ends_at->isFuture() ? 'Active' : 'Inactive'); ?>

                                </span>
                            </td>
                            <td>
                                <div class="d-flex gap-2">
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('coupons.update')): ?>
                                    <a href="<?php echo e(route('admin.coupons.edit', $coupon->id)); ?>" class="admin-action-btn admin-action-btn-sm admin-btn-primary" title="Edit Coupon">
                                        <i class="bi bi-pencil"></i> 
                                    </a>
                                    <?php endif; ?>
                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('coupons.delete')): ?>
                                    <form action="<?php echo e(route('admin.coupons.destroy', $coupon->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Are you sure?')">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button type="submit" class="admin-action-btn admin-action-btn-sm" style="background: #ef4444; height: -webkit-fill-available; color: white;" title="Delete Coupon">
                                            <i class="bi bi-trash"></i> 
                                        </button>
                                    </form>
                                    <?php endif; ?>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>

        <?php if($coupons->count() > 0): ?>
            <!-- Pagination - Right Aligned -->
            <?php if($coupons->hasPages()): ?>
            <div class="pagination-wrapper mt-4 m-4">
                <div class="d-flex justify-content-end align-items-center gap-3 flex-wrap">
                    <div class="pagination-info-text">
                        Showing <strong><?php echo e($coupons->firstItem() ?? 0); ?></strong>–<strong><?php echo e($coupons->lastItem() ?? 0); ?></strong> 
                        of <strong><?php echo e($coupons->total()); ?></strong> coupons
                    </div>
                    <div class="pagination-controls">
                        <?php echo e($coupons->links('vendor.pagination.admin-categories')); ?>

                    </div>
                </div>
            </div>
            <?php endif; ?>
        <?php else: ?>
            <div class="admin-empty-state">
                <i class="bi bi-ticket-perforated"></i>
                <h3>No Coupons Found</h3>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('coupons.create')): ?>
                <p>Get started by creating your first coupon.</p>
                <a href="<?php echo e(route('admin.coupons.create')); ?>" class="admin-btn-primary">
                    <i class="bi bi-plus"></i> Add Coupon
                </a>
                <?php endif; ?>
            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/shaa_jewels/live/resources/views/admin/coupons/index.blade.php ENDPATH**/ ?>