<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs"
    Inherits="UserAuthApp.Web.Register" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Register - User Authentication</title>
    <style>
        /* ── Page Styling ── */
        body {
            font-family: 'Segoe UI', Arial, sans-serif;
            background-color: #f0f2f5;
            margin: 0;
            padding: 20px;
        }
        .container {
            width: 420px;
            margin: 40px auto;
            padding: 35px;
            background: #ffffff;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        }
        h2 {
            text-align: center;
            color: #1a1a2e;
            margin-bottom: 25px;
        }
        .form-group {
            margin-bottom: 18px;
        }
        .form-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 600;
            color: #444;
            font-size: 14px;
        }
        .form-group input[type="text"],
        .form-group input[type="password"] {
            width: 100%;
            padding: 11px 14px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            box-sizing: border-box;
            transition: border-color 0.3s;
        }
        .form-group input:focus {
            border-color: #4CAF50;
            outline: none;
        }
        .btn-register {
            width: 100%;
            padding: 13px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            margin-top: 10px;
        }
        .btn-register:hover {
            background-color: #43a047;
        }
        .message {
            text-align: center;
            margin-top: 15px;
            padding: 12px;
            border-radius: 6px;
            font-size: 14px;
        }
        .success { background-color: #d4edda; color: #155724; }
        .error { background-color: #f8d7da; color: #721c24; }
        .link-section {
            text-align: center;
            margin-top: 20px;
            font-size: 14px;
        }
        .link-section a {
            color: #4CAF50;
            text-decoration: none;
            font-weight: 600;
        }
        .validation-error {
            color: red;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <form id="frmRegister" runat="server">
        <div class="container">
            <h2>Create Your Account</h2>

            <!-- First Name -->
            <div class="form-group">
                <label>First Name</label>
                <asp:TextBox ID="txtFirstName" runat="server" placeholder="Enter your first name" />
                <asp:RequiredFieldValidator ID="rfvFirstName" runat="server"
                    ControlToValidate="txtFirstName"
                    ErrorMessage="* First name is required"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Last Name -->
            <div class="form-group">
                <label>Last Name</label>
                <asp:TextBox ID="txtLastName" runat="server" placeholder="Enter your last name" />
                <asp:RequiredFieldValidator ID="rfvLastName" runat="server"
                    ControlToValidate="txtLastName"
                    ErrorMessage="* Last name is required"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Email -->
            <div class="form-group">
                <label>Email Address</label>
                <asp:TextBox ID="txtEmail" runat="server" TextMode="Email"
                    placeholder="you@example.com" />
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server"
                    ControlToValidate="txtEmail"
                    ErrorMessage="* Email is required"
                    CssClass="validation-error"
                    Display="Dynamic" />
                <asp:RegularExpressionValidator ID="revEmail" runat="server"
                    ControlToValidate="txtEmail"
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                    ErrorMessage="* Invalid email format"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Username -->
            <div class="form-group">
                <label>Username</label>
                <asp:TextBox ID="txtUsername" runat="server" placeholder="Choose a username" />
                <asp:RequiredFieldValidator ID="rfvUsername" runat="server"
                    ControlToValidate="txtUsername"
                    ErrorMessage="* Username is required"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Password -->
            <div class="form-group">
                <label>Password</label>
                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"
                    placeholder="Minimum 6 characters" />
                <asp:RequiredFieldValidator ID="rfvPassword" runat="server"
                    ControlToValidate="txtPassword"
                    ErrorMessage="* Password is required"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Confirm Password -->
            <div class="form-group">
                <label>Confirm Password</label>
                <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password"
                    placeholder="Re-enter your password" />
                <asp:CompareValidator ID="cvPassword" runat="server"
                    ControlToValidate="txtConfirmPassword"
                    ControlToCompare="txtPassword"
                    ErrorMessage="* Passwords do not match"
                    CssClass="validation-error"
                    Display="Dynamic" />
            </div>

            <!-- Register Button -->
            <asp:Button ID="btnRegister" runat="server" Text="Create Account"
                CssClass="btn-register" OnClick="btnRegister_Click" />

            <!-- Message Label (shows success/error messages) -->
            <asp:Label ID="lblMessage" runat="server" CssClass="message" />

            <!-- Link to Login page -->
            <div class="link-section">
                Already have an account? <a href="Login.aspx">Sign in here</a>
            </div>
        </div>
    </form>
</body>
</html>
