<?php
// Start a session just in case we need it later
session_start();

// Get message parameters from the URL
// NOTE: This logic must be at the top of the file before any HTML is sent.
$message = $_GET['message'] ?? '';
$message_type = $_GET['message_type'] ?? 'info';
$display_message = !empty($message);

if ($display_message) {
    // Determine colors for Tailwind CSS based on message type
    $color_bg = ($message_type === 'error') ? 'bg-red-800' : 'bg-green-800';
    $color_text = ($message_type === 'error') ? 'text-red-100' : 'text-green-100';
    $icon = ($message_type === 'error') ? '🛑' : '✅';
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Login - Confluence King</title>
    <?php require_once 'meta.php'; ?>
</head>
<body class="bg-gray-900 text-white min-h-screen flex items-center justify-center">
    <div class="bg-gray-800 p-8 rounded-lg shadow-xl w-full max-w-md">
        <h2 class="text-2xl font-bold mb-6 text-center">Client Login</h2>
        
        <?php if ($display_message): ?>
            <div class="p-3 rounded-md mb-4 text-sm font-medium <?= $color_bg ?> <?= $color_text ?>">
                <?= $icon ?> <?= htmlspecialchars(urldecode($message)) ?>
            </div>
        <?php endif; ?>
        <form action="login_process.php" method="POST">
            <div class="mb-4">
                <label for="email" class="block text-sm font-medium text-gray-300 mb-1">Email Address</label>
                <input type="email" id="email" name="email" required
                       class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md focus:outline-none focus:ring-blue-500 text-white"
                       placeholder="you@example.com">
            </div>
            <div class="mb-6">
                <label for="password" class="block text-sm font-medium text-gray-300 mb-1">Password</label>
                <input type="password" id="password" name="password" required
                       class="w-full px-3 py-2 bg-gray-700 border border-gray-600 rounded-md focus:outline-none focus:ring-blue-500 text-white"
                       placeholder="Enter your password">
            </div>
            <button type="submit"
                    class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 rounded-md font-medium">
                Log In
            </button>
        </form>
        <p class="text-center text-sm text-gray-400 mt-4">
            Don't have an account? <a href="register.php" class="text-blue-400 hover:underline">Sign up here</a>
        </p>
    </div>
</body>
</html>