<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>租房系统登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            background-color: white;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            width: 360px;
        }
        h2 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            color: #666;
            font-weight: bold;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 14px;
        }
        .role-group {
            display: flex;
            justify-content: space-around;
            margin: 10px 0;
        }
        .role-group label {
            display: inline;
            font-weight: normal;
        }
        button {
            width: 100%;
            padding: 12px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #45a049;
        }
        .error {
            background-color: #ffebee;
            color: #c62828;
            padding: 10px;
            border-radius: 4px;
            margin-bottom: 20px;
            text-align: center;
        }
        .register-link {
            text-align: center;
            margin-top: 20px;
            color: #666;
        }
        .register-link a {
            color: #4CAF50;
            text-decoration: none;
        }
        .register-link a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>租房系统登录</h2>
        
        <%-- 显示错误信息 --%>
        <% 
            String error = (String)request.getAttribute("error");
            if(error != null) {
        %>
            <div class="error"><%= error %></div>
        <%
            }
        %>
        <%-- 显示成功信息（如注册成功） --%>
<% 
    String message = (String)request.getAttribute("message");
    if(message != null) {
%>
    <div class="message" style="background-color:#e8f5e9; color:#2e7d32; padding:10px; border-radius:4px; margin-bottom:20px; text-align:center;">
        <%= message %>
    </div>
<%
    }
%>
        
        <form action="${pageContext.request.contextPath}/user/login" method="post">
            <div class="form-group">
                <label>用户名：</label>
                <input type="text" name="username" required>
            </div>
            
            <div class="form-group">
                <label>密码：</label>
                <input type="password" name="password" required>
            </div>
            
            <div class="form-group">
                <label>登录角色：</label>
                <div class="role-group">
                    <label>
                        <input type="radio" name="roleType" value="0" checked> 租客
                    </label>
                    <label>
                        <input type="radio" name="roleType" value="1"> 房东
                    </label>
                    <label>
                        <input type="radio" name="roleType" value="2"> 管理员
                    </label>
                </div>
            </div>
            
            <button type="submit">登录</button>
        </form>
        
        <div class="register-link">
            还没有账号？ <a href="${pageContext.request.contextPath}/user/register">立即注册</a>
        </div>
    </div>
</body>
</html>