
<?php $__env->startSection('title','Edit Installment #'.$installment->id); ?>

<?php $__env->startPush('styles'); ?>
    
    <link rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<?php $__env->stopPush(); ?>

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

<style>
    :root{
        --inst-primary:#dc2626;
        --inst-primary-soft:#fee2e2;
        --inst-bg:#f5f5f5;
    }

    .inst-edit-bg{
        background:var(--inst-bg);
    }

    .inst-card{
        border-radius:1rem;
        box-shadow:0 10px 28px rgba(15,23,42,.08);
        border:1px solid #e5e7eb;
        background:#fff;
    }

    .inst-section-title{
        font-size:.8rem;
        font-weight:600;
        text-transform:uppercase;
        letter-spacing:.08em;
        color:#6b7280;
        margin-bottom:.25rem;
    }

    .badge-status{
        border-radius:999px;
        padding:.25rem .6rem;
        font-size:.7rem;
        font-weight:600;
        display:inline-flex;
        align-items:center;
        gap:.25rem;
    }
    .badge-status .dot{
        width:.45rem;
        height:.45rem;
        border-radius:999px;
    }

    .badge-upcoming{
        background:#eff6ff;
        color:#1d4ed8;
    }
    .badge-upcoming .dot{ background:#3b82f6; }

    .badge-paid{
        background:#ecfdf3;
        color:#15803d;
    }
    .badge-paid .dot{ background:#22c55e; }

    .badge-late{
        background:#fef2f2;
        color:#b91c1c;
    }
    .badge-late .dot{ background:#ef4444; }

    .mini-label{
        font-size:.75rem;
        color:#6b7280;
        text-transform:uppercase;
        letter-spacing:.06em;
    }
    .mini-value{
        font-size:.9rem;
        font-weight:600;
        color:#111827;
    }

    .btn-soft-secondary{
        background:#f9fafb;
        color:#374151;
        border:1px solid #e5e7eb;
        border-radius:999px;
    }
    .btn-soft-secondary:hover{
        background:#e5e7eb;
        border-color:#d1d5db;
    }

    .btn-soft-primary{
        background:linear-gradient(135deg,#ef4444,#dc2626);
        color:#fff;
        border:none;
        border-radius:999px;
        box-shadow:0 12px 26px rgba(220,38,38,.45);
    }
    .btn-soft-primary:hover{
        filter:brightness(1.02);
        box-shadow:0 16px 34px rgba(185,28,28,.55);
    }

    @media (max-width:768px){
        .inst-header-stack{
            flex-direction:column;
            align-items:flex-start!important;
            gap:.4rem;
        }
    }
</style>

<?php
    if ($installment->status === 'paid') {
        $statusClass = 'badge-paid';
        $statusLabel = 'Paid';
    } elseif ($installment->status === 'late') {
        $statusClass = 'badge-late';
        $statusLabel = 'Late';
    } else {
        $statusClass = 'badge-upcoming';
        $statusLabel = 'Upcoming';
    }
?>

<div class="inst-edit-bg py-3 py-md-4">
    <div class="container-fluid" style="max-width:900px;">

        <div class="d-flex inst-header-stack justify-content-between align-items-center mb-3">
            <div>
                <h5 class="mb-1 fw-semibold d-flex align-items-center gap-2">
                    <i class="bi bi-pencil-square text-danger fs-5"></i>
                    <span>Installment #<?php echo e($installment->id); ?></span>
                </h5>
                <small class="text-muted">
                    Loan #<?php echo e($loan->id); ?> · User: <?php echo e($loan->user?->name ?? 'N/A'); ?>

                </small>
            </div>

            <div class="d-flex flex-wrap gap-2 align-items-center">
                <span class="badge-status <?php echo e($statusClass); ?>">
                    <span class="dot"></span>
                    <?php echo e($statusLabel); ?>

                </span>

                <a href="<?php echo e(route('admin.loans.installments', $loan)); ?>"
                   class="btn btn-sm btn-soft-secondary d-inline-flex align-items-center gap-1">
                    <i class="bi bi-arrow-left"></i>
                    <span>Back to schedule</span>
                </a>
            </div>
        </div>

        
        <div class="card inst-card mb-3">
            <div class="card-body">
                <div class="inst-section-title mb-2">Installment info</div>

                <div class="row g-3">
                    <div class="col-sm-4">
                        <div class="mini-label">Due date</div>
                        <div class="mini-value">
                            <?php echo e($installment->due_date?->format('d M Y')); ?>

                        </div>
                        <div class="text-muted small">
                            <?php echo e($installment->due_date?->diffForHumans()); ?>

                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="mini-label">Installment amount</div>
                        <div class="mini-value">
                            ৳ <?php echo e(number_format($installment->amount)); ?>

                        </div>
                        <div class="text-muted small">
                            P: <?php echo e(number_format($installment->principal_part)); ?>,
                            I: <?php echo e(number_format($installment->interest_part)); ?>

                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="mini-label">Current status</div>
                        <div class="mini-value text-capitalize">
                            <?php echo e($installment->status); ?>

                        </div>
                        <?php if($installment->paid_at): ?>
                            <div class="text-muted small">
                                <i class="bi bi-clock-history me-1"></i>
                                Paid at <?php echo e($installment->paid_at->format('d M, H:i')); ?>

                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>

        
        <form method="POST" action="<?php echo e(route('admin.installments.update', $installment)); ?>">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>

            <div class="card inst-card mb-3">
                <div class="card-body">
                    <div class="inst-section-title mb-2">Update payment</div>

                    <div class="row g-3">
                        <div class="col-md-4">
                            <label class="form-label fw-semibold">Status</label>
                            <select name="status"
                                    class="form-select <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                                <option value="upcoming" <?php echo e(old('status', $installment->status)==='upcoming' ? 'selected' : ''); ?>>Upcoming</option>
                                <option value="paid"     <?php echo e(old('status', $installment->status)==='paid'     ? 'selected' : ''); ?>>Paid</option>
                                <option value="late"     <?php echo e(old('status', $installment->status)==='late'     ? 'selected' : ''); ?>>Late</option>
                            </select>
                            <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            <div class="form-text">
                                Paid করলে নিচের payment fields পূরণ করলে future reference সহজ হবে।
                            </div>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-semibold">Paid amount (BDT)</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="bi bi-cash-stack"></i>
                                </span>
                                <input type="number"
                                       name="paid_amount"
                                       value="<?php echo e(old('paid_amount', $installment->paid_amount)); ?>"
                                       class="form-control <?php $__errorArgs = ['paid_amount'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       placeholder="e.g. <?php echo e($installment->amount); ?>">
                                <?php $__errorArgs = ['paid_amount'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="form-text">
                                Status যদি paid হয়, তাহলে এই ফিল্ডটা অবশ্যই পূরণ করো।
                            </div>
                        </div>

                        <div class="col-md-4">
                            <label class="form-label fw-semibold">Payment method</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="bi bi-credit-card-2-front"></i>
                                </span>
                                <input type="text"
                                       name="payment_method"
                                       value="<?php echo e(old('payment_method', $installment->payment_method)); ?>"
                                       class="form-control <?php $__errorArgs = ['payment_method'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       placeholder="bkash / nagad / bank">
                                <?php $__errorArgs = ['payment_method'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="form-text">
                                ইচ্ছা করলে short name লিখতে পারো (যেমন: bkash, nagad).
                            </div>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-semibold">Payment TRX ID</label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <i class="bi bi-upc-scan"></i>
                                </span>
                                <input type="text"
                                       name="payment_trx_id"
                                       value="<?php echo e(old('payment_trx_id', $installment->payment_trx_id)); ?>"
                                       class="form-control <?php $__errorArgs = ['payment_trx_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                       placeholder="SMS / bank transaction id">
                                <?php $__errorArgs = ['payment_trx_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="form-text">
                                ভবিষ্যতে verify করার সময় এই TRX ID কাজে আসবে।
                            </div>
                        </div>

                    </div>
                </div>

                <div class="card-footer bg-transparent border-0 pt-0 pb-3">
                    <div class="d-flex justify-content-end gap-2">
                        <a href="<?php echo e(route('admin.loans.installments', $loan)); ?>"
                           class="btn btn-soft-secondary d-inline-flex align-items-center gap-1">
                            <i class="bi bi-x-circle"></i>
                            <span>Cancel</span>
                        </a>
                        <button type="submit"
                                class="btn btn-soft-primary d-inline-flex align-items-center gap-2">
                            <i class="bi bi-save2"></i>
                            <span>Save changes</span>
                        </button>
                    </div>
                </div>
            </div>

        </form>

    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecareba2/loan.rkmotorsbike.top/resources/views/backend/loans/installments_edit.blade.php ENDPATH**/ ?>