<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>License Key erstellen</title>
    <link rel="stylesheet" href="/static/style.css">
    <link rel="icon" href="/static/logo.png" type="image/png">
    <style>
        body {
            background-image: url('/static/background.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        .content {
            background: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            width: 80%;
            max-width: 800px;
            max-height: 90vh;
            overflow-y: auto;
            text-align: center;
        }
        .content h2 {
            text-align: center;
        }
        .content .license-key {
            display: flex;
            align-items: center;
            margin: 20px 0;
        }
        .content .license-key input {
            width: 300px;
            padding: 10px;
            margin-right: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        .content .license-key button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            border-radius: 4px;
        }
        .content .license-key button:hover {
            background-color: #0056b3;
        }
        .content .message {
            display: none;
            color: green;
            margin-top: 10px;
        }
        .content form {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .content form label {
            margin-top: 10px;
            width: 100%;
            text-align: left;
        }
        .content form input,
        .content form textarea,
        .content form select {
            width: 100%;
            padding: 10px;
            margin-top: 5px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .content form button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            border-radius: 4px;
            margin-top: 20px;
        }
        .content form button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    {% include "top_bar.html" %}
    <div class="content">
        <h2>License Key erstellen</h2>
        {% if license_key %}
        <div class="license-key">
            <input type="text" id="licenseKey" value="{{ license_key }}" readonly>
            <button onclick="copyToClipboard()">Kopieren</button>
        </div>
        <div class="message" id="message">
            <img src="/static/green_check.png" alt="Check" style="width: 20px; vertical-align: middle;">
            License key wurde kopiert
        </div>
        {% elif error %}
        <p>{{ error }}</p>
        {% endif %}
        <form action="{{ url_for('create_license_key') }}" method="post">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <button type="submit">Neuen License Key generieren</button>
        </form>
        <a href="/license_keys" class="black-button">Zurück</a>
    </div>
    <script>
        function copyToClipboard() {
            var copyText = document.getElementById("licenseKey");
            copyText.select();
            copyText.setSelectionRange(0, 99999);
            document.execCommand("copy");
            var message = document.getElementById("message");
            message.style.display = "block";
            setTimeout(function() {
                message.style.display = "none";
            }, 2000);
        }
    </script>
</body>
</html>
