<?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 mb-6">
        <a href="<?php echo e(route('transactions.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 Transaksi</h2>
            <p class="text-slate-500 mt-1 text-sm">Ubah detail transaksi</p>
        </div>
    </div>

    <div class="w-full max-w-2xl">
        <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('transactions.update', $transaction)); ?>" method="POST" enctype="multipart/form-data" x-data="{ type: '<?php echo e(old('type', $transaction->type)); ?>', removeAttachment: false }">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>

                <!-- Transaction Type Tabs -->
                <div class="flex rounded-xl bg-slate-100 p-1 mb-6">
                    <button type="button"
                            @click="type = 'expense'"
                            :class="type === 'expense' ? 'bg-white text-rose-600 shadow-md' : 'text-slate-500'"
                            class="flex-1 py-2.5 text-sm font-medium rounded-lg transition">
                        <i class="fas fa-arrow-up mr-2"></i>Pengeluaran
                    </button>
                    <button type="button"
                            @click="type = 'income'"
                            :class="type === 'income' ? 'bg-white text-emerald-600 shadow-md' : 'text-slate-500'"
                            class="flex-1 py-2.5 text-sm font-medium rounded-lg transition">
                        <i class="fas fa-arrow-down mr-2"></i>Pemasukan
                    </button>
                </div>
                <input type="hidden" name="type" x-model="type">

                <div class="space-y-6">
                    <!-- Amount -->
                    <div>
                        <label for="amount" class="block text-sm font-medium text-slate-700 mb-2">Jumlah</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 text-2xl font-bold bg-slate-50 border-slate-200 rounded-xl focus:border-teal-500 focus:ring-teal-500"
                                   :class="type === 'income' ? 'text-emerald-600' : 'text-rose-600'"
                                   value="<?php echo e(old('amount', $transaction->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 class="grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6">
                        <!-- Account -->
                        <div>
                            <label for="account_id" class="block text-sm font-medium text-slate-700 mb-2">Akun</label>
                            <select id="account_id" name="account_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 = $accounts ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($account->id); ?>" <?php echo e(old('account_id', $transaction->account_id) == $account->id ? 'selected' : ''); ?>>
                                        <?php echo e($account->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            <?php $__errorArgs = ['account_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>

                        <!-- Date -->
                        <div>
                            <label for="date" class="block text-sm font-medium text-slate-700 mb-2">Tanggal</label>
                            <input type="date" id="date" name="date"
                                   value="<?php echo e(old('date', $transaction->date?->format('Y-m-d') ?? $transaction->transaction_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">
                            <?php $__errorArgs = ['date'];
$__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>

                    <!-- Time -->
                    <div>
                        <label for="time" class="block text-sm font-medium text-slate-700 mb-2">Waktu</label>
                        <input type="time" id="time" name="time" step="1"
                               value="<?php echo e(old('time', $transaction->time ?? '00:00:00')); ?>"
                               class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                        <p class="mt-1 text-xs text-slate-400">Format: Jam:Menit:Detik</p>
                        <?php $__errorArgs = ['time'];
$__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>

                    <!-- Category -->
                    <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"
                                class="w-full bg-slate-50 border-slate-200 text-slate-800 rounded-xl focus:border-teal-500 focus:ring-teal-500">
                            <option value="">Pilih kategori...</option>
                            <?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', $transaction->category_id) == $category->id ? 'selected' : ''); ?>>
                                    <?php echo e($category->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <!-- Description -->
                    <div>
                        <label for="description" class="block text-sm font-medium text-slate-700 mb-2">Deskripsi</label>
                        <textarea id="description" name="description" 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('description', $transaction->description)); ?></textarea>
                    </div>

                    <!-- Attachment -->
                    <div x-data="{ preview: '<?php echo e($transaction->attachment ? url('storage/' . $transaction->attachment) : ''); ?>', hasExisting: <?php echo e($transaction->attachment ? 'true' : 'false'); ?> }">
                        <label class="block text-sm font-medium text-slate-700 mb-2">Lampiran Gambar</label>

                        <!-- Existing attachment -->
                        <template x-if="hasExisting && !removeAttachment">
                            <div class="mb-3 p-3 bg-slate-50 rounded-xl border border-slate-200 flex items-center justify-between">
                                <div class="flex items-center">
                                    <img src="<?php echo e($transaction->attachment ? url('storage/' . $transaction->attachment) : ''); ?>"
                                         class="w-16 h-16 object-cover rounded-lg mr-3">
                                    <div>
                                        <p class="text-sm font-medium text-slate-700"><?php echo e($transaction->attachment_name ?? 'Lampiran'); ?></p>
                                        <p class="text-xs text-slate-400">Gambar tersimpan</p>
                                    </div>
                                </div>
                                <button type="button" @click="removeAttachment = true"
                                        class="p-2 text-rose-500 hover:bg-rose-50 rounded-lg transition">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </div>
                        </template>
                        <input type="hidden" name="remove_attachment" :value="removeAttachment ? 1 : 0">

                        <!-- Upload new -->
                        <div class="flex items-center space-x-4" x-data="{ newPreview: null }">
                            <label class="flex-1 relative cursor-pointer">
                                <div class="flex items-center justify-center px-4 py-4 bg-slate-50 border-2 border-dashed border-slate-200 rounded-xl hover:border-teal-400 transition">
                                    <div class="text-center">
                                        <i class="fas fa-cloud-upload-alt text-2xl text-slate-400 mb-2"></i>
                                        <p class="text-sm text-slate-500" x-text="hasExisting && !removeAttachment ? 'Ganti gambar' : 'Upload gambar'">Upload gambar</p>
                                        <p class="text-xs text-slate-400 mt-1">JPG, PNG, GIF, WebP (Maks 5MB)</p>
                                    </div>
                                </div>
                                <input type="file" name="attachment" accept="image/*" class="sr-only"
                                       @change="newPreview = URL.createObjectURL($event.target.files[0])">
                            </label>
                            <template x-if="newPreview">
                                <div class="relative">
                                    <img :src="newPreview" class="w-24 h-24 object-cover rounded-xl border border-slate-200">
                                    <button type="button" @click="newPreview = null"
                                            class="absolute -top-2 -right-2 w-6 h-6 bg-rose-500 text-white rounded-full text-xs flex items-center justify-center hover:bg-rose-600">
                                        <i class="fas fa-times"></i>
                                    </button>
                                </div>
                            </template>
                        </div>
                        <?php $__errorArgs = ['attachment'];
$__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>

                <!-- Actions -->
                <div class="flex items-center justify-between mt-8 pt-6 border-t border-slate-100">
                    <button type="button" onclick="document.getElementById('deleteModal').classList.remove('hidden')"
                            class="text-rose-500 hover:text-rose-700 font-medium transition">
                        <i class="fas fa-trash mr-2"></i>Hapus
                    </button>
                    <div class="flex space-x-4">
                        <a href="<?php echo e(route('transactions.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>
                </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 Transaksi</h3>
                <p class="text-slate-500 text-center mb-6">Yakin ingin menghapus transaksi 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('transactions.destroy', $transaction)); ?>" 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\transactions\edit.blade.php ENDPATH**/ ?>