<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}AstraOS{% endblock %}</title>
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='media/AstraOS_Logo.ico') }}">

    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
    {% block head %}{% endblock %}

    <style>
        body {
            background: radial-gradient(circle at top, #1b1b26, #0a0a0f 70%);
            overflow-x: hidden;
            min-height: 100vh;
        }
        .custom-checkbox-label {
            display: flex;
            align-items: center;
            cursor: pointer;
            user-select: none;
        }
        .custom-checkbox-label input[type="checkbox"] {
            display: none;
        }
        .custom-checkbox-box {
            width: 20px;
            height: 20px;
            border: 2px solid #4a5568;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.2s, border-color 0.2s;
            margin-right: 0.75rem;
        }
        .custom-checkbox-box svg {
            width: 14px;
            height: 14px;
            color: white;
            transform: scale(0);
            transition: transform 0.2s ease-in-out;
        }
        .custom-checkbox-label input[type="checkbox"]:checked + .custom-checkbox-box {
            background-color: #8b5cf6;
            border-color: #8b5cf6;
        }
        .custom-checkbox-label.maintenance input[type="checkbox"]:checked + .custom-checkbox-box {
            background-color: #ca8a04;
            border-color: #ca8a04;
        }
        .custom-checkbox-label input[type="checkbox"]:checked + .custom-checkbox-box svg {
            transform: scale(1);
        }
        footer {
            text-align: center;
            padding: 1rem;
            font-size: 0.875rem;
            color: #888;
            background: rgba(0,0,0,0.3);
        }
        #startup {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            width: 100vw !important;
            height: 100vh !important;
            margin: 0 !important;
            padding: 0 !important;
            background: black !important;
            z-index: 9999 !important;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        #star {
            width: 64px;
            height: 64px;
            position: relative;
        }
        #star .blur {
            position: absolute;
            inset: 0;
            border-radius: 50%;
            filter: blur(12px);
            opacity: 0.7;
            background: rgba(192,132,252,0.7);
        }
        #startup p {
            margin-top: 1rem;
            font-size: 1.25rem;
            letter-spacing: 0.05em;
            opacity: 0.8;
            color: #fff;
        }
        .animated-bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 0;
            pointer-events: none;
            overflow: hidden;
        }
        .dot {
            position: absolute;
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: rgba(192, 132, 252, 0.2);
            animation: float 20s infinite linear;
        }
        .dot.maintenance {
            background: rgba(243, 156, 18, 0.2);
        }
        @keyframes float {
            0% { transform: translateY(100vh) scale(1); }
            100% { transform: translateY(-10vh) scale(1.5); }
        }
    </style>
</head>
<body class="text-white flex flex-col min-h-screen">

<div id="startup">
    <div id="star">
        <div class="blur"></div>
        <svg class="relative z-10" viewBox="0 0 100 100">
            <path d="M50 5 L63 40 L95 50 L63 60 L50 95 L37 60 L5 50 L37 40 Z" fill="#c084fc"/>
            <path d="M50 28 L58 45 L76 50 L58 55 L50 72 L42 55 L24 50 L42 45 Z" fill="#fff" opacity="0.9"/>
        </svg>
    </div>
    <p>AstraOS</p>
</div>

<div class="animated-bg"></div>

