{% if session['theme'] == 'darkmode' %}
    {% extends "base_dark.html" %}
{% else %}
    {% extends "base.html" %}
{% endif %}

{% block title %}Altersüberprüfung{% endblock %}

{% block content %}
{% if session['theme'] == 'darkmode' %}
<style>
    .container {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        gap: 40px;
        margin: auto;
        margin-top: 100px;
    }
    .form-container, .search-container {
        background: rgba(30, 30, 30, 0.95);
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.5);
        max-width: 500px;
        width: 100%;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .form-container h1, .search-container h1 {
        margin-bottom: 20px;
        color: #fff;
    }
    .form-container form, .search-container form {
        margin: 5px 0;
        width: 100%;
    }
    .form-container form button, .search-container form button {
        margin-bottom: 5px;
    }
    .form-container input, .search-container input {
        width: 100%;
        padding: 10px;
        margin: 5px 0;
        border-radius: 4px;
        border: 1px solid #444;
        background: #222;
        color: #fff;
    }
    .result {
        font-size: 1.5em;
        color: #0ff;
        margin-top: 20px;
    }
    .user-list {
        margin-top: 20px;
        width: 100%;
        max-height: 400px;
        overflow-y: auto;
    }
    .user-list button {
        width: 100%;
        margin-bottom: 5px;
    }
    .back-btn-row {
        display: flex;
        justify-content: center;
        margin-top: 40px;
    }
    .back-button-dark {
        display: inline-block;
        text-align: center;
        width: auto;
        padding: 14px 28px;
    }
    label {
        color: #fff;
    }
</style>
<div>
    <div class="container">
        <div class="form-container">
            <h1>Altersüberprüfung</h1>
            <form method="POST">
                <label for="birthdate">Geburtsdatum:</label>
                <input type="date" id="birthdate" name="birthdate" value="{{ request.form.birthdate }}" required>
                <br>
                <label for="steam_id">SteamID:</label>
                <input type="text" id="steam_id" name="steam_id" value="{{ request.form.steam_id }}" required>
                <br>
                <label for="ingame_name">Ingame Name:</label>
                <input type="text" id="ingame_name" name="ingame_name" value="{{ request.form.ingame_name }}" required>
                <br>
                <button type="submit" class="neon-button neon1"><span>Überprüfen</span></button>
            </form>
            {% if age is not none %}
                <p class="result">Die Person ist {{ age }} Jahre alt.</p>
                {% if age < 13 %}
                    <p class="result">Diese Person muss für {{ (birthdate_dt.replace(year=birthdate_dt.year + 13) - today).days }} Tage gebannt werden.</p>
                {% else %}
                    <p class="result">Diese Person muss nicht gebannt werden.</p>
                {% endif %}
            {% endif %}
        </div>
        <div class="search-container">
            <h1>Benutzer suchen</h1>
            <form method="GET">
                <input type="text" name="search" placeholder="Suche nach Ingame Name oder SteamID" value="{{ request.args.search }}">
                <button type="submit" class="neon-button neon2"><span>Suchen</span></button>
            </form>
            <div class="user-list">
                {% for user in users %}
                    <form action="{{ url_for('view_user_age', user_id=user._id) }}" method="get">
                        <button type="submit" class="neon-button neon1"><span>{{ user.ingame_name }}</span></button>
                    </form>
                {% endfor %}
            </div>
        </div>
    </div>
    <div class="back-btn-row">
        <a href="{{ url_for('dashboard') }}" class="neon-button neon3 back-button-dark"><span>Zurück</span></a>
    </div>
</div>
{% else %}
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <title>Altersüberprüfung</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;
            flex-direction: column;
        }
        .container {
            display: flex;
            justify-content: center;
            align-items: flex-start;
            gap: 40px;
            margin: auto;
            margin-top: 150px;
        }
        .form-container, .search-container {
            background: rgba(255, 255, 255, 0.6);
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            max-width: 500px;
            width: 100%;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .form-container h1, .search-container h1 {
            margin-bottom: 20px;
        }
        .form-container form, .search-container form {
            margin: 5px 0;
            width: 100%;
        }
        .form-container form button, .search-container form button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            border-radius: 4px;
            width: 100%;
            margin-bottom: 5px;
        }
        .form-container form button:hover, .search-container form button:hover {
            background-color: #0056b3;
        }
        .form-container input, .search-container input {
            width: 100%;
            padding: 10px;
            margin: 5px 0;
            border-radius: 4px;
            border: 1px solid #ccc;
        }
        .result {
            font-size: 1.5em;
            color: #333;
            margin-top: 20px;
        }
        .user-list {
            margin-top: 20px;
            width: 100%;
            max-height: 400px;
            overflow-y: auto;
        }
        .user-list button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            border-radius: 4px;
            width: 100%;
            margin-bottom: 5px;
        }
        .user-list button:hover {
            background-color: #0056b3;
        }
        .back-btn-row {
            display: flex;
            justify-content: center;
            margin-top: 40px;
        }
        .back-button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 15px;
            cursor: pointer;
            border-radius: 4px;
            width: auto;
            margin-top: 0;
            text-align: center;
            display: inline-block;
        }
        .back-button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    {% include "top_bar.html" %}
    <div class="container">
        <div class="form-container">
            <h1>Altersüberprüfung</h1>
            <form method="POST">
                <label for="birthdate">Geburtsdatum:</label>
                <input type="date" id="birthdate" name="birthdate" value="{{ request.form.birthdate }}" required>
                <br>
                <label for="steam_id">SteamID:</label>
                <input type="text" id="steam_id" name="steam_id" value="{{ request.form.steam_id }}" required>
                <br>
                <label for="ingame_name">Ingame Name:</label>
                <input type="text" id="ingame_name" name="ingame_name" value="{{ request.form.ingame_name }}" required>
                <br>
                <button type="submit">Überprüfen</button>
            </form>
            {% if age is not none %}
                <p class="result">Die Person ist {{ age }} Jahre alt.</p>
                {% if age < 13 %}
                    <p class="result">Diese Person muss für {{ (birthdate_dt.replace(year=birthdate_dt.year + 13) - today).days }} Tage gebannt werden.</p>
                {% else %}
                    <p class="result">Diese Person muss nicht gebannt werden.</p>
                {% endif %}
            {% endif %}
        </div>
        <div class="search-container">
            <h1>Benutzer suchen</h1>
            <form method="GET">
                <input type="text" name="search" placeholder="Suche nach Ingame Name oder SteamID" value="{{ request.args.search }}">
                <button type="submit">Suchen</button>
            </form>
            <div class="user-list">
                {% for user in users %}
                    <form action="{{ url_for('view_user_age', user_id=user._id) }}" method="get">
                        <button type="submit">{{ user.ingame_name }}</button>
                    </form>
                {% endfor %}
            </div>
        </div>
    </div>
    <div class="back-btn-row">
        <a href="{{ url_for('dashboard') }}" class="back-button">Zurück</a>
    </div>
</body>
</html>
{% endif %}
{% endblock %}
