<?php $__env->startSection('title', 'Dashboard'); ?>
<?php $__env->startSection('page-title', '⚙️ Pengaturan Website'); ?>

<?php $__env->startSection('content'); ?>
<div class="tabs">
    <button class="tab-btn active" onclick="switchTab('hero')">🎯 Hero</button>
    <button class="tab-btn" onclick="switchTab('general')">⚙️ Umum</button>
    <button class="tab-btn" onclick="switchTab('about')">🏆 Keunggulan</button>
    <button class="tab-btn" onclick="switchTab('services')">🔧 Layanan</button>
    <button class="tab-btn" onclick="switchTab('footer')">📄 Footer</button>
</div>

<form action="<?php echo e(route('admin.settings.update')); ?>" method="POST" enctype="multipart/form-data" id="settings-form">
    <?php echo csrf_field(); ?>
    <?php echo method_field('POST'); ?>

    
    <div class="tab-panel active" id="tab-hero">
        <div class="card">
            <div class="card-header">
                <h3>🎯 Hero Section</h3>
                <small style="color:#9CA3AF">Bagian pertama yang dilihat pengunjung</small>
            </div>
            <div class="card-body">
                <?php $heroGroup = $settings->get('hero', collect()); ?>
                
                <div class="form-group">
                    <label>Headline Utama</label>
                    <input type="text" name="hero_headline" class="form-control" 
                           value="<?php echo e($heroGroup->where('key','hero_headline')->first()?->value ?? ''); ?>">
                </div>
                <div class="form-group">
                    <label>Sub-headline</label>
                    <textarea name="hero_subheadline" class="form-control"><?php echo e($heroGroup->where('key','hero_subheadline')->first()?->value ?? ''); ?></textarea>
                </div>
                <div class="form-group">
                    <label>Teks Tombol CTA</label>
                    <input type="text" name="hero_cta_text" class="form-control" 
                           value="<?php echo e($heroGroup->where('key','hero_cta_text')->first()?->value ?? ''); ?>">
                </div>
                
                <div class="form-grid">
                    <div class="form-group">
                        <label>Gambar Hero</label>
                        <?php $heroImg = $heroGroup->where('key','hero_image')->first()?->value ?? ''; ?>
                        <div class="upload-area" onclick="document.getElementById('hero_image_file').click()">
                            <?php if($heroImg): ?>
                            <img src="<?php echo e($heroImg); ?>" class="upload-preview" id="hero_image_preview" alt="Preview">
                            <?php else: ?>
                            <div id="hero_image_preview" style="font-size:3rem;margin-bottom:8px">🖼️</div>
                            <?php endif; ?>
                            <p style="font-size:0.82rem;color:#9CA3AF">Klik untuk ganti gambar (JPG, PNG, WEBP)</p>
                        </div>
                        <input type="file" id="hero_image_file" accept="image/*" style="display:none"
                               onchange="previewAndUpload(this, 'hero_image_preview', 'hero_image')">
                        <input type="hidden" name="hero_image" id="hero_image" value="<?php echo e($heroImg); ?>">
                    </div>
                    
                    <div class="form-group">
                        <label>Video Hero (Opsional)</label>
                        <?php $heroVid = $heroGroup->where('key','hero_video')->first()?->value ?? ''; ?>
                        <div class="upload-area" onclick="document.getElementById('hero_video_file').click()">
                            <div style="font-size:3rem;margin-bottom:8px">🎬</div>
                            <p style="font-size:0.82rem;color:#9CA3AF"><?php echo e($heroVid ? 'Video aktif. Klik untuk ganti.' : 'Klik untuk upload video (MP4)'); ?></p>
                        </div>
                        <input type="file" id="hero_video_file" accept="video/*" style="display:none"
                               onchange="previewAndUpload(this, null, 'hero_video')">
                        <input type="hidden" name="hero_video" id="hero_video" value="<?php echo e($heroVid); ?>">
                    </div>
                </div>
            </div>
        </div>
    </div>

    
    <div class="tab-panel" id="tab-general">
        <div class="card">
            <div class="card-header"><h3>⚙️ Pengaturan Umum</h3></div>
            <div class="card-body">
                <?php $generalGroup = $settings->get('general', collect()); ?>
                
                <div class="form-group">
                    <label>Logo Bengkel</label>
                    <?php $logoVal = $generalGroup->where('key','logo')->first()?->value ?? ''; ?>
                    <div class="upload-area" onclick="document.getElementById('logo_file').click()">
                        <?php if($logoVal): ?>
                        <img src="<?php echo e($logoVal); ?>" class="upload-preview" id="logo_preview" alt="Logo Preview">
                        <?php else: ?>
                        <div id="logo_preview" style="font-size:3rem;margin-bottom:8px">🏷️</div>
                        <?php endif; ?>
                        <p style="font-size:0.82rem;color:#9CA3AF">Klik untuk ganti logo</p>
                    </div>
                    <input type="file" id="logo_file" accept="image/*" style="display:none"
                           onchange="previewAndUpload(this, 'logo_preview', 'logo')">
                    <input type="hidden" name="logo" id="logo" value="<?php echo e($logoVal); ?>">
                </div>
                
                <div class="form-grid">
                    <div class="form-group">
                        <label>Nama Bengkel</label>
                        <input type="text" name="site_name" class="form-control" 
                               value="<?php echo e($generalGroup->where('key','site_name')->first()?->value ?? ''); ?>">
                    </div>
                    <div class="form-group">
                        <label>Nomor WhatsApp (dengan kode negara)</label>
                        <input type="text" name="whatsapp" class="form-control" 
                               value="<?php echo e($generalGroup->where('key','whatsapp')->first()?->value ?? ''); ?>"
                               placeholder="628123456789">
                    </div>
                </div>
                
                <div class="form-group">
                    <label>Jam Operasional</label>
                    <input type="text" name="open_hours" class="form-control" 
                           value="<?php echo e($generalGroup->where('key','open_hours')->first()?->value ?? ''); ?>">
                </div>
                
                <div class="form-group">
                    <label>Alamat Bengkel</label>
                    <textarea name="address" class="form-control"><?php echo e($generalGroup->where('key','address')->first()?->value ?? ''); ?></textarea>
                </div>
                
                <div class="form-group">
                    <label>Google Maps Embed URL</label>
                    <input type="text" name="maps_embed" class="form-control" 
                           value="<?php echo e($generalGroup->where('key','maps_embed')->first()?->value ?? ''); ?>"
                           placeholder="https://www.google.com/maps/embed?pb=...">
                    <small style="color:#9CA3AF;font-size:0.78rem;">Buka Google Maps → Share → Embed a map → salin link dari src="..."</small>
                </div>
            </div>
        </div>
    </div>

    
    <div class="tab-panel" id="tab-about">
        <div class="card">
            <div class="card-header"><h3>🏆 Keunggulan Kami</h3></div>
            <div class="card-body">
                <?php 
                    $aboutGroup = $settings->get('about', collect());
                    $featuresRaw = $aboutGroup->where('key','features')->first()?->value ?? '[]';
                    $featuresData = json_decode($featuresRaw, true) ?? [];
                ?>
                
                <div class="form-grid">
                    <div class="form-group">
                        <label>Judul Section</label>
                        <input type="text" name="about_title" class="form-control" 
                               value="<?php echo e($aboutGroup->where('key','about_title')->first()?->value ?? ''); ?>">
                    </div>
                    <div class="form-group">
                        <label>Subtitle</label>
                        <input type="text" name="about_subtitle" class="form-control" 
                               value="<?php echo e($aboutGroup->where('key','about_subtitle')->first()?->value ?? ''); ?>">
                    </div>
                </div>

                <div style="margin-bottom:12px;font-weight:700;font-size:0.9rem;">Daftar Keunggulan:</div>
                <div class="json-items" id="features-list">
                    <?php $__currentLoopData = $featuresData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $fi => $feat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="json-item" id="feature-item-<?php echo e($fi); ?>">
                        <div class="json-item-header">
                            <span class="json-item-title">Keunggulan #<?php echo e($fi + 1); ?></span>
                            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('feature-item-<?php echo e($fi); ?>')">Hapus</button>
                        </div>
                        <div class="form-grid">
                            <div class="form-group">
                                <label>Icon (Gambar PNG)</label>
                                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('feat_icon_file_<?php echo e($fi); ?>').click()">
                                    <?php if(!empty($feat['icon'])): ?>
                                    <img src="<?php echo e($feat['icon']); ?>" class="upload-preview" id="feat_icon_preview_<?php echo e($fi); ?>" style="max-height:60px;object-fit:contain;margin-bottom:8px;" alt="Icon">
                                    <?php else: ?>
                                    <div id="feat_icon_preview_<?php echo e($fi); ?>" style="font-size:2rem;margin-bottom:4px">🖼️</div>
                                    <?php endif; ?>
                                </div>
                                <input type="file" id="feat_icon_file_<?php echo e($fi); ?>" accept="image/png, image/jpeg, image/webp" style="display:none"
                                       onchange="previewAndUpload(this, 'feat_icon_preview_<?php echo e($fi); ?>', 'feat_icon_<?php echo e($fi); ?>')">
                                <input type="hidden" name="feat_icon[]" id="feat_icon_<?php echo e($fi); ?>" value="<?php echo e($feat['icon'] ?? ''); ?>">
                            </div>
                            <div class="form-group">
                                <label>Judul</label>
                                <input type="text" name="feat_title[]" class="form-control" value="<?php echo e($feat['title'] ?? ''); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>Deskripsi</label>
                            <textarea name="feat_desc[]" class="form-control" style="min-height:70px"><?php echo e($feat['desc'] ?? ''); ?></textarea>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <button type="button" class="btn btn-primary" onclick="addFeatureItem()" style="margin-top:16px">+ Tambah Keunggulan</button>
                <input type="hidden" name="features" id="features-hidden">
            </div>
        </div>
    </div>

    
    <div class="tab-panel" id="tab-services">
        <div class="card">
            <div class="card-header"><h3>🔧 Layanan Kami</h3></div>
            <div class="card-body">
                <?php 
                    $servicesGroup = $settings->get('services', collect());
                    $servicesRaw = $servicesGroup->where('key','services')->first()?->value ?? '[]';
                    $servicesData = json_decode($servicesRaw, true) ?? [];
                ?>
                
                <div class="form-group">
                    <label>Judul Section Layanan</label>
                    <input type="text" name="services_title" class="form-control" 
                           value="<?php echo e($servicesGroup->where('key','services_title')->first()?->value ?? ''); ?>">
                </div>

                <div class="json-items" id="services-list">
                    <?php $__currentLoopData = $servicesData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $si => $svc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="json-item" id="service-item-<?php echo e($si); ?>">
                        <div class="json-item-header">
                            <span class="json-item-title">Layanan #<?php echo e($si + 1); ?></span>
                            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('service-item-<?php echo e($si); ?>')">Hapus</button>
                        </div>
                        <div class="form-grid-3">
                            <div class="form-group">
                                <label>Icon (Gambar PNG)</label>
                                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('svc_icon_file_<?php echo e($si); ?>').click()">
                                    <?php if(!empty($svc['icon'])): ?>
                                    <img src="<?php echo e($svc['icon']); ?>" class="upload-preview" id="svc_icon_preview_<?php echo e($si); ?>" style="max-height:60px;object-fit:contain;margin-bottom:8px;" alt="Icon">
                                    <?php else: ?>
                                    <div id="svc_icon_preview_<?php echo e($si); ?>" style="font-size:2rem;margin-bottom:4px">🖼️</div>
                                    <?php endif; ?>
                                </div>
                                <input type="file" id="svc_icon_file_<?php echo e($si); ?>" accept="image/png, image/jpeg, image/webp" style="display:none"
                                       onchange="previewAndUpload(this, 'svc_icon_preview_<?php echo e($si); ?>', 'svc_icon_<?php echo e($si); ?>')">
                                <input type="hidden" name="svc_icon[]" id="svc_icon_<?php echo e($si); ?>" value="<?php echo e($svc['icon'] ?? ''); ?>">
                            </div>
                            <div class="form-group">
                                <label>Nama Layanan</label>
                                <input type="text" name="svc_title[]" class="form-control" value="<?php echo e($svc['title'] ?? ''); ?>">
                            </div>
                            <div class="form-group">
                                <label>Harga</label>
                                <input type="text" name="svc_price[]" class="form-control" value="<?php echo e($svc['price'] ?? ''); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>Deskripsi</label>
                            <textarea name="svc_desc[]" class="form-control" style="min-height:70px"><?php echo e($svc['desc'] ?? ''); ?></textarea>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <button type="button" class="btn btn-primary" onclick="addServiceItem()" style="margin-top:16px">+ Tambah Layanan</button>
                <input type="hidden" name="services" id="services-hidden">
            </div>
        </div>
    </div>

    
    <div class="tab-panel" id="tab-footer">
        <div class="card">
            <div class="card-header"><h3>📄 Footer & CTA</h3></div>
            <div class="card-body">
                <?php 
                    $footerGroup = $settings->get('footer', collect());
                    $socialMediaRaw = $settings->flatten()->where('key','social_media')->first()?->value ?? '[]';
                    $socialMediaData = json_decode($socialMediaRaw, true) ?? [];
                ?>
                <div class="form-group">
                    <label>Judul Footer CTA</label>
                    <input type="text" name="footer_cta_title" class="form-control" 
                           value="<?php echo e($footerGroup->where('key','footer_cta_title')->first()?->value ?? ''); ?>">
                </div>
                <div class="form-group">
                    <label>Subtitle Footer CTA</label>
                    <textarea name="footer_cta_subtitle" class="form-control"><?php echo e($footerGroup->where('key','footer_cta_subtitle')->first()?->value ?? ''); ?></textarea>
                </div>

                <hr style="margin:24px 0; border:0; border-top:1px solid #E5E5E5;">
                <div style="margin-bottom:12px;font-weight:700;font-size:0.9rem;">Ikon Sosial Media:</div>
                <div class="json-items" id="social-list">
                    <?php $__currentLoopData = $socialMediaData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $smi => $soc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="json-item" id="social-item-<?php echo e($smi); ?>">
                        <div class="json-item-header">
                            <span class="json-item-title">Sosial Media #<?php echo e($smi + 1); ?></span>
                            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('social-item-<?php echo e($smi); ?>')">Hapus</button>
                        </div>
                        <div class="form-grid-3">
                            <div class="form-group">
                                <label>Icon (Gambar/Emoji)</label>
                                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('soc_icon_file_<?php echo e($smi); ?>').click()">
                                    <?php if(!empty($soc['icon']) && (str_starts_with($soc['icon'], '/') || str_starts_with($soc['icon'], 'http'))): ?>
                                    <img src="<?php echo e($soc['icon']); ?>" class="upload-preview" id="soc_icon_preview_<?php echo e($smi); ?>" style="max-height:60px;object-fit:contain;margin-bottom:8px;" alt="Icon">
                                    <?php else: ?>
                                    <div id="soc_icon_preview_<?php echo e($smi); ?>" style="font-size:2rem;margin-bottom:4px"><?php echo e($soc['icon'] ?? '🖼️'); ?></div>
                                    <?php endif; ?>
                                </div>
                                <input type="file" id="soc_icon_file_<?php echo e($smi); ?>" accept="image/png, image/jpeg, image/webp" style="display:none"
                                       onchange="previewAndUpload(this, 'soc_icon_preview_<?php echo e($smi); ?>', 'soc_icon_<?php echo e($smi); ?>')">
                                <input type="text" name="soc_icon[]" id="soc_icon_<?php echo e($smi); ?>" value="<?php echo e($soc['icon'] ?? ''); ?>" class="form-control" placeholder="Atau ketik emoji (cth: 📸)" style="margin-top:8px;">
                            </div>
                            <div class="form-group">
                                <label>Nama Platform</label>
                                <input type="text" name="soc_title[]" class="form-control" value="<?php echo e($soc['title'] ?? ''); ?>" placeholder="Instagram">
                            </div>
                            <div class="form-group">
                                <label>URL</label>
                                <input type="url" name="soc_url[]" class="form-control" value="<?php echo e($soc['url'] ?? ''); ?>" placeholder="https://instagram.com/...">
                            </div>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
                <button type="button" class="btn btn-primary" onclick="addSocialItem()" style="margin-top:16px">+ Tambah Sosial Media</button>
                <input type="hidden" name="social_media" id="social-hidden">
            </div>
        </div>
    </div>

    <div style="margin-top:24px;display:flex;justify-content:flex-end;">
        <button type="submit" class="btn btn-primary" style="padding:14px 36px;font-size:1rem;">
            💾 Simpan Semua Perubahan
        </button>
    </div>
