
<?php $__env->startSection('title', 'Update Password'); ?>
<?php $__env->startSection('sub_layout'); ?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" />

<style>
    :root { --primary:#e53935; --bg:#f5f5f5; --soft:#ffe5e5; --border:#f0f0f0; }
    * { box-sizing:border-box;margin:0;padding:0; }
    body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:var(--bg); }

    .page { max-width:900px;margin:18px auto 30px;padding:0 12px; }
    .card { background:#fff;border-radius:18px;padding:18px 18px 20px;
            box-shadow:0 6px 16px rgba(0,0,0,.06);margin-bottom:14px; }

    .form-header{ display:flex;align-items:center;gap:10px;margin-bottom:14px; }
    .form-icon{
        height:36px;width:36px;border-radius:50%;
        background:var(--soft);
        display:flex;align-items:center;justify-content:center;
        color:var(--primary);font-size:17px;
    }
    .form-title{ font-size:18px;font-weight:700;color:#333; }
    .form-sub{ font-size:13px;color:#777; }

    .form-group{ margin-bottom:16px; }
    .form-label{ font-size:13px;font-weight:600;margin-bottom:6px;display:block;color:#444; }
    .input-control{
        width:100%;padding:9px 10px;border-radius:10px;
        border:1px solid var(--border);font-size:14px;
        outline:none;transition:.15s border;
        background:#fafafa;
    }
    .input-control:focus{ border-color:var(--primary);background:#fff; }

    .status-text{ font-size:12px;margin-top:4px;display:flex;align-items:center;gap:4px; }

    .btn-row{ display:flex;flex-wrap:wrap;gap:10px;justify-content:flex-end;margin-top:4px; }
    .btn{
        border-radius:999px;padding:9px 18px;font-size:14px;
        font-weight:600;border:1px solid transparent;
        display:inline-flex;align-items:center;gap:6px;
        cursor:pointer;text-decoration:none;transition:.15s all;white-space:nowrap;
    }
    .btn-primary{ background:var(--primary);color:#fff;border-color:var(--primary); }
    .btn-primary:hover{ filter:brightness(.95); }
    .btn-outline{ background:#fff;color:var(--primary);border-color:var(--primary); }
    .btn-outline:hover{ background:var(--soft); }

    .alert{ padding:8px 10px;border-radius:10px;font-size:13px;margin-bottom:10px; }
    .alert-success{ background:#e6f7e9;color:#1b7a36; }
    .alert-error{ background:#ffeaea;color:#b3261e; }

    @media (max-width:480px){ .btn-row{ justify-content:center; } }
</style>

<div class="page">
    <div class="card">
        <div class="form-header">
            <div class="form-icon">
                <i class="fa-solid fa-lock"></i>
            </div>
            <div>
                <div class="form-title">Update Password</div>
            </div>
        </div>

        <?php if(session('success')): ?>
            <div class="alert alert-success"><?php echo e(session('success')); ?></div>
        <?php endif; ?>

        <?php if($errors->any()): ?>
            <div class="alert alert-error">
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $err): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div><?php echo e($err); ?></div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        <?php endif; ?>

        <form action="<?php echo e(route('profile.password.update')); ?>" method="POST" id="passwordForm">
            <?php echo csrf_field(); ?>

            <div class="form-group">
                <label class="form-label" for="old_password">Old Password</label>
                <input type="password" name="old_password" id="old_password"
                       class="input-control"
                       placeholder="পুরানো পাসওয়ার্ড দিন">
                <span id="old-pass-status" class="status-text"></span>
            </div>

            <div class="form-group">
                <label class="form-label" for="password">New Password</label>
                <input type="password" name="password" id="password"
                       class="input-control"
                       placeholder="নতুন পাসওয়ার্ড দিন">
            </div>

            <div class="form-group">
                <label class="form-label" for="password_confirmation">Confirm Password</label>
                <input type="password" name="password_confirmation" id="password_confirmation"
                       class="input-control"
                       placeholder="নতুন পাসওয়ার্ড আবার লিখুন">
            </div>

            <div class="btn-row">
                <a href="<?php echo e(route('profile')); ?>" class="btn btn-outline">
                    <i class="fa-solid fa-arrow-left"></i> Back
                </a>
                <button type="submit" class="btn btn-primary">
                    <i class="fa-regular fa-circle-check"></i> Save Password
                </button>
            </div>
        </form>
    </div>
</div>

<script>
    const inputOld = document.getElementById('old_password');
    const statusEl = document.getElementById('old-pass-status');

    inputOld.addEventListener('input', function () {
        const val = this.value;

        if (!val) {
            statusEl.textContent = '';
            return;
        }

        fetch("<?php echo e(route('profile.password.check')); ?>", {
            method: 'POST',
            headers: {
                'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>',
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ old_password: val })
        }).then(res => res.json())
          .then(data => {
              if (data.valid) {
                  statusEl.innerHTML = '<i class="fa-solid fa-circle-check" style="color:green;"></i> পুরাতন পাসওয়ার্ড সঠিক';
                  statusEl.style.color = 'green';
              } else {
                  statusEl.innerHTML = '<i class="fa-solid fa-circle-xmark" style="color:#b3261e;"></i> পুরাতন পাসওয়ার্ড ভুল';
                  statusEl.style.color = '#b3261e';
              }
          }).catch(() => {
              statusEl.textContent = '';
          });
    });
</script>
<?php $__env->stopSection(); ?>

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