package templates

templ Login(sessionExpired bool) {
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Login</title>
        <script src="/static/htmx.min.js"></script>
        <script src="/static/toast.js"></script>
        <script src="/static/theme.js"></script>
        <link href="/static/style.css" rel="stylesheet">
    </head>
    <body class="theme-tokyo-night min-h-screen">
        <div class="container mx-auto px-4 py-8 max-w-md">
            <div class="flex justify-between items-center mb-8">
                <h1 class="text-3xl font-bold">Login to Bookhoard</h1>
                <select id="theme-select" class="px-3 py-2 border rounded" style="background-color: var(--bg-secondary); color: var(--text-primary); border-color: var(--border)" onchange="changeTheme()">
                    <option value="tokyo-night">Tokyo Night</option>
                    <option value="dracula">Dracula</option>
                    <option value="nord">Nord</option>
                    <option value="solarized-dark">Solarized Dark</option>
                    <option value="monokai">Monokai</option>
                    <option value="one-dark-pro">One Dark Pro</option>
                    <option value="material-dark">Material Dark</option>
                    <option value="catppuccin-mocha">Catppuccin Mocha</option>
                    <option value="catppuccin-macchiato">Catppuccin Macchiato</option>
                    <option value="catppuccin-frappe">Catppuccin Frappé</option>
                    <option value="catppuccin-latte">Catppuccin Latte</option>
                </select>
            </div>

            if sessionExpired {
                <div class="mb-4 p-3 rounded-lg border" style="background-color: var(--bg-secondary); border-color: var(--accent);">
                    <p style="color: var(--text-primary);">
                        Your session has expired. Please log in again to continue.
                    </p>
                </div>
            }

            <form hx-post="/api/auth/login" hx-target="#result" hx-swap="innerHTML" class="card p-6 rounded-lg shadow-md border">
                <div class="mb-4">
                    <label class="block mb-2" style="color: var(--text-secondary)">Email or Username</label>
                    <input type="text" name="login" class="w-full px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
                </div>
                <div class="mb-4">
                    <label class="block mb-2" style="color: var(--text-secondary)">Password</label>
                    <input type="password" name="password" class="w-full px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
                </div>
                <button type="submit" class="btn-primary w-full py-2 rounded">
                    Sign In
                </button>
            </form>
            
            <div id="result" class="mt-4 text-center"></div>
            
            <p class="text-center mt-4">
                <a href="/register" class="text-blue-500 hover:underline">Don't have an account? Sign Up</a>
            </p>
        </div>
    </body>
    </html>
}