</form>

<script>
// Tabs
function switchTab(name) {
    document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
    document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
    document.getElementById('tab-' + name).classList.add('active');
    event.target.classList.add('active');
}

// File upload with preview
function previewAndUpload(input, previewId, hiddenId) {
    const file = input.files[0];
    if (!file) return;
    
    const formData = new FormData();
    formData.append('file', file);
    formData.append('_token', '<?php echo e(csrf_token()); ?>');

    fetch('<?php echo e(route("admin.upload")); ?>', { method: 'POST', body: formData })
        .then(r => r.json())
        .then(data => {
            if (data.success) {
                document.getElementById(hiddenId).value = data.url;
                if (previewId) {
                    const preview = document.getElementById(previewId);
                    if (preview.tagName === 'IMG') {
                        preview.src = data.url;
                    } else {
                        // Create img and replace
                        const img = document.createElement('img');
                        img.src = data.url;
                        img.className = 'upload-preview';
                        img.id = previewId;
                        if(previewId.includes('icon')) {
                            img.style.maxHeight = '60px';
                            img.style.objectFit = 'contain';
                            img.style.marginBottom = '8px';
                        }
                        preview.replaceWith(img);
                    }
                }
                alert('✅ File berhasil diupload!');
            }
        })
        .catch(err => alert('❌ Gagal upload: ' + err));
}

