@extends('layouts.app')

@section('title', 'My Profile')

@section('content')
<h2 class="page-title">My Profile</h2>

<div class="row">
    <div class="col-xl-6 col-lg-8 mx-auto">
        <div class="card border-0 shadow-sm">
            <div class="card-header bg-white border-0 pt-4 pb-0">
                <h5 class="fw-bold mb-0 text-primary">Account Settings</h5>
            </div>
            <div class="card-body p-4">
                <form action="{{ route('profile.update') }}" method="POST">
                    @csrf
                    @method('PUT')

                    <h6 class="fw-bold text-muted mb-4 text-uppercase" style="font-size: 12px; letter-spacing: 1px;">Personal Information</h6>

                    <div class="form-floating mb-4">
                        <input type="text" id="name" name="name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name', $user->name) }}" placeholder="Full Name" required>
                        <label for="name">Full Name <span class="text-danger">*</span></label>
                        @error('name') <div class="text-danger small mt-1">{{ $message }}</div> @enderror
                    </div>

                    <div class="form-floating mb-4">
                        <input type="email" id="email" name="email" class="form-control @error('email') is-invalid @enderror" value="{{ old('email', $user->email) }}" placeholder="Email Address" required>
                        <label for="email">Email Address <span class="text-danger">*</span></label>
                        @error('email') <div class="text-danger small mt-1">{{ $message }}</div> @enderror
                    </div>

                    <hr class="my-4 border-light">

                    <h6 class="fw-bold text-muted mb-4 text-uppercase" style="font-size: 12px; letter-spacing: 1px;">Change Password (Optional)</h6>

                    <div class="form-floating mb-4">
                        <input type="password" id="current_password" name="current_password" class="form-control @error('current_password') is-invalid @enderror" placeholder="Current Password">
                        <label for="current_password">Current Password</label>
                        @error('current_password') <div class="text-danger small mt-1">{{ $message }}</div> @enderror
                    </div>

                    <div class="row g-4 mb-4">
                        <div class="col-md-6">
                            <div class="form-floating">
                                <input type="password" id="password" name="password" class="form-control @error('password') is-invalid @enderror" placeholder="New Password">
                                <label for="password">New Password</label>
                            </div>
                            @error('password') <div class="text-danger small mt-1">{{ $message }}</div> @enderror
                        </div>
                        <div class="col-md-6">
                            <div class="form-floating">
                                <input type="password" id="password_confirmation" name="password_confirmation" class="form-control" placeholder="Confirm New Password">
                                <label for="password_confirmation">Confirm New Password</label>
                            </div>
                        </div>
                    </div>

                    <div class="d-flex justify-content-end mt-5 pt-3 border-top">
                        <button type="submit" class="btn btn-primary px-5 fw-bold"><i class="fas fa-save me-2"></i> Update Profile</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
