<?php
// pages/login.php
if (isLoggedIn()) {
    redirect('index.php?page=dashboard');
}
?>
<div class="login-page">
    <div class="login-form">
        <h2 style="text-align: center; margin-bottom: 2rem;">WCS Admin Login</h2>
        <?php if (isset($_GET['error'])): ?>
            <div class="alert alert-danger">
                <?php echo htmlspecialchars($_GET['error']); ?>
            </div>
        <?php endif; ?>
        
        <form action="api/auth.php" method="POST">
            <div class="form-group">
                <label for="username">Username or Email</label>
                <input type="text" id="username" name="username" class="form-control" required placeholder="Enter username or email">
            </div>
            
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" id="password" name="password" class="form-control" required placeholder="Enter password">
            </div>
            
            <button type="submit" class="btn btn-block">Login</button>
        </form>
    </div>
</div>