// Dynamic feature items
let featureCount = <?php echo e(count($featuresData)); ?>;
function addFeatureItem() {
    const list = document.getElementById('features-list');
    const id = 'feature-item-' + featureCount;
    const div = document.createElement('div');
    div.className = 'json-item';
    div.id = id;
    div.innerHTML = `
        <div class="json-item-header">
            <span class="json-item-title">Keunggulan #${featureCount + 1}</span>
            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('${id}')">Hapus</button>
        </div>
        <div class="form-grid">
            <div class="form-group">
                <label>Icon (Gambar PNG)</label>
                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('feat_icon_file_${featureCount}').click()">
                    <div id="feat_icon_preview_${featureCount}" style="font-size:2rem;margin-bottom:4px">🖼️</div>
                </div>
                <input type="file" id="feat_icon_file_${featureCount}" accept="image/png, image/jpeg, image/webp" style="display:none" onchange="previewAndUpload(this, 'feat_icon_preview_${featureCount}', 'feat_icon_${featureCount}')">
                <input type="hidden" name="feat_icon[]" id="feat_icon_${featureCount}">
            </div>
            <div class="form-group"><label>Judul</label><input type="text" name="feat_title[]" class="form-control" placeholder="Nama Keunggulan"></div>
        </div>
        <div class="form-group"><label>Deskripsi</label><textarea name="feat_desc[]" class="form-control" style="min-height:70px" placeholder="Deskripsi singkat..."></textarea></div>
    `;
    list.appendChild(div);
    featureCount++;
}

