<?php $__env->startSection('title', 'Informasi Kontak'); ?>
<?php $__env->startSection('page-title', 'Informasi Kontak Desa'); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-3xl">
    <form method="POST" action="<?php echo e(route('admin.contact.update')); ?>" class="space-y-5">
        <?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>

        <div class="card-admin grid grid-cols-1 md:grid-cols-2 gap-4">
            <div class="md:col-span-2"><label class="form-label">Nama Kantor *</label><input name="nama_kantor" value="<?php echo e(old('nama_kantor', $contact->nama_kantor)); ?>" class="form-input" required></div>
            <div class="md:col-span-2"><label class="form-label">Alamat</label><textarea name="alamat" rows="2" class="form-textarea"><?php echo e(old('alamat', $contact->alamat)); ?></textarea></div>
            <div><label class="form-label">Telepon</label><input name="telepon" value="<?php echo e(old('telepon', $contact->telepon)); ?>" class="form-input" placeholder="0852xxxxxxxx"></div>
            <div><label class="form-label">WhatsApp</label><input name="whatsapp" value="<?php echo e(old('whatsapp', $contact->whatsapp)); ?>" class="form-input" placeholder="0852xxxxxxxx"></div>
            <div><label class="form-label">Email</label><input type="email" name="email" value="<?php echo e(old('email', $contact->email)); ?>" class="form-input"></div>
            <div><label class="form-label">Jam Pelayanan</label><input name="jam_pelayanan" value="<?php echo e(old('jam_pelayanan', $contact->jam_pelayanan)); ?>" class="form-input" placeholder="Senin–Jumat, 08.00–15.00 WIB"></div>
        </div>

        
        <div class="card-admin">
            <label class="form-label mb-3">Lokasi Kantor Desa (klik peta untuk ubah)</label>
            <div id="contact-admin-map" class="w-full rounded-xl overflow-hidden border border-gray-200" style="height:300px;"></div>
            <div class="grid grid-cols-2 gap-4 mt-4">
                <div><label class="form-label">Latitude</label><input type="text" name="latitude" id="lat-input" value="<?php echo e(old('latitude', $contact->latitude)); ?>" class="form-input font-mono"></div>
                <div><label class="form-label">Longitude</label><input type="text" name="longitude" id="lng-input" value="<?php echo e(old('longitude', $contact->longitude)); ?>" class="form-input font-mono"></div>
            </div>
        </div>

        <?php if($errors->any()): ?>
            <div class="bg-red-50 border border-red-200 rounded-lg p-3">
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><p class="text-red-600 text-sm"><?php echo e($e); ?></p><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        <?php endif; ?>

        <button type="submit" class="btn-primary">💾 Simpan Perubahan</button>
    </form>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    const lat = parseFloat(document.getElementById('lat-input').value) || -3.85;
    const lng = parseFloat(document.getElementById('lng-input').value) || 101.90;

    const map = L.map('contact-admin-map').setView([lat, lng], 15);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '© OpenStreetMap contributors'
    }).addTo(map);

    let marker = L.marker([lat, lng], { draggable: true }).addTo(map);

    map.on('click', function(e) {
        marker.setLatLng(e.latlng);
        document.getElementById('lat-input').value = e.latlng.lat.toFixed(7);
        document.getElementById('lng-input').value = e.latlng.lng.toFixed(7);
    });

    marker.on('dragend', function(e) {
        const pos = e.target.getLatLng();
        document.getElementById('lat-input').value = pos.lat.toFixed(7);
        document.getElementById('lng-input').value = pos.lng.toFixed(7);
    });
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH F:\web Desa Suka Baru\website-desa-suka-baru\resources\views/admin/contact/edit.blade.php ENDPATH**/ ?>