@page
@model QuantEngine.Web.Pages.Admin.Users.CreateModel
@{
    ViewData["Title"] = "새 사용자 추가";
}

<div class="page-header d-print-none">
    <div class="row align-items-center">
        <div class="col">
            <h2 class="page-title">새 사용자 추가</h2>
        </div>
    </div>
</div>

<div class="page-body">
    <div class="row">
        <div class="col-md-8">
            <div class="card">
                <div class="card-body">
                    @if (!ViewData.ModelState.IsValid)
                    {
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            <h4 class="alert-title">검증 오류</h4>
                            @foreach (var modelState in ViewData.ModelState.Values)
                            {
                                @foreach (var error in modelState.Errors)
                                {
                                    <div>@error.ErrorMessage</div>
                                }
                            }
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    }

                    <form method="post" class="form-vertical">
                        @Html.AntiForgeryToken()

                        <div class="mb-3">
                            <label for="username" class="form-label">사용자명 <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" id="username" asp-for="Input.Username" placeholder="admin_user" required />
                            <small class="form-text text-muted">영문, 숫자, 언더스코어만 사용 가능</small>
                        </div>

                        <div class="mb-3">
                            <label for="password" class="form-label">비밀번호 <span class="text-danger">*</span></label>
                            <input type="password" class="form-control" id="password" asp-for="Input.Password" placeholder="최소 8자" required />
                            <small class="form-text text-muted">최소 8자 이상, 대문자/숫자/특수문자 권장</small>
                        </div>

                        <div class="mb-3">
                            <label for="role" class="form-label">역할 <span class="text-danger">*</span></label>
                            <select class="form-select" id="role" asp-for="Input.Role">
                                <option value="Admin">관리자 (Admin)</option>
                                <option value="User">사용자 (User)</option>
                                <option value="Viewer">조회전용 (Viewer)</option>
                            </select>
                        </div>

                        <div class="mb-3">
                            <div class="form-check">
                                <input type="checkbox" class="form-check-input" id="isActive" asp-for="Input.IsActive" checked />
                                <label class="form-check-label" for="isActive">활성화</label>
                            </div>
                        </div>

                        <div class="form-footer">
                            <button type="submit" class="btn btn-primary">추가</button>
                            <a href="/Admin/Users" class="btn btn-secondary">취소</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