// Dynamic service items
let serviceCount = <?php echo e(count($servicesData)); ?>;
function addServiceItem() {
    const list = document.getElementById('services-list');
    const id = 'service-item-' + serviceCount;
    const div = document.createElement('div');
    div.className = 'json-item';
    div.id = id;
    div.innerHTML = `
        <div class="json-item-header">
            <span class="json-item-title">Layanan #${serviceCount + 1}</span>
            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('${id}')">Hapus</button>
        </div>
        <div class="form-grid-3">
            <div class="form-group">
                <label>Icon (Gambar PNG)</label>
                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('svc_icon_file_${serviceCount}').click()">
                    <div id="svc_icon_preview_${serviceCount}" style="font-size:2rem;margin-bottom:4px">🖼️</div>
                </div>
                <input type="file" id="svc_icon_file_${serviceCount}" accept="image/png, image/jpeg, image/webp" style="display:none" onchange="previewAndUpload(this, 'svc_icon_preview_${serviceCount}', 'svc_icon_${serviceCount}')">
                <input type="hidden" name="svc_icon[]" id="svc_icon_${serviceCount}">
            </div>
            <div class="form-group"><label>Nama Layanan</label><input type="text" name="svc_title[]" class="form-control" placeholder="Nama Layanan"></div>
            <div class="form-group"><label>Harga</label><input type="text" name="svc_price[]" class="form-control" placeholder="Mulai Rp 150.000"></div>
        </div>
        <div class="form-group"><label>Deskripsi</label><textarea name="svc_desc[]" class="form-control" style="min-height:70px"></textarea></div>
    `;
    list.appendChild(div);
    serviceCount++;
}

