<?php $__env->startSection('title', 'Dashboard - Formulaire de modification de Site'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- Header -->
    <div class="py-3 py-lg-4">
        <div class="row align-items-center">
            <div class="col-lg-6">
                <h4 class="page-title mb-0" style="color: #020548;">
                    <i class="mdi mdi-map-marker me-2"></i> Modification de site touristique
                </h4>
            </div>
            <div class="col-lg-6">
                <div class="d-none d-lg-block">
                    <ol class="breadcrumb m-0 float-end">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(route('listeSite')); ?>">Sites</a></li>
                        <li class="breadcrumb-item active">Modification</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <!-- Formulaire -->
    <div class="row justify-content-center">
        <div class="col-lg-10">
            <div class="card border-0 shadow-sm">
                <div class="card-header text-white" style="background-color: #020548;">
                    <h5 class="mb-0" style="color: #ffffff">Modifier : <?php echo e($site->name); ?></h5>
                </div>

                <div class="card-body p-4">
                    <form action="<?php echo e(route('sites.update', $site->id)); ?>" method="POST" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('PUT'); ?>

                        <!-- Section Informations de base -->
                        <div class="mb-4">
                            <h6 class="border-bottom pb-2 mb-3" style="color: #020548;">
                                <i class="mdi mdi-information-outline me-1"></i> Informations générales
                            </h6>

                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label for="name" class="form-label">Nom du site</label>
                                    <input type="text" class="form-control" id="name" name="name"
                                           value="<?php echo e(old('name', $site->name)); ?>" required>
                                    <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>

                                <div class="col-md-6">
                                    <label for="location" class="form-label">Lieu</label>
                                    <input type="text" class="form-control" id="location" name="location"
                                           value="<?php echo e(old('location', $site->location)); ?>" required>
                                    <?php $__errorArgs = ['location'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>

                                <div class="col-md-6">
                                    <label for="lat" class="form-label">Latitude</label>
                                    <input type="text" class="form-control" id="lat" name="lat"
                                        value="<?php echo e(old('lat', $site->lat)); ?>" required>
                                    <?php $__errorArgs = ['lat'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    <small class="text-muted">Exemple: 5.359951</small>
                                </div>

                                <div class="col-md-6">
                                    <label for="longi" class="form-label">Longitude</label>
                                    <input type="text" class="form-control" id="longi" name="longi"
                                        value="<?php echo e(old('longi', $site->longi)); ?>" required>
                                    <?php $__errorArgs = ['longi'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    <small class="text-muted">Exemple: -4.008256</small>
                                </div>
                            </div>
                        </div>

                        <!-- Section Images -->
                        <div class="mb-4">
                            <h6 class="border-bottom pb-2 mb-3" style="color: #020548;">
                                <i class="mdi mdi-image-multiple me-1"></i> Gestion des images
                            </h6>

                            <!-- Images existantes -->
                            <?php if($site->images->count() > 0): ?>
                            <div class="mb-3">
                                <label class="form-label">Images actuelles</label>
                                <div class="row g-2">
                                    <?php $__currentLoopData = $site->images; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $image): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-md-3 col-6">
                                        <div class="border p-2 rounded">
                                            <img src="<?php echo e(asset('storage/'.$image->images_path)); ?>"
                                                 class="img-fluid rounded"
                                                 style="height:120px;width:100%;object-fit:cover;"
                                                 onerror="this.src='<?php echo e(asset('images/placeholder.jpg')); ?>'">
                                            <div class="form-check mt-2">
                                                <input type="checkbox"
                                                       name="delete_images[]"
                                                       value="<?php echo e($image->id); ?>"
                                                       class="form-check-input"
                                                       id="delete_image_<?php echo e($image->id); ?>">
                                                <label class="form-check-label small" for="delete_image_<?php echo e($image->id); ?>">
                                                    Supprimer
                                                </label>
                                            </div>
                                        </div>
                                    </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                            </div>
                            <?php endif; ?>

                            <!-- Nouvelles images -->
                            <div class="mb-3">
                                <label for="new_images" class="form-label">Ajouter des images</label>
                                <input type="file" class="form-control" id="new_images"
                                       name="new_images[]" multiple accept="image/*">
                                <div class="form-text">Formats acceptés: JPEG, PNG, JPG (Max 2MB par image)</div>
                                <?php $__errorArgs = ['new_images'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <!-- Section Description -->
                        <div class="mb-4">
                            <h6 class="border-bottom pb-2 mb-3" style="color: #020548;">
                                <i class="mdi mdi-text-box-outline me-1"></i> Descriptions
                            </h6>

                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label for="description_fr" class="form-label">Description (Français)</label>
                                    <textarea class="form-control" id="description_fr" name="description_fr" rows="4"><?php echo e(old('description_fr', $site->description_fr)); ?></textarea>
                                    <?php $__errorArgs = ['description_fr'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>

                                <div class="col-md-6">
                                    <label for="description_en" class="form-label">Description (Anglais)</label>
                                    <textarea class="form-control" id="description_en" name="description_en" rows="4"><?php echo e(old('description_en', $site->description_en)); ?></textarea>
                                    <?php $__errorArgs = ['description_en'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                        </div>

                        <!-- Section Tarifs -->
                        <div class="mb-4">
                            <h6 class="border-bottom pb-2 mb-3" style="color: #020548;">
                                <i class="mdi mdi-cash-multiple me-1"></i> Tarification
                            </h6>

                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label for="standard_price" class="form-label">Prix Standard (FCFA)</label>
                                    <div class="input-group">
                                        <span class="input-group-text">FCFA</span>
                                        <input type="number" class="form-control" id="standard_price" name="standard_price"
                                               value="<?php echo e(old('standard_price', $site->standard_price)); ?>" min="0" required>
                                    </div>
                                    <?php $__errorArgs = ['standard_price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>

                                <div class="col-md-6">
                                    <label for="premium_price" class="form-label">Prix Premium (FCFA)</label>
                                    <div class="input-group">
                                        <span class="input-group-text">FCFA</span>
                                        <input type="number" class="form-control" id="premium_price" name="premium_price"
                                               value="<?php echo e(old('premium_price', $site->premium_price)); ?>" min="0" required>
                                    </div>
                                    <?php $__errorArgs = ['premium_price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                        </div>

                        <!-- Section Horaires -->
                        <div class="mb-4">
                            <h6 class="border-bottom pb-2 mb-3" style="color: #020548;">
                                <i class="mdi mdi-clock-outline me-1"></i> Horaires de visite
                            </h6>

                            <div class="row g-3">
                                <div class="col-md-6">
                                    <label for="visit_start_time" class="form-label">Heure d'ouverture</label>
                                    <input type="time" class="form-control" id="visit_start_time" name="visit_start_time"
                                           value="<?php echo e(old('visit_start_time', $site->visit_start_time ? \Carbon\Carbon::parse($site->visit_start_time)->format('H:i') : '')); ?>" required>
                                    <?php $__errorArgs = ['visit_start_time'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>

                                <div class="col-md-6">
                                    <label for="visit_end_time" class="form-label">Heure de fermeture</label>
                                    <input type="time" class="form-control" id="visit_end_time" name="visit_end_time"
                                           value="<?php echo e(old('visit_end_time', $site->visit_end_time ? \Carbon\Carbon::parse($site->visit_end_time)->format('H:i') : '')); ?>" required>
                                    <?php $__errorArgs = ['visit_end_time'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="text-danger small"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                        </div>

                        <!-- Boutons d'action -->
                        <div class="d-flex justify-content-between border-top pt-3">
                            <a href="<?php echo e(route('listeSite')); ?>" class="btn btn-outline-secondary">
                                <i class="mdi mdi-arrow-left me-1"></i> Annuler
                            </a>
                            <button type="submit" class="btn text-white" style="background-color: #020548;">
                                <i class="mdi mdi-content-save me-1"></i> Enregistrer
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
<style>
    :root {
        --primary-color: #020548;
        --primary-hover: #01032e;
        --secondary-color: #f8f9fa;
    }

    body {
        background-color: #f5f7fb;
    }

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

    .card-header {
        font-weight: 600;
        letter-spacing: 0.5px;
        background-color: var(--primary-color);
    }

    .form-control, .form-select {
        border-radius: 6px;
        padding: 10px 15px;
        border: 1px solid #e0e0e0;
        transition: all 0.3s;
    }

    .form-control:focus, .form-select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.25rem rgba(2, 5, 72, 0.15);
    }

    .btn-outline-secondary {
        padding: 10px 25px;
        font-weight: 500;
    }

    .btn-primary {
        background-color: var(--primary-color);
        border-color: var(--primary-color);
        padding: 10px 25px;
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    .btn-primary:hover {
        background-color: var(--primary-hover);
        border-color: var(--primary-hover);
    }

    .form-check-input:checked {
        background-color: var(--primary-color);
        border-color: var(--primary-color);
    }

    input[type="file"] {
        padding: 8px;
    }

    input[type="file"]::file-selector-button {
        background-color: var(--primary-color);
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 4px;
        margin-right: 10px;
        cursor: pointer;
        transition: all 0.3s;
    }

    input[type="file"]::file-selector-button:hover {
        background-color: var(--primary-hover);
    }

    h4, h5, h6 {
        font-weight: 600;
    }

    .border-bottom {
        border-color: rgba(2, 5, 72, 0.1) !important;
    }

    textarea {
        min-height: 120px;
    }

    .text-danger.small {
        font-size: 0.875em;
        margin-top: 0.25rem;
    }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // Validation des prix
        document.querySelector('form').addEventListener('submit', function(e) {
            const priceStandard = document.getElementById('standard_price').value;
            const pricePremium = document.getElementById('premium_price').value;

            if (parseInt(pricePremium) <= parseInt(priceStandard)) {
                alert('Le prix premium doit être supérieur au prix standard');
                e.preventDefault();
                return false;
            }

            // Validation des horaires
            const startTime = document.getElementById('visit_start_time').value;
            const endTime = document.getElementById('visit_end_time').value;

            if (startTime && endTime && startTime >= endTime) {
                alert('L\'heure de fermeture doit être après l\'heure d\'ouverture');
                e.preventDefault();
                return false;
            }
        });

        // Formatage automatique des coordonnées GPS
        document.getElementById('lat').addEventListener('blur', function() {
            let value = this.value.replace(',', '.');
            if (value && !isNaN(parseFloat(value))) {
                this.value = parseFloat(value).toFixed(6);
            }
        });

        document.getElementById('longi').addEventListener('blur', function() {
            let value = this.value.replace(',', '.');
            if (value && !isNaN(parseFloat(value))) {
                this.value = parseFloat(value).toFixed(6);
            }
        });
    });
</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/formeEditSite.blade.php ENDPATH**/ ?>