@model LittleShop.DTOs.UpdateUserDto

@{
    ViewData["Title"] = "Edit User";
    var userId = ViewData["UserId"] as Guid?;
}

<div class="row mb-4">
    <div class="col">
        <h1><i class="fas fa-user-edit"></i> Edit User</h1>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-body">
                <form method="post" asp-area="Admin" asp-controller="Users" asp-action="Edit" asp-route-id="@userId">
                    @Html.AntiForgeryToken()
                    
                    @if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
                    {
                        <div class="alert alert-danger" role="alert">
                            @foreach (var error in ViewData.ModelState[""].Errors)
                            {
                                <div>@error.ErrorMessage</div>
                            }
                        </div>
                    }
                    
                    <div class="mb-3">
                        <label for="Username" class="form-label">Username</label>
                        <input name="Username" id="Username" class="form-control" value="@Model?.Username" required />
                        <div class="form-text">Must be unique across all users</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="Password" class="form-label">New Password</label>
                        <input name="Password" id="Password" type="password" class="form-control" />
                        <div class="form-text">Leave blank to keep current password. Minimum 3 characters if changing.</div>
                    </div>
                    
                    <div class="mb-3 form-check">
                        <input name="IsActive" id="IsActive" type="checkbox" class="form-check-input" value="true" @(Model?.IsActive == true ? "checked" : "") />
                        <input name="IsActive" type="hidden" value="false" />
                        <label for="IsActive" class="form-check-label">
                            User is active (can log in)
                        </label>
                    </div>
                    
                    <div class="d-flex justify-content-between">
                        <a href="@Url.Action("Index")" class="btn btn-secondary">
                            <i class="fas fa-arrow-left"></i> Back to Users
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> Update User
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-info-circle"></i> Edit Information</h5>
            </div>
            <div class="card-body">
                <ul class="list-unstyled">
                    <li><strong>Username:</strong> Can be changed if unique</li>
                    <li><strong>Password:</strong> Optional - leave blank to keep current</li>
                    <li><strong>Status:</strong> Inactive users cannot log in</li>
                </ul>
                <div class="alert alert-warning mt-3">
                    <i class="fas fa-exclamation-triangle"></i> 
                    <strong>Warning:</strong> Deactivating your own account will lock you out.
                </div>
            </div>
        </div>
    </div>
</div>