// Dynamic social items
let socialCount = <?php echo e(count($socialMediaData)); ?>;
function addSocialItem() {
    const list = document.getElementById('social-list');
    const id = 'social-item-' + socialCount;
    const div = document.createElement('div');
    div.className = 'json-item';
    div.id = id;
    div.innerHTML = `
        <div class="json-item-header">
            <span class="json-item-title">Sosial Media #${socialCount + 1}</span>
            <button type="button" class="btn btn-danger btn-sm" onclick="removeItem('${id}')">Hapus</button>
        </div>
        <div class="form-grid-3">
            <div class="form-group">
                <label>Icon (Gambar/Emoji)</label>
                <div class="upload-area" style="min-height:80px;padding:10px" onclick="document.getElementById('soc_icon_file_${socialCount}').click()">
                    <div id="soc_icon_preview_${socialCount}" style="font-size:2rem;margin-bottom:4px">🖼️</div>
                </div>
                <input type="file" id="soc_icon_file_${socialCount}" accept="image/png, image/jpeg, image/webp" style="display:none" onchange="previewAndUpload(this, 'soc_icon_preview_${socialCount}', 'soc_icon_${socialCount}')">
                <input type="text" name="soc_icon[]" id="soc_icon_${socialCount}" class="form-control" placeholder="Atau ketik emoji (cth: 📸)" style="margin-top:8px;">
            </div>
            <div class="form-group"><label>Nama Platform</label><input type="text" name="soc_title[]" class="form-control" placeholder="Instagram"></div>
            <div class="form-group"><label>URL</label><input type="url" name="soc_url[]" class="form-control" placeholder="https://instagram.com/..."></div>
        </div>
    `;
    list.appendChild(div);
    socialCount++;
}

