<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - LinkedIn Posts</title>
    <link rel="icon" type="image/png" href="/static/favicon.png">
    <link rel="stylesheet" href="/static/tailwind.css">
    <style>
        body { background-color: #3d4848; }
        .btn-linkedin { background-color: #0A66C2; }
        .btn-linkedin:hover { background-color: #004182; }
        .card-bg { background-color: #4a5858; border-color: #5a6868; }
    </style>
</head>
<body class="text-gray-100 min-h-screen flex items-center justify-center">
    <div class="w-full max-w-md">
        <div class="card-bg rounded-xl border p-8">
            <div class="text-center mb-8">
                <img src="/static/logo.png" alt="Logo" class="h-16 w-auto mx-auto mb-4">
                <p class="text-sm text-brand-highlight font-medium mb-2">Onyva</p>
                <h1 class="text-2xl font-bold text-white mb-2">LinkedIn Workflow</h1>
                <p class="text-gray-400">Content-Workflow fur bestehende Onyva-Kunden</p>
                <p class="text-xs text-gray-500 mt-3">
                    Kein offizielles Angebot von LinkedIn. Die Anmeldung leitet dich zur LinkedIn-Autorisierung weiter.
                </p>
            </div>

            {% if error %}
            <div class="bg-red-900/50 border border-red-500 text-red-200 px-4 py-3 rounded-lg mb-6">
                {% if error == 'access_denied' %}
                    Zugriff verweigert. Bitte versuche es erneut.
                {% elif error == 'unauthorized' %}
                    Dein LinkedIn-Profil ist nicht autorisiert.
                {% else %}
                    Fehler bei der Anmeldung: {{ error }}
                {% endif %}
            </div>
            {% endif %}

            <div class="space-y-6">
                <a href="/auth/linkedin" class="w-full btn-linkedin text-white font-medium py-3 px-4 rounded-lg transition-colors flex items-center justify-center gap-3">
                    <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
                        <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/>
                    </svg>
                    Mit LinkedIn anmelden
                </a>

                <div class="relative my-4">
                    <div class="absolute inset-0 flex items-center">
                        <div class="w-full border-t border-gray-600"></div>
                    </div>
                    <div class="relative flex justify-center text-sm">
                        <span class="px-4 bg-brand-bg-light text-gray-400">oder</span>
                    </div>
                </div>

                <!-- Email/Password Login Form -->
                <form method="POST" action="/auth/login" class="space-y-4">
                    <div>
                        <input type="email" name="email" required
                               class="w-full bg-brand-bg border border-gray-600 rounded-lg px-4 py-2 text-white focus:border-brand-highlight focus:outline-none"
                               placeholder="E-Mail">
                    </div>
                    <div>
                        <input type="password" name="password" required
                               class="w-full bg-brand-bg border border-gray-600 rounded-lg px-4 py-2 text-white focus:border-brand-highlight focus:outline-none"
                               placeholder="Passwort">
                    </div>
                    <button type="submit" class="w-full bg-brand-highlight hover:bg-brand-highlight-dark text-brand-bg-dark font-medium py-3 px-4 rounded-lg transition-colors">
                        Anmelden
                    </button>
                </form>

                <p class="text-center text-gray-500 text-sm">
                    Noch kein Konto?
                    <a href="/register" class="text-brand-highlight hover:underline">Jetzt registrieren</a>
                </p>
            </div>
        </div>

        <div class="mt-6 text-center space-y-2">
            <a href="/admin/login" class="text-gray-500 hover:text-gray-300 text-sm">
                Admin-Login
            </a>
            <div class="text-xs text-gray-500">
                Betreiber: Onyva |
                <a href="/privacy-policy" class="hover:text-gray-300">Datenschutz</a> |
                <a href="mailto:team@onyva.de" class="hover:text-gray-300">team@onyva.de</a>
            </div>
        </div>
    </div>
</body>
</html>
