package templates

templ AdminProfile(user User) {
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Profile Settings - Bookhoard</title>
        <script src="/static/htmx.min.js"></script>
        <script src="/static/toast.js"></script>
        <link href="/static/style.css" rel="stylesheet">
    </head>
    <body class="theme-tokyo-night">
        <nav class="border-b" style="border-color: var(--border); background-color: var(--bg-secondary)">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <div class="flex justify-between items-center h-16">
                    <div class="flex items-center">
                        <h1 class="text-xl font-bold" style="color: var(--text-primary)">📚 Bookhoard</h1>
                    </div>
                    <div class="flex items-center space-x-4">
                        <a href="/" class="px-3 py-2 text-sm hover:opacity-80" style="color: var(--text-secondary)">Library</a>
                        <span style="color: var(--text-secondary)">Welcome, { user.Username }!</span>
                        <button onclick="logout()" class="btn-primary px-4 py-2 rounded text-sm">
                            Logout
                        </button>
                    </div>
                </div>
            </div>
        </nav>

        <div class="flex min-h-screen" style="background-color: var(--bg-primary)">
            <aside class="w-64 border-r" style="background-color: var(--bg-secondary); border-color: var(--border)">
                <div class="p-6">
                    <h2 class="text-lg font-semibold mb-6" style="color: var(--text-primary)">Admin Panel</h2>
                    <nav class="space-y-2">
                        <a href="/admin" class="block px-4 py-2 rounded-lg hover:opacity-80" style="color: var(--text-primary)">
                            🏠 Dashboard
                        </a>
                        <a href="/admin/profile" class="block px-4 py-2 rounded-lg bg-accent text-bg-primary" style="color: var(--text-primary)">
                            👤 Profile Settings
                        </a>
                        <a href="/admin/library" class="block px-4 py-2 rounded-lg hover:opacity-80" style="color: var(--text-primary)">
                            📚 Library Management
                        </a>
                    </nav>
                </div>
            </aside>

            <main class="flex-1 p-8">
                <div class="max-w-4xl">
                    <div class="mb-8">
                        <div class="flex items-center space-x-4 mb-4">
                            <a href="/admin" class="btn-secondary px-4 py-2 rounded-lg font-medium">
                                ← Back to Dashboard
                            </a>
                        </div>
                        <h1 class="text-3xl font-bold mb-2" style="color: var(--text-primary)">Profile Settings</h1>
                        <p style="color: var(--text-secondary)">Manage your account information and preferences</p>
                    </div>

                    <div class="space-y-8">
                        <div class="card p-6 rounded-lg border" style="background-color: var(--bg-secondary); border-color: var(--border)">
                            <h3 class="text-xl font-semibold mb-6" style="color: var(--text-primary)">Account Information</h3>

                            <div class="mb-6">
                                <h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Username</h4>
                                <form hx-put="/api/auth/username" hx-target="#username-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
                                    <input type="text" name="username" value={ user.Username } class="flex-1 px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
                                    <button type="submit" class="btn-primary px-4 py-2 rounded">Update</button>
                                </form>
                                <div id="username-result" class="mt-2"></div>
                            </div>

                            <div class="mb-6">
                                <h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Email Address</h4>
                                <form hx-put="/api/auth/email" hx-target="#email-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
                                    <input type="email" name="email" value={ user.Email } class="flex-1 px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
                                    <button type="submit" class="btn-primary px-4 py-2 rounded">Update</button>
                                </form>
                                <div id="email-result" class="mt-2"></div>
                            </div>

                            <div>
                                <h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Change Password</h4>
                                <form hx-put="/api/auth/password" hx-target="#password-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="space-y-4 max-w-md">
                                    <div>
                                        <label class="block text-sm font-medium mb-1" style="color: var(--text-secondary)">Current Password</label>
                                        <input type="password" name="current_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>
                                    <div>
                                        <label class="block text-sm font-medium mb-1" style="color: var(--text-secondary)">New Password</label>
                                        <input type="password" name="new_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 minlength="6">
                                    </div>
                                    <div>
                                        <label class="block text-sm font-medium mb-1" style="color: var(--text-secondary)">Confirm New Password</label>
                                        <input type="password" name="confirm_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 minlength="6">
                                    </div>
                                    <button type="submit" class="btn-primary px-4 py-2 rounded">Update Password</button>
                                </form>
                                <div id="password-result" class="mt-2"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>
        </div>

        <script>
            function logout() {
                localStorage.removeItem('token');
                localStorage.removeItem('user');
                window.location.href = '/';
            }

            document.addEventListener('DOMContentLoaded', function() {
                loadTheme();
            });
        </script>
    </body>
    </html>
}