<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Администратор — WB Feedback</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
</head>
<body>

<nav class="topbar">
    <div class="topbar__inner">
        <a href="{{ url_for('index') }}" class="topbar__brand">
            <img src="{{ url_for('static', filename='wb3.png') }}" class="topbar__logo-img" alt="WB">
            
        </a>
        <div class="topbar__nav">
            <a href="{{ url_for('index') }}" class="topbar__link">Отзывы</a>
            <a href="{{ url_for('cabinet') }}" class="topbar__link">Кабинет</a>
            <a href="{{ url_for('admin_panel') }}" class="topbar__link active">Администратор</a>
        </div>
        <div class="topbar__user">
            <span class="topbar__username">{{ current_user["username"] }}</span>
            <a href="{{ url_for('logout') }}" class="btn-ghost">Выйти</a>
        </div>
    </div>
</nav>

<div class="page">

    <div class="page-header">
        <h1>Панель администратора</h1>
        <p class="hint">Управление пользователями и подтверждение заявок.</p>
    </div>

    {% if info_message %}
        <div class="alert alert-success">{{ info_message }}</div>
    {% endif %}

    <div class="cabinet-section">
        <div class="section-header">
            <h2>Пользователи</h2>
            <span class="badge">{{ users|length }}</span>
        </div>

        <ul class="token-list">
            {% for user in users %}
                <li class="token-item">
                    <div class="token-main">
                        <div class="token-name">
                            {{ user["username"] }}
                            {% if user["is_admin"] %}
                                <span class="badge badge-admin">Администратор</span>
                            {% endif %}
                            {% if user["is_active"] %}
                                <span class="badge badge-green">Активен</span>
                            {% else %}
                                <span class="badge badge-inactive">Не активен</span>
                            {% endif %}
                        </div>
                    </div>

                    {% if current_user["id"] != user["id"] %}
                        <div class="token-actions">
                            <form method="post" class="inline-form">
                                <input type="hidden" name="user_id" value="{{ user['id'] }}">
                                {% if user["is_active"] %}
                                    <input type="hidden" name="admin_action" value="deactivate">
                                    <button type="submit" class="secondary">Отключить</button>
                                {% else %}
                                    <input type="hidden" name="admin_action" value="activate">
                                    <button type="submit">Активировать</button>
                                {% endif %}
                            </form>
                        </div>
                    {% endif %}
                </li>
            {% endfor %}
        </ul>
    </div>

</div>

<!-- Нижняя навигация (мобайл) -->
<nav class="bottom-nav">
    <a href="{{ url_for('index') }}" class="bottom-nav__item">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"/>
            <rect x="9" y="3" width="6" height="4" rx="1"/>
            <line x1="9" y1="12" x2="15" y2="12"/>
            <line x1="9" y1="16" x2="13" y2="16"/>
        </svg>
        Отзывы
    </a>
    <a href="{{ url_for('cabinet') }}" class="bottom-nav__item">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
            <circle cx="12" cy="7" r="4"/>
        </svg>
        Кабинет
    </a>
    <a href="{{ url_for('admin_panel') }}" class="bottom-nav__item active">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
        </svg>
        Админ
    </a>
</nav>

</body>
</html>