function removeItem(id) {
    document.getElementById(id)?.remove();
}

// Before submit: collect JSON data
document.getElementById('settings-form').addEventListener('submit', function(e) {
    // Features JSON
    const featIcons = [...document.querySelectorAll('[name="feat_icon[]"]')].map(el => el.value);
    const featTitles = [...document.querySelectorAll('[name="feat_title[]"]')].map(el => el.value);
    const featDescs = [...document.querySelectorAll('[name="feat_desc[]"]')].map(el => el.value);
    const featJson = featIcons.map((icon, i) => ({ icon, title: featTitles[i], desc: featDescs[i] })).filter(f => f.title);
    document.getElementById('features-hidden').value = JSON.stringify(featJson);

    // Services JSON
    const svcIcons = [...document.querySelectorAll('[name="svc_icon[]"]')].map(el => el.value);
    const svcTitles = [...document.querySelectorAll('[name="svc_title[]"]')].map(el => el.value);
    const svcPrices = [...document.querySelectorAll('[name="svc_price[]"]')].map(el => el.value);
    const svcDescs = [...document.querySelectorAll('[name="svc_desc[]"]')].map(el => el.value);
    const svcJson = svcIcons.map((icon, i) => ({ icon, title: svcTitles[i], price: svcPrices[i], desc: svcDescs[i] })).filter(s => s.title);
    document.getElementById('services-hidden').value = JSON.stringify(svcJson);

    // Social JSON
    const socIcons = [...document.querySelectorAll('[name="soc_icon[]"]')].map(el => el.value);
    const socTitles = [...document.querySelectorAll('[name="soc_title[]"]')].map(el => el.value);
    const socUrls = [...document.querySelectorAll('[name="soc_url[]"]')].map(el => el.value);
    const socJson = socIcons.map((icon, i) => ({ icon, title: socTitles[i], url: socUrls[i] })).filter(s => s.title);
    document.getElementById('social-hidden').value = JSON.stringify(socJson);
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Dgufi\Herd\mjm\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>