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

<?php
    // Fungsi untuk membaca isi file CSS saat Edit Tema
    $cssDesktop = '';
    $cssMobile = '';
    if(isset($theme->warna) && \Illuminate\Support\Facades\File::exists(public_path($theme->warna))) {
        $cssDesktop = \Illuminate\Support\Facades\File::get(public_path($theme->warna));
    }
    if(isset($theme->warna_mobile) && \Illuminate\Support\Facades\File::exists(public_path($theme->warna_mobile))) {
        $cssMobile = \Illuminate\Support\Facades\File::get(public_path($theme->warna_mobile));
    }
?>
<div class="row">
    
    <?php if(Route::is('admin.website.theme.edit')): ?>
    <div class="col-lg-4 mb-3">
        <div class="card">
            <div class="card-body">
                <h4 class="card-title">Edit Tema</h4>
                <form class="form p-t-20" enctype="multipart/form-data" action="<?php echo e(route('admin.website.theme.update', $theme->id)); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    
                    <div class="form-group">
                        <label>Nama Tema</label>
                        <div class="input-group mb-3">
                            <input type="text" class="form-control" name="name" required value="<?php echo e($theme->name); ?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label>Desktop CSS (Paste Kode CSS di sini)</label>
                        <small class="d-block text-muted mb-2">Cari CSS Desktop di: https://domain_target.com/assets/css/style.css</small>
                        <textarea class="form-control" name="warna" rows="6" placeholder="body { background: #000; }" <?php echo e(isset($theme->warna) ? '' : 'required'); ?>><?php echo e($cssDesktop); ?></textarea>
                    </div>

                    <div class="form-group mt-3">
                        <label>Mobile CSS (Paste Kode CSS di sini)</label>
                        <small class="d-block text-muted mb-2">Cari CSS Mobile di: https://domain_target.com/assets/css/style-m.css</small>
                        <textarea class="form-control" name="warna_mobile" rows="6" placeholder="body { background: #000; }" <?php echo e(isset($theme->warna_mobile) ? '' : 'required'); ?>><?php echo e($cssMobile); ?></textarea>
                    </div>

                    <hr>
                    <small class="text-danger">*Kosongkan file di bawah ini jika tidak ingin mengubah gambar.</small>

                    <div class="form-group mt-2">
                        <label>Thumbnail Tema <small>(Opsional)</small></label>
                        <input type="file" class="form-control mb-1" name="gambar" accept="image/*">
                        <?php if($theme->gambar): ?> <img src="<?php echo e(asset('uploads/'.$theme->gambar)); ?>" width="80" style="border-radius: 5px;"> <?php endif; ?>
                    </div>
                    <div class="form-group">
                        <label>Jackpot IMG (Global)</label>
                        <small class="d-block text-muted mb-2">domain_target/assets/img/progressive-jackpot-text.png</small>
                        <input type="file" class="form-control mb-1" name="jackpot" accept="image/*">
                        <?php if($theme->jackpot): ?> <img src="<?php echo e(asset('uploads/'.$theme->jackpot)); ?>" height="30" style="background:#333; padding:2px; border-radius:3px;"> <?php endif; ?>
                    </div>
                    <div class="form-group">
                        <label>Jackpot Desktop BG</label>
                        <small class="d-block text-muted mb-2">domain_target/assets/img/progressive-jackpot.webp</small>
                        <input type="file" class="form-control mb-1" name="jackpot_desktop" accept="image/*">
                        <?php if($theme->jackpot_desktop): ?> <img src="<?php echo e(asset('uploads/'.$theme->jackpot_desktop)); ?>" height="30" style="border-radius:3px;"> <?php endif; ?>
                    </div>
                    <div class="form-group">
                        <label>Jackpot Mobile BG</label>
                        <small class="d-block text-muted mb-2">domain_target/assets/img/progressive-jackpot-m.png</small>
                        <input type="file" class="form-control mb-1" name="jackpot_mobile" accept="image/*">
                        <?php if($theme->jackpot_mobile): ?> <img src="<?php echo e(asset('uploads/'.$theme->jackpot_mobile)); ?>" height="30" style="border-radius:3px;"> <?php endif; ?>
                    </div>
                    <div class="form-group">
                        <label>Download Icon</label>
                        <small class="d-block text-muted mb-2">domain_target/assets/img/download.webp</small>
                        <input type="file" class="form-control mb-1" name="download" accept="image/*">
                        <?php if($theme->download): ?> <img src="<?php echo e(asset('uploads/'.$theme->download)); ?>" height="50"> <?php endif; ?>
                    </div>
                    <div class="form-group">
                        <label>Contact Icon</label>
                        <small class="d-block text-muted mb-2">domain_target/assets/img/contact.webp</small>
                        <input type="file" class="form-control mb-1" name="contact" accept="image/*">
                        <?php if($theme->contact): ?> <img src="<?php echo e(asset('uploads/'.$theme->contact)); ?>" height="50"> <?php endif; ?>
                    </div>

                    <button type="submit" class="btn btn-primary m-r-10 mt-3" name="upload">Update Tema</button>
                    <a href="<?php echo e(route('admin.website.theme')); ?>" class="btn btn-secondary mt-3">Batal</a>
                </form>
            </div>
        </div>
    </div>

    
    <?php else: ?>
    <div class="col-lg-4 mb-3">
        <div class="card">
            <div class="card-body">
                <h4 class="card-title">Tambah Tema Baru</h4>
                <form class="form p-t-20" enctype="multipart/form-data" action="<?php echo e(route('admin.website.theme.create')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="form-group">
                        <label>Nama Tema</label>
                        <div class="input-group mb-3">
                            <input type="text" class="form-control" name="name" required placeholder="Masukkan nama tema">
                        </div>
                    </div>

                    <div class="form-group">
                        <label>Desktop CSS (Paste Kode CSS di sini)</label>
                        <small class="d-block text-muted mb-2">Cari CSS Desktop di: https://domain_target.com/assets/css/style.css</small>
                        <textarea class="form-control" name="warna" rows="6" placeholder="body { background: #000; }" <?php echo e(isset($theme->warna) ? '' : 'required'); ?>><?php echo e($cssDesktop); ?></textarea>
                    </div>

                    <div class="form-group mt-3">
                        <label>Mobile CSS (Paste Kode CSS di sini)</label>
                        <small class="d-block text-muted mb-2">Cari CSS Mobile di: https://domain_target.com/assets/css/style-m.css</small>
                        <textarea class="form-control" name="warna_mobile" rows="6" placeholder="body { background: #000; }" <?php echo e(isset($theme->warna_mobile) ? '' : 'required'); ?>><?php echo e($cssMobile); ?></textarea>
                    </div>

                    <hr>

                    <div class="form-group mt-2">
                        <label>Thumbnail Tema <small>(Opsional)</small></label>
                        <input type="file" class="form-control" name="gambar" accept="image/*">
                    </div>
                    <div class="form-group">
                        <label>Jackpot IMG (Global)</label>
                        <small class="d-block text-muted mb-2">Cari di: domain_target/assets/img/progressive-jackpot-text.png</small>
                        <input type="file" class="form-control" name="jackpot" accept="image/*" required>
                    </div>
                    <div class="form-group">
                        <label>Jackpot Desktop BG</label>
                        <small class="d-block text-muted mb-2">Cari di: domain_target/assets/img/progressive-jackpot.webp</small>
                        <input type="file" class="form-control" name="jackpot_desktop" accept="image/*">
                    </div>
                    <div class="form-group">
                        <label>Jackpot Mobile BG</label>
                        <small class="d-block text-muted mb-2">Cari di: domain_target/assets/img/progressive-jackpot-m.png</small>
                        <input type="file" class="form-control" name="jackpot_mobile" accept="image/*">
                    </div>
                    <div class="form-group">
                        <label>Download Icon</label>
                        <small class="d-block text-muted mb-2">Cari di: domain_target/assets/img/download.webp</small>
                        <input type="file" class="form-control" name="download" accept="image/*">
                    </div>
                    <div class="form-group">
                        <label>Contact Icon</label>
                        <small class="d-block text-muted mb-2">Cari di: domain_target/assets/img/contact.webp</small>
                        <input type="file" class="form-control" name="contact" accept="image/*">
                    </div>

                    <button type="submit" class="btn btn-primary m-r-10 mt-3" name="upload">Submit Tema</button>
                </form>
            </div>
        </div>
    </div>
    <?php endif; ?>

    
    <div class="col-lg-8 mb-3">
        <div class="card mb-3">
            <div class="card-body">
                <h4 class="card-title">Select Active Theme</h4>
                <form class="form" action="<?php echo e(route('admin.website.theme.active')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="input-group">
                        <select name="status" class="form-control select2" required>
                            <option value=""> -- Pilih Tema -- </option>
                            <?php $__currentLoopData = $themes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($item->id); ?>" <?php echo e($item->status == 'active' ? 'selected' : ''); ?>> <?php echo e($item->name); ?> </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <button type="submit" class="btn btn-success" name="upload">Aktifkan Tema</button>
                    </div>
                </form>
            </div>
        </div>

        <div class="card">
            <div class="card-datatable table-responsive pt-3">
                <table id="default-datatable" class="table table-bordered table-sm table-hover">
                    <thead class="table-dark">
                        <tr>
                            <th class="text-center" style="vertical-align: middle;">#</th>
                            <th class="text-center" style="vertical-align: middle;">Nama Tema</th>
                            <th class="text-center" style="vertical-align: middle;">Thumbnail</th>
                            <th class="text-center" style="vertical-align: middle;">CSS (Desktop & Mobile)</th>
                            <th class="text-center" style="vertical-align: middle;">Jackpot (Global | D | M)</th>
                            <th class="text-center" style="vertical-align: middle;">Icons (DL | Contact)</th>
                            <th class="text-center" style="vertical-align: middle;">Status</th>
                            <th class="text-center" style="vertical-align: middle;">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $themes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <th class="text-center" style="vertical-align: middle; font-size: 13px;"><?php echo e($loop->iteration); ?></th>
                            
                            
                            <td style="vertical-align: middle; font-size: 13px; font-weight: bold; white-space: nowrap;">
                                <?php echo e($item->name); ?>

                            </td>
        
                            
                            <td class="text-center" style="vertical-align: middle;">
                                <?php if($item->gambar): ?>
                                    <span class="text-muted">-</span>
                                <?php else: ?>
                                    <span class="text-muted">-</span>
                                <?php endif; ?>
                            </td>
        
                            
                            <td style="vertical-align: middle; font-size: 11px; white-space: normal; max-width: 250px; word-wrap: break-word;">
                                <div style="margin-bottom: 3px;">
                                    <strong>D:</strong> 
                                    <a href="<?php echo e($item->warna); ?>" target="_blank" class="text-primary text-decoration-none" title="<?php echo e($item->warna); ?>">
                                        <?php echo e(\Illuminate\Support\Str::limit($item->warna, 35)); ?>

                                    </a>
                                </div>
                                <div>
                                    <strong>M:</strong> 
                                    <a href="<?php echo e($item->warna_mobile); ?>" target="_blank" class="text-primary text-decoration-none" title="<?php echo e($item->warna_mobile); ?>">
                                        <?php echo e(\Illuminate\Support\Str::limit($item->warna_mobile, 35)); ?>

                                    </a>
                                </div>
                            </td>
        
                            
                            <td class="text-center" style="vertical-align: middle; background: #fdfdfd;">
                                <div style="display: flex; justify-content: center; align-items: center; gap: 8px;">
                                    <?php if($item->jackpot): ?> 
                                        <img style="height: 25px; background: #333; padding: 2px; border-radius: 3px;" src="<?php echo e(asset('uploads/'.$item->jackpot)); ?>" title="Jackpot Global"> 
                                    <?php else: ?> <span class="text-muted">-</span> <?php endif; ?>
                                    |
                                    <?php if($item->jackpot_desktop): ?> 
                                        <img style="height: 25px; border-radius: 3px; border: 1px solid #ddd;" src="<?php echo e(asset('uploads/'.$item->jackpot_desktop)); ?>" title="Jackpot Desktop"> 
                                    <?php else: ?> <span class="text-muted">-</span> <?php endif; ?>
                                    |
                                    <?php if($item->jackpot_mobile): ?> 
                                        <img style="height: 25px; border-radius: 3px; border: 1px solid #ddd;" src="<?php echo e(asset('uploads/'.$item->jackpot_mobile)); ?>" title="Jackpot Mobile"> 
                                    <?php else: ?> <span class="text-muted">-</span> <?php endif; ?>
                                </div>
                            </td>
        
                            
                            <td class="text-center" style="vertical-align: middle;">
                                <div style="display: flex; justify-content: center; align-items: center; gap: 8px;">
                                    <?php if($item->download): ?> 
                                        <img style="height: 30px; border-radius: 3px;" src="<?php echo e(asset('uploads/'.$item->download)); ?>" title="Icon Download"> 
                                    <?php else: ?> <span class="text-muted">-</span> <?php endif; ?>
                                    |
                                    <?php if($item->contact): ?> 
                                        <img style="height: 30px; border-radius: 3px;" src="<?php echo e(asset('uploads/'.$item->contact)); ?>" title="Icon Contact"> 
                                    <?php else: ?> <span class="text-muted">-</span> <?php endif; ?>
                                </div>
                            </td>
        
                            
                            <td class="text-center" style="vertical-align: middle; font-size: 13px;">
                                <?php if($item->status == 'active'): ?>
                                    <span class="badge bg-success">Active</span>
                                <?php else: ?>
                                    <span class="badge bg-secondary">Disable</span>
                                <?php endif; ?>
                            </td>
        
                            
                            <td class="text-center" style="vertical-align: middle;">
                                <a href="<?php echo e(route('admin.website.theme.edit', $item->id)); ?>" class="btn btn-sm btn-primary" title="Edit"><i class="mdi mdi-pencil"></i></a>
                                <a href="<?php echo e(route('admin.website.theme.delete', $item->id)); ?>" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus tema ini?');" title="Hapus"><i class="mdi mdi-trash-can"></i></a>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('backend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /www/wwwroot/website/sewa/gbo86/resources/views/backend/theme/theme.blade.php ENDPATH**/ ?>