<?php $__env->startSection('title', 'Liste des Sites'); ?>

<?php $__env->startPush('styles'); ?>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.5.0/css/responsive.bootstrap5.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
    :root {
        --primary-color: #020548;
        --secondary-color: #3b5de7;
        --accent-color: #ff6b6b;
        --light-bg: #f8f9fa;
    }

    .page-header {
        background-color: white;
        padding: 1.5rem;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        margin-bottom: 2rem;
    }

    .breadcrumb-custom {
        background-color: transparent;
        padding: 0;
    }

    .breadcrumb-custom .breadcrumb-item a {
        color: var(--secondary-color);
        text-decoration: none;
    }

    .breadcrumb-custom .breadcrumb-item.active {
        color: var(--primary-color);
        font-weight: 500;
    }

    .btn-add {
        background-color: var(--primary-color);
        border: none;
        padding: 10px 20px;
        font-weight: 500;
        transition: all 0.3s;
    }

    .btn-add:hover {
        background-color: var(--secondary-color);
        transform: translateY(-2px);
    }

    .card-table {
        border: none;
        border-radius: 10px;
        box-shadow: 0 10px 30px rgba(2,5,72,0.1);
        overflow: hidden;
    }

    .table-responsive {
        padding: 0;
        overflow-x: auto;
    }

    #site-table {
        width: 100% !important;
    }

    #site-table thead th {
        background-color: var(--primary-color);
        color: white;
        font-weight: 500;
        padding: 15px;
        white-space: nowrap;
    }

    #site-table tbody td {
        vertical-align: middle;
        padding: 12px 15px;
    }

    #site-table tbody tr:nth-child(even) {
        background-color: rgba(248, 249, 250, 0.5);
    }

    #site-table tbody tr:hover {
        background-color: rgba(2, 5, 72, 0.03);
    }

    .carousel-img {
        height: 120px;
        width: 180px;
        object-fit: cover;
        border-radius: 8px;
    }

    .carousel-control-prev-icon,
    .carousel-control-next-icon {
        background-color: rgba(0,0,0,0.5);
        border-radius: 50%;
        padding: 10px;
    }

    .btn-action {
        padding: 6px 12px;
        font-size: 14px;
        border-radius: 6px;
        transition: all 0.2s;
    }

    .btn-edit {
        background-color: #ffc107;
        border-color: #ffc107;
        color: #212529;
    }

    .btn-edit:hover {
        background-color: #e0a800;
        border-color: #d39e00;
    }

    .btn-delete {
        background-color: #dc3545;
        border-color: #dc3545;
    }

    .btn-delete:hover {
        background-color: #c82333;
        border-color: #bd2130;
    }

    .btn-pdf {
        background-color: #6c757d;
        border-color: #6c757d;
        color: white;
    }

    .btn-pdf:hover {
        background-color: #5a6268;
        border-color: #545b62;
    }

    /* Modal de succès */
    .success-modal .modal-header {
        background-color: #28a745;
        color: white;
    }

    /* Modal de suppression */
    .delete-modal .modal-header {
        background-color: #dc3545;
        color: white;
    }

    .price-cell {
        font-weight: 600;
        color: var(--primary-color);
    }

    .description-cell {
        max-width: 200px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .time-cell {
        white-space: nowrap;
    }

    .btn-view {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
}

.btn-view:hover {
    background-color: #138496;
    border-color: #117a8b;
    color: white;
}

    /* Style pour le tableau responsive */
    @media screen and (max-width: 768px) {
        .description-cell {
            max-width: 150px;
        }
    }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- Modal de succès -->
    <?php if(session('show_success_modal')): ?>
    <div class="modal fade success-modal show" id="successModal" tabindex="-1" style="display: block; background: rgba(0,0,0,0.5);">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fas fa-check-circle me-2"></i>Succès</h5>
                </div>
                <div class="modal-body">
                    <p><?php echo e(session('modal_message', 'Site créé avec succès !')); ?></p>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var modal = new bootstrap.Modal(document.getElementById('successModal'), {
                backdrop: 'static',
                keyboard: false
            });
            modal.show();

            setTimeout(function() {
                var modalEl = document.getElementById('successModal');
                modalEl.style.transition = 'opacity 0.5s';
                modalEl.style.opacity = '0';

                setTimeout(function() {
                    modal.hide();
                    window.location.href = "<?php echo e(route('listeSite')); ?>";
                }, 500);
            }, 2500);
        });
    </script>
    <?php endif; ?>

    <!-- En-tête de page -->
    <div class="page-header">
        <div class="row align-items-center">
            <div class="col-md-6">
                <h2 class="mb-0">
                    <i class="fas fa-map-marked-alt me-2" style="color: var(--primary-color);"></i>
                    Liste des Sites Touristiques
                </h2>
            </div>
            <div class="col-md-6">
                <div class="d-flex justify-content-end align-items-center">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb breadcrumb-custom">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboard</a></li>
                            <li class="breadcrumb-item active">Sites</li>
                        </ol>
                    </nav>
                    <a href="<?php echo e(route('formSite')); ?>" class="btn btn-add ms-3">
                        <i class="fas fa-plus me-2"></i>Ajouter un site
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- Carte principale -->
    <div class="card-table">
        <div class="card-body">
            <div class="table-responsive">
                <table id="site-table" class="table table-hover" style="width:100%">
                    <thead>
                        <tr>
                            <th>Nom du Site</th>
                            <th>Images</th>
                            <th>Lieu</th>
                            <th>Prix Standard</th>
                            <th>Prix Premium</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $sites; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $site): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td>
                                <strong><?php echo e($site->name); ?></strong>
                                <br>
                                <small class="text-muted description-cell" title="<?php echo e($site->description_fr); ?>">
                                    <?php echo e(Str::limit($site->description_fr, 50)); ?>

                                </small>
                            </td>
                            <td>
                                <?php if($site->images->count() > 0): ?>
                                <div id="carousel-<?php echo e($site->id); ?>" class="carousel slide" data-bs-ride="carousel" style="width: 180px;">
                                    <div class="carousel-inner">
                                        <?php $__currentLoopData = $site->images; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $image): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="carousel-item <?php echo e($key === 0 ? 'active' : ''); ?>">
                                                <img src="<?php echo e($image->image_url); ?>" class="d-block carousel-img" alt="<?php echo e($site->name); ?>">
                                            </div>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </div>
                                    <?php if($site->images->count() > 1): ?>
                                        <button class="carousel-control-prev" type="button" data-bs-target="#carousel-<?php echo e($site->id); ?>" data-bs-slide="prev">
                                            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                                        </button>
                                        <button class="carousel-control-next" type="button" data-bs-target="#carousel-<?php echo e($site->id); ?>" data-bs-slide="next">
                                            <span class="carousel-control-next-icon" aria-hidden="true"></span>
                                        </button>
                                    <?php endif; ?>
                                </div>
                                <?php else: ?>
                                <div class="bg-light d-flex align-items-center justify-content-center" style="height: 120px; width: 180px; border-radius: 8px;">
                                    <i class="fas fa-image fa-2x text-muted"></i>
                                </div>
                                <?php endif; ?>
                            </td>
                            <td><?php echo e($site->location); ?></td>
                            <td class="price-cell">
                                <?php echo e(number_format($site->standard_price, 0, ',', ' ')); ?> FCFA
                            </td>
                            <td class="price-cell">
                                <?php echo e(number_format($site->premium_price, 0, ',', ' ')); ?> FCFA
                            </td>
                            <td>
                                <div class="d-flex gap-2">
                                    <a href="<?php echo e(route('formeEditSite', $site->id)); ?>" class="btn btn-action btn-edit">
                                        <i class="fas fa-edit"></i>
                                    </a>
                                    <button type="button" class="btn btn-action btn-delete" data-bs-toggle="modal" data-bs-target="#deleteModal<?php echo e($site->id); ?>">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                    
                                    <a href="<?php echo e(route('dashboard.showsite', $site->id)); ?>" class="btn btn-action btn-view">
                                        <i class="fas fa-eye"></i>
                                    </a>
                                </div>
                            </td>
                        </tr>

                        <!-- Modal de suppression -->
                        <div class="modal fade delete-modal" id="deleteModal<?php echo e($site->id); ?>" tabindex="-1">
                            <div class="modal-dialog modal-dialog-centered">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title"><i class="fas fa-exclamation-triangle me-2"></i>Confirmation</h5>
                                    </div>
                                    <div class="modal-body">
                                        <p>Êtes-vous sûr de vouloir supprimer le site <strong><?php echo e($site->name); ?></strong> ?</p>
                                        <p class="text-danger"><small>Cette action est irréversible.</small></p>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
                                        <form action="<?php echo e(route('sites.destroy', $site->id)); ?>" method="POST">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-danger">
                                                <i class="fas fa-trash me-1"></i> Supprimer
                                            </button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.5.0/js/responsive.bootstrap5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<script>
$(document).ready(function() {
    $('#site-table').DataTable({
        responsive: true,
        language: {
            url: 'https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json'
        },
        dom: '<"top"f>rt<"bottom"lip><"clear">',
        columnDefs: [
            { responsivePriority: 1, targets: 0 }, // Nom
            { responsivePriority: 2, targets: -1 }, // Actions
            {
                responsivePriority: 3,
                targets: 1, // Images
                orderable: false // Désactive le tri
            },
            { responsivePriority: 4, targets: 2 }, // Lieu
            { responsivePriority: 5, targets: 3 }, // Prix Standard
            { responsivePriority: 6, targets: 4 }  // Prix Premium
        ]
    });

    // Initialiser les carousels
    $('.carousel').carousel({
        interval: false
    });

    // Tooltip Bootstrap pour les descriptions
    $('.description-cell').tooltip({
        trigger: 'hover',
        placement: 'top'
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\LENOVO\Documents\voyagedifiantDashboard\resources\views/page/listeSite.blade.php ENDPATH**/ ?>