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

<div class="row mb-4 align-items-center">
    <div class="col-md-6">
        <h2 class="fw-bold text-dark mb-1">Home Banner Studio</h2>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0">
                <li class="breadcrumb-item"><a href="#" class="text-decoration-none text-muted">Dashboard</a></li>
                <li class="breadcrumb-item active fw-medium text-primary" aria-current="page">Home Banner</li>
            </ol>
        </nav>
    </div>
    <div class="col-md-6 text-md-end">
        <a href="<?php echo e(route('home-banners.create')); ?>" class="btn btn-primary btn-lg shadow-sm rounded-3 px-4 py-2">
            <i class="bi bi-plus-circle-fill me-2"></i> Add New Banner
        </a>
    </div>
</div>

<?php if(session('success')): ?>
    <div class="alert alert-success alert-dismissible fade show rounded-4 shadow-sm mb-4 border-0 p-3" role="alert">
        <div class="d-flex align-items-center">
            <div class="bg-success text-white rounded-circle p-2 me-3 d-flex align-items-center justify-content-center" style="width: 32px; height: 32px;">
                <i class="bi bi-check-lg"></i>
            </div>
            <div>
                <strong class="d-block">Success!</strong>
                <span class="small"><?php echo e(session('success')); ?></span>
            </div>
        </div>
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<?php endif; ?>

<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
    <div class="card-header bg-white border-bottom py-3 px-4 d-flex align-items-center justify-content-between">
        <h6 class="m-0 fw-bold text-dark">Banner Collection</h6>
        <div class="dropdown">
            <button class="btn btn-light btn-sm rounded-3 border" type="button" data-bs-toggle="dropdown">
                <i class="bi bi-three-dots-vertical"></i>
            </button>
            <ul class="dropdown-menu dropdown-menu-end shadow border-0 rounded-3">
                <li><a class="dropdown-item py-2" href="#"><i class="bi bi-images me-2"></i> Preview Grid</a></li>
                <li><a class="dropdown-item py-2" href="#"><i class="bi bi-cloud-download me-2"></i> Export List</a></li>
            </ul>
        </div>
    </div>
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead class="text-secondary small text-uppercase fw-bold" style="background-color: #f8fafc;">
                    <tr>
                        <th class="px-4 py-3" style="width: 80px;">SL.NO</th>
                        <th class="py-3">Banner Content</th>
                        <th class="py-3">Preview Image</th>
                        <th class="py-3">Timeline</th>
                        <th class="px-4 py-3 text-end">Management</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $banners; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $banner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="transition-all">
                            <td class="px-4 py-4 text-secondary fw-medium">#<?php echo e($loop->iteration); ?></td>
                            <td class="py-4">
                                <div class="d-flex align-items-start">
                                    <div class="bg-primary-subtle text-primary rounded-3 p-2 me-3 d-flex align-items-center justify-content-center banner-icon-box">
                                        <i class="bi bi-layout-text-window-reverse"></i>
                                    </div>
                                    <div>
                                        <span class="d-block fw-bold text-dark h6 mb-1"><?php echo e($banner->heading); ?></span>
                                        <p class="text-secondary small mb-0"><?php echo e(\Illuminate\Support\Str::limit($banner->description, 90)); ?></p>
                                    </div>
                                </div>
                            </td>
                            <td class="py-4">
                                <?php if(!empty($banner->image)): ?>
                                    <div class="d-flex align-items-center">
                                        <img src="<?php echo e(asset('storage/' . $banner->image)); ?>" alt="<?php echo e($banner->heading); ?>" class="rounded-3 border object-fit-cover me-3 banner-thumb">
                                        <div>
                                            <span class="d-block small fw-semibold text-dark">Hero Visual</span>
                                            <a href="#" class="small text-decoration-none text-primary">Change preview</a>
                                        </div>
                                    </div>
                                <?php else: ?>
                                    <span class="badge bg-light text-secondary border px-3 py-2 rounded-pill font-monospace small">NO_IMAGE</span>
                                <?php endif; ?>
                            </td>
                            <td class="py-4 text-secondary">
                                <span class="d-block small fw-bold text-dark mb-1">
                                    <?php echo e($banner->updated_at ? $banner->updated_at->format('d M, Y') : 'Not updated yet'); ?>

                                </span>
                                <span class="text-secondary small">
                                    <?php echo e($banner->updated_at ? $banner->updated_at->diffForHumans() : 'Fresh draft'); ?>

                                </span>
                            </td>
                            <td class="px-4 py-4 text-end">
                                <div class="d-flex justify-content-end gap-2">
                                    <a href="<?php echo e(route('home-banners.show', $banner->id)); ?>" class="btn btn-light btn-sm rounded-3 border text-info" title="Preview Banner">
                                        <i class="bi bi-eye"></i>
                                    </a>
                                    <a href="<?php echo e(route('home-banners.edit', $banner->id)); ?>" class="btn btn-light btn-sm rounded-3 border text-primary" title="Edit Banner">
                                        <i class="bi bi-pencil-square"></i>
                                    </a>
                                    <button
                                        type="button"
                                        class="btn btn-light btn-sm rounded-3 border text-danger"
                                        title="Delete Banner"
                                        data-bs-toggle="modal"
                                        data-bs-target="#deleteBannerModal"
                                        data-banner-heading="<?php echo e($banner->heading); ?>"
                                        data-delete-url="<?php echo e(route('home-banners.destroy', $banner->id)); ?>"
                                    >
                                        <i class="bi bi-trash3"></i>
                                    </button>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="5" class="text-center py-5">
                                <img src="https://illustrations.popsy.co/gray/design-tools.svg" alt="Empty" style="width: 150px;" class="mb-4 opacity-50">
                                <h5 class="text-dark fw-bold">No Home Banners Added</h5>
                                <p class="text-secondary mb-4">Create your first hero banner to highlight the most important message on the homepage.</p>
                                <a href="<?php echo e(route('home-banners.create')); ?>" class="btn btn-primary rounded-3 px-4">Create First Banner</a>
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="modal fade" id="deleteBannerModal" tabindex="-1" aria-labelledby="deleteBannerModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-0 shadow-lg rounded-4 overflow-hidden">
            <div class="modal-body p-4 p-md-5">
                <div class="delete-modal-icon mx-auto mb-4">
                    <i class="bi bi-trash3"></i>
                </div>
                <div class="text-center">
                    <h5 class="fw-bold text-dark mb-2" id="deleteBannerModalLabel">Delete this banner?</h5>
                    <p class="text-secondary mb-2">This action will permanently remove the selected banner.</p>
                    <p class="text-dark fw-semibold mb-0" id="deleteBannerName"></p>
                </div>
            </div>
            <div class="modal-footer border-0 pt-0 px-4 px-md-5 pb-4 pb-md-5 d-flex justify-content-center gap-2">
                <button type="button" class="btn btn-light border rounded-3 px-4" data-bs-dismiss="modal">Cancel</button>
                <form id="deleteBannerForm" method="POST" class="m-0">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('DELETE'); ?>
                    <button type="submit" class="btn btn-danger rounded-3 px-4 shadow-sm">
                        Delete Banner
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
<style>
    .transition-all { transition: all 0.2s ease-in-out; }
    .table tbody tr:hover { background-color: #f8fafc !important; transform: scale(1.002); }
    .bg-primary-subtle { background-color: #eff6ff !important; }
    .banner-icon-box { width: 40px; height: 40px; }
    .banner-thumb {
        width: 72px;
        height: 72px;
        object-fit: cover;
    }
    .delete-modal-icon {
        width: 72px;
        height: 72px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 24px;
        background: linear-gradient(145deg, #fee2e2 0%, #fecaca 100%);
        color: #dc2626;
        font-size: 1.75rem;
    }
    .breadcrumb-item + .breadcrumb-item::before { content: "\2022"; color: #cbd5e1; }
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const deleteBannerModal = document.getElementById('deleteBannerModal');
        const deleteBannerForm = document.getElementById('deleteBannerForm');
        const deleteBannerName = document.getElementById('deleteBannerName');

        if (!deleteBannerModal || !deleteBannerForm || !deleteBannerName) {
            return;
        }

        deleteBannerModal.addEventListener('show.bs.modal', function (event) {
            const triggerButton = event.relatedTarget;

            if (!triggerButton) {
                return;
            }

            const deleteUrl = triggerButton.getAttribute('data-delete-url');
            const bannerHeading = triggerButton.getAttribute('data-banner-heading');

            deleteBannerForm.setAttribute('action', deleteUrl);
            deleteBannerName.textContent = bannerHeading ? '"' + bannerHeading + '"' : '';
        });
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\portfolio\resources\views\homebanner\index.blade.php ENDPATH**/ ?>