

<?php $__env->startSection('title', $title ?? 'Profile'); ?>

<?php $__env->startSection('content'); ?>
    <div class="container-header">
        <h2 class="title"><?php echo e($title ?? 'Profile'); ?></h2>
    </div>

    <div class="card mp-20 profile-card">
        <div class="profile-image-wrap">
            <img id="profile-image-preview" src="<?php echo e($user->image ? asset($user->image) : 'https://ui-avatars.com/api/?name=' . urlencode($user->fname . ' ' . $user->lname) . '&background=random'); ?>" alt="Profile">
        </div>
        <p class="profile-name"><?php echo e($user->fname); ?> <?php echo e($user->lname); ?></p>
        <p class="profile-email"><?php echo e($user->email); ?></p>
        <form action="<?php echo e(route('user.profile.update-image')); ?>" method="POST" enctype="multipart/form-data" class="profile-image-form">
            <?php echo csrf_field(); ?>
            <input type="file" name="image" id="profile-image-input" accept="image/*" style="display: none;">
            <button type="button" class="btn btn-primary" id="update-image-btn"><i class="ti ti-photo-up"></i> Update photo</button>
        </form>
    </div>

    <div class="card mp-20">
        <h2 class="title">Account details</h2>
        <form action="<?php echo e(route('user.profile.update')); ?>" method="POST">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>
            <div class="form-grid">
                <div class="form-group">
                    <label class="form-label">First name</label>
                    <input type="text" name="fname" class="form-control" value="<?php echo e(old('fname', $user->fname)); ?>" placeholder="First name">
                </div>
                <div class="form-group">
                    <label class="form-label">Last name</label>
                    <input type="text" name="lname" class="form-control" value="<?php echo e(old('lname', $user->lname)); ?>" placeholder="Last name">
                </div>
            </div>
            <div class="form-grid">
                <div class="form-group">
                    <label class="form-label">Email <span class="required">*</span></label>
                    <input type="email" name="email" class="form-control" value="<?php echo e(old('email', $user->email)); ?>" required placeholder="Email">
                </div>
                <div class="form-group">
                    <label class="form-label">New password</label>
                    <input type="password" name="password" class="form-control" placeholder="Leave blank to keep current">
                </div>
            </div>
            <button type="submit" class="btn btn-primary"><i class="ti ti-device-floppy"></i> Update</button>
        </form>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    var updateBtn = document.getElementById('update-image-btn');
    var fileInput = document.getElementById('profile-image-input');
    var preview = document.getElementById('profile-image-preview');
    var form = document.querySelector('.profile-image-form');

    if (updateBtn && fileInput) {
        updateBtn.addEventListener('click', function() { fileInput.click(); });
        fileInput.addEventListener('change', function() {
            if (fileInput.files.length) form.submit();
        });
    }
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('frontend.layout.dash', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\HP\Desktop\nbverify\mine\resources\views/frontend/user/profile.blade.php ENDPATH**/ ?>