@model Eshop.Web.ViewModels.ProfileViewModel
@{
    ViewData["Title"] = "My Profile";
}

<div class="row justify-content-center mt-5">
    <div class="col-md-6">
        @if (TempData["SuccessMessage"] != null)
        {
            <div class="alert alert-success">@TempData["SuccessMessage"]</div>
        }

        <div class="card shadow-sm mb-4">
            <div class="card-body p-4">
                <h1 class="card-title text-center mb-4">My Profile</h1>

                <form asp-action="Profile">
                    <div asp-validation-summary="ModelOnly" class="text-danger"></div>

                    <div class="mb-3">
                        <label asp-for="UserName" class="form-label"></label>
                        <input asp-for="UserName" class="form-control" />
                        <span asp-validation-for="UserName" class="text-danger small"></span>
                    </div>

                    <div class="mb-3">
                        <label asp-for="Email" class="form-label"></label>
                        <input asp-for="Email" class="form-control" />
                        <span asp-validation-for="Email" class="text-danger small"></span>
                    </div>

                    <hr />
                    <p class="text-muted small">Change Password (optional)</p>

                    <div class="mb-3">
                        <label asp-for="CurrentPassword" class="form-label"></label>
                        <input asp-for="CurrentPassword" class="form-control" />
                        <span asp-validation-for="CurrentPassword" class="text-danger small"></span>
                    </div>

                    <div class="mb-3">
                        <label asp-for="NewPassword" class="form-label"></label>
                        <input asp-for="NewPassword" class="form-control" />
                        <span asp-validation-for="NewPassword" class="text-danger small"></span>
                    </div>

                    <div class="mb-3">
                        <label asp-for="ConfirmPassword" class="form-label"></label>
                        <input asp-for="ConfirmPassword" class="form-control" />
                        <span asp-validation-for="ConfirmPassword" class="text-danger small"></span>
                    </div>

                    <div class="d-grid mt-4">
                        <button type="submit" class="btn btn-primary">Update Profile</button>
                    </div>
                </form>
            </div>
        </div>

        <div class="card border-danger shadow-sm">
            <div class="card-body p-4">
                <h3 class="text-danger">Privacy & Data</h3>
                <p class="text-muted small">Manage your personal data and account status.</p>
                
                <div class="d-grid gap-2">
                    <a asp-action="DownloadData" class="btn btn-outline-info">Download My Data (JSON)</a>
                    
                    <form asp-action="DeleteAccount" method="post" onsubmit="return confirm('Are you absolutely sure you want to delete your account? This action cannot be undone.');">
                        @Html.AntiForgeryToken()
                        <div class="d-grid">
                            <button type="submit" class="btn btn-outline-danger">Delete My Account</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section Scripts {
    @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