<div class="flex">
    <aside class="fixed top-0 left-0 w-64 h-screen bg-black/40 border-r p-6 backdrop-blur-lg flex flex-col flex-shrink-0 z-20
                   {% if maintenance_active %}border-yellow-500/30{% else %}border-purple-500/20{% endif %}">
        <h1 class="text-3xl font-bold mb-8 tracking-wide
                   {% if maintenance_active %}text-yellow-300{% else %}text-purple-300{% endif %}">AstraOS</h1>

        <nav class="flex flex-col gap-2 text-gray-300 overflow-y-auto">

            <a href="{{ url_for('dashboard') }}"
               class="px-3 py-2 rounded-md transition flex-shrink-0
               {% if active_page == 'dashboard' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                Dashboard
            </a>

            <a href="{{ url_for('status_page') }}"
               class="px-3 py-2 rounded-md transition flex-shrink-0
               {% if active_page == 'status_page' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                Status Page
            </a>

            <a href="{{ url_for('settings') }}"
               class="px-3 py-2 rounded-md transition flex-shrink-0
               {% if active_page == 'settings' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                Einstellungen
            </a>

            <div>
                <button class="w-full text-left px-3 py-2 rounded-md transition flex justify-between items-center collapsible flex-shrink-0
                               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}"
                        data-open="{% if active_page in ['user_management', 'role_management', 'maintenance_management'] %}true{% else %}false{% endif %}">
                    <span>Administration</span>
                    <svg class="w-4 h-4 transform transition-transform"
                         fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                              d="M19 9l-7 7-7-7"></path>
                    </svg>
                </button>

                <div class="pl-4 mt-1 space-y-1 content hidden">
                    <a href="{{ url_for('user_management') }}"
                       class="block px-3 py-1 rounded-md transition
                       {% if active_page == 'user_management' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
                       {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                        👤 User Management
                    </a>

                    <a href="{{ url_for('role_management') }}"
                       class="block px-3 py-1 rounded-md transition
                       {% if active_page == 'role_management' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
                       {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                        🛡️ Role Management
                    </a>
                    <a href="{{ url_for('maintenance_management') }}"
                       class="block px-3 py-1 rounded-md transition
                       {% if active_page == 'maintenance_management' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
                       {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                        🔧 Maintenance
                    </a>
                </div>
            </div>

            <div>
                <button class="w-full text-left px-3 py-2 rounded-md transition flex justify-between items-center collapsible
                               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}"
                        data-open="{% if active_page in ['discord_bots'] %}true{% else %}false{% endif %}">
                    <span>Private Tools</span>
                    <svg class="w-4 h-4 transform transition-transform"
                         fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                              d="M19 9l-7 7-7-7"></path>
                    </svg>
                </button>

                <div class="pl-4 mt-1 space-y-1 content hidden">
                    {% if 'manage_discord_bots' in session.get('permissions', []) %}
                    <a href="{{ url_for('discord_bots') }}"
                       class="block px-3 py-1 rounded-md transition
                       {% if active_page == 'discord_bots' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
                       {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                        🤖 Discord Bots
                    </a>
                    {% endif %}
                </div>
            </div>

            <div>
                <button class="w-full text-left px-3 py-2 rounded-md transition flex justify-between items-center collapsible
                               {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}"
                        data-open="{% if active_page in ['ip_analyzer'] %}true{% else %}false{% endif %}">
                    <span>Moonlab Tools</span>
                    <svg class="w-4 h-4 transform transition-transform"
                         fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                              d="M19 9l-7 7-7-7"></path>
                    </svg>
                </button>

                <div class="pl-4 mt-1 space-y-1 content hidden">
                    {% if 'view_ip_analyzer' in session.get('permissions', []) %}
                    <a href="{{ url_for('ip_analyzer') }}"
                       class="block px-3 py-1 rounded-md transition
                       {% if active_page == 'ip_analyzer' %}{% if maintenance_active %}bg-yellow-500/10 text-yellow-300{% else %}bg-purple-500/10 text-purple-300{% endif %}{% else %}
                       {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}{% endif %}">
                        🌐 IP Analyzer
                    </a>
                    {% endif %}
                    <a href="https://intra.moon-lab.de" target="_blank" rel="noopener noreferrer" class="block px-3 py-1 rounded-md {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}">🌐 Moonlab-Intranet</a>
                    <a href="javascript:void(0);" onclick="alert('Diese Funktion wird in Kürze verfügbar sein.')" class="block px-3 py-1 rounded-md {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}">🎂 Altersüberprüfung</a>
                    <a href="javascript:void(0);" onclick="alert('Diese Funktion wird in Kürze verfügbar sein.')" class="block px-3 py-1 rounded-md {% if maintenance_active %}hover:bg-yellow-500/10 hover:text-yellow-300{% else %}hover:bg-purple-500/10 hover:text-purple-300{% endif %}">🎉 Events</a>
                </div>
            </div>

        </nav>
    </aside>

    <div class="ml-64 flex-1 flex flex-col min-h-screen">
        <main class="flex-1 p-8 space-y-10" id="mainContent">
            {% block content %}{% endblock %}
        </main>

        <footer>
            &copy; 2025 AstraOS
        </footer>
    </div>
</div>

<a href="{{ url_for('logout') }}" class="fixed bottom-6 left-6 text-white font-bold py-3 px-5 rounded-full shadow-lg transition-all backdrop-blur-sm flex items-center gap-2 z-30
    {% if maintenance_active %}
        bg-yellow-600/50 hover:bg-yellow-500/80 hover:shadow-yellow-500/40 border border-yellow-500/20
    {% else %}
        bg-purple-600/50 hover:bg-purple-500/80 hover:shadow-purple-500/40 border border-purple-500/20
    {% endif %}">
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
        <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9" />
    </svg>
    <span>Logout</span>
</a>


<script src="{{ url_for('static', filename='JAVASCRIPT/main.js') }}"></script>
<script>
gsap.to("#star", {
    rotation: 360,
    duration: 1.2,
    ease: "power1.inOut",
    repeat: -1
});
gsap.to("#star", { scale: 1.2, duration: 0.8, yoyo: true, repeat: -1, ease: "power1.inOut" });
setTimeout(() => {
    gsap.to("#startup", {
        opacity: 0,
        duration: 0.3,
        onComplete: () => {
            document.getElementById("startup").style.display = "none";
            gsap.to("#mainContent", { opacity: 1, duration: 0.1 });
        }
    });
}, 400);
const bg = document.querySelector('.animated-bg');
if (bg) {
    for (let i = 0; i < 50; i++) {
        const dot = document.createElement('div');
        dot.classList.add('dot');
        if (document.body.classList.contains('maintenance-active')) {
            dot.classList.add('maintenance');
        }
        dot.style.left = `${Math.random() * 100}vw`;
        dot.style.animationDelay = `${Math.random() * -20}s`;
        dot.style.animationDuration = `${20 + Math.random() * 10}s`;
        bg.appendChild(dot);
    }
}
</script>
{% if maintenance_active %}
<script>document.body.classList.add('maintenance-active');</script>
{% endif %}
</body>
</html>
