<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <!-- Header -->
    <div class="flex items-center justify-between mb-6">
        <div class="flex items-center">
            <a href="<?php echo e(route('budgets.index')); ?>" class="text-slate-400 hover:text-teal-600 mr-3 sm:mr-4 transition">
                <i class="fas fa-arrow-left text-lg sm:text-xl"></i>
            </a>
            <div>
                <h2 class="text-xl sm:text-2xl font-bold text-slate-800">Edit Anggaran</h2>
                <p class="text-slate-500 mt-1 text-sm">Ubah batas pengeluaran</p>
            </div>
        </div>
        <button type="button" onclick="document.getElementById('deleteModal').classList.remove('hidden')"
                class="text-rose-500 hover:text-rose-700 transition">
            <i class="fas fa-trash text-lg"></i>
        </button>
    </div>

    <div class="w-full max-w-2xl">
        <!-- Budget Progress -->
        <?php
            $percentage = $budget->amount > 0 ? ($budget->spent_amount / $budget->amount) * 100 : 0;
            $status = $percentage >= 100 ? 'exceeded' : ($percentage >= 80 ? 'warning' : 'on_track');
        ?>
        <div class="bg-white border border-slate-100 rounded-xl sm:rounded-2xl p-4 sm:p-5 shadow-sm mb-6">
            <div class="flex items-center justify-between mb-4">
                <h3 class="font-semibold text-slate-800">Progres Saat Ini</h3>
                <span class="px-3 py-1 rounded-full text-sm font-medium <?php echo e($status === 'exceeded' ? 'bg-rose-100 text-rose-600' : ($status === 'warning' ? 'bg-amber-100 text-amber-600' : 'bg-emerald-100 text-emerald-600')); ?>">
                    <?php echo e(number_format($percentage, 1)); ?>%
                </span>
            </div>
            <div class="w-full h-3 bg-slate-100 rounded-full overflow-hidden mb-3">
                <div class="h-full rounded-full transition-all <?php echo e($status === 'exceeded' ? 'bg-rose-500' : ($status === 'warning' ? 'bg-amber-500' : 'bg-emerald-500')); ?>"
                     style="width: <?php echo e(min($percentage, 100)); ?>%"></div>
            </div>
            <div class="flex justify-between text-sm">
                <span class="text-slate-500">Rp <?php echo e(number_format($budget->spent_amount ?? 0, 0, ',', '.')); ?> terpakai</span>
                <span class="text-slate-500">Sisa Rp <?php echo e(number_format(max(0, $budget->amount - ($budget->spent_amount ?? 0)), 0, ',', '.')); ?></span>
            </div>
        </div>

        <!-- Edit Form -->
        <div class="bg-white border border-slate-100 rounded-xl sm:rounded-2xl p-4 sm:p-6 shadow-sm">
            <form action="<?php echo e(route('budgets.update', $budget)); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>

                <div class="space-y-6">
                    <div>
                        <label for="category_id" class="block text-sm font-medium text-slate-700 mb-2">Kategori</label>
                        <select id="category_id" name="category_id" required
                                class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                            <?php $__currentLoopData = $categories ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($category->id); ?>" <?php echo e(old('category_id', $budget->category_id) == $category->id ? 'selected' : ''); ?>>
                                    <?php echo e($category->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php $__errorArgs = ['category_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="mt-1 text-sm text-rose-500"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div>
                        <label for="amount" class="block text-sm font-medium text-slate-700 mb-2">Jumlah Anggaran</label>
                        <div class="relative">
                            <span class="absolute inset-y-0 left-0 pl-4 flex items-center text-slate-500">Rp</span>
                            <input type="number" name="amount" id="amount" step="1" min="0"
                                   class="pl-12 w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500"
                                   value="<?php echo e(old('amount', $budget->amount)); ?>" required>
                        </div>
                        <?php $__errorArgs = ['amount'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="mt-1 text-sm text-rose-500"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div>
                        <label for="period" class="block text-sm font-medium text-slate-700 mb-2">Periode</label>
                        <select id="period" name="period" required
                                class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                            <option value="weekly" <?php echo e(old('period', $budget->period) === 'weekly' ? 'selected' : ''); ?>>Mingguan</option>
                            <option value="monthly" <?php echo e(old('period', $budget->period) === 'monthly' ? 'selected' : ''); ?>>Bulanan</option>
                            <option value="quarterly" <?php echo e(old('period', $budget->period) === 'quarterly' ? 'selected' : ''); ?>>Triwulan</option>
                            <option value="yearly" <?php echo e(old('period', $budget->period) === 'yearly' ? 'selected' : ''); ?>>Tahunan</option>
                        </select>
                        <?php $__errorArgs = ['period'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="mt-1 text-sm text-rose-500"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                        <div>
                            <label for="start_date" class="block text-sm font-medium text-slate-700 mb-2">Tanggal Mulai</label>
                            <input type="date" id="start_date" name="start_date"
                                   value="<?php echo e(old('start_date', $budget->start_date?->format('Y-m-d'))); ?>" required
                                   class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                        </div>
                        <div>
                            <label for="end_date" class="block text-sm font-medium text-slate-700 mb-2">Tanggal Akhir</label>
                            <input type="date" id="end_date" name="end_date"
                                   value="<?php echo e(old('end_date', $budget->end_date?->format('Y-m-d'))); ?>"
                                   class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                        </div>
                    </div>

                    <div>
                        <label for="alert_threshold" class="block text-sm font-medium text-slate-700 mb-2">Ambang Peringatan (%)</label>
                        <input type="number" id="alert_threshold" name="alert_threshold"
                               value="<?php echo e(old('alert_threshold', $budget->alert_threshold)); ?>" min="1" max="100"
                               class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                    </div>

                    <div>
                        <label for="notes" class="block text-sm font-medium text-slate-700 mb-2">Catatan</label>
                        <textarea id="notes" name="notes" rows="2"
                                  class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500 placeholder-slate-400"><?php echo e(old('notes', $budget->notes)); ?></textarea>
                    </div>

                    <div class="flex items-center space-x-6">
                        <div class="flex items-center">
                            <input type="checkbox" id="rollover" name="rollover" value="1"
                                   class="rounded border-slate-300 text-teal-600 focus:ring-teal-500"
                                   <?php echo e(old('rollover', $budget->rollover ?? false) ? 'checked' : ''); ?>>
                            <label for="rollover" class="ml-2 text-sm text-slate-700">
                                Lanjutkan anggaran
                            </label>
                        </div>
                        <div class="flex items-center">
                            <input type="checkbox" id="is_active" name="is_active" value="1"
                                   class="rounded border-slate-300 text-teal-600 focus:ring-teal-500"
                                   <?php echo e(old('is_active', $budget->is_active ?? true) ? 'checked' : ''); ?>>
                            <label for="is_active" class="ml-2 text-sm text-slate-700">
                                Aktif
                            </label>
                        </div>
                    </div>
                </div>

                <div class="flex items-center justify-end space-x-4 mt-8 pt-6 border-t border-slate-100">
                    <a href="<?php echo e(route('budgets.index')); ?>" class="px-5 py-2.5 text-slate-600 hover:text-slate-800 font-medium rounded-xl transition">Batal</a>
                    <button type="submit" class="px-6 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-500 hover:from-teal-600 hover:to-emerald-600 text-white font-medium rounded-xl transition shadow-lg shadow-teal-500/30">
                        <i class="fas fa-save mr-2"></i>Simpan Perubahan
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Delete Modal -->
    <div id="deleteModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
        <div class="flex items-center justify-center min-h-screen px-4">
            <div class="fixed inset-0 bg-black/50" onclick="document.getElementById('deleteModal').classList.add('hidden')"></div>
            <div class="relative bg-white rounded-2xl shadow-xl max-w-md w-full p-6">
                <div class="w-14 h-14 bg-rose-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <i class="fas fa-trash text-rose-500 text-xl"></i>
                </div>
                <h3 class="text-lg font-bold text-slate-800 text-center mb-2">Hapus Anggaran</h3>
                <p class="text-slate-500 text-center mb-6">Yakin ingin menghapus anggaran ini? Tindakan ini tidak dapat dibatalkan.</p>
                <div class="flex justify-center space-x-4">
                    <button type="button" onclick="document.getElementById('deleteModal').classList.add('hidden')"
                            class="px-5 py-2.5 text-slate-600 hover:text-slate-800 font-medium transition">Batal</button>
                    <form action="<?php echo e(route('budgets.destroy', $budget)); ?>" method="POST" class="inline">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <button type="submit" class="px-5 py-2.5 bg-rose-500 hover:bg-rose-600 text-white font-medium rounded-xl transition">
                            Ya, Hapus
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\mymoney-app\resources\views\budgets\edit.blade.php ENDPATH**/ ?>