{% extends "admin/base.html" %}
{% block title %}Дашборд — Админ-панель{% endblock %}
{% block nav_dashboard %}active{% endblock %}
{% block page_title %}📊 Дашборд{% endblock %}

{% block content %}
<div class="a-stats">
    <div class="a-stat">
        <div class="as-label">Пользователей</div>
        <div class="as-value">{{ total_users }}</div>
        <div class="as-bar" style="width:60%;background:#f59e0b"></div>
    </div>
    <div class="a-stat">
        <div class="as-label">Открыто кейсов</div>
        <div class="as-value">{{ total_openings }}</div>
        <div class="as-bar" style="width:45%;background:#60a5fa"></div>
    </div>
    <div class="a-stat">
        <div class="as-label">Проведено контрактов</div>
        <div class="as-value">{{ total_contracts }}</div>
        <div class="as-bar" style="width:30%;background:#a78bfa"></div>
    </div>
    <div class="a-stat">
        <div class="as-label">Предметов в БД</div>
        <div class="as-value">{{ total_items }}</div>
        <div class="as-bar" style="width:75%;background:#f472b6"></div>
    </div>
    <div class="a-stat">
        <div class="as-label">Общий баланс</div>
        <div class="as-value">{{ total_balance|money }} ₽</div>
        <div class="as-bar" style="width:40%;background:#34d399"></div>
    </div>
    <div class="a-stat">
        <div class="as-label">Средний РПУ</div>
        <div class="as-value">{{ avg_rpu }}%</div>
        <div class="as-bar" style="width:{{ avg_rpu }}%;background:#fbbf24"></div>
    </div>
</div>

<div class="a-row a-mb">
    <div class="a-card" style="flex:1">
        <div class="a-card-header">🎲 RPU Overview</div>
        {% if rpu_count > 0 %}
        <div class="a-row a-gap-sm a-mb" style="text-align:center;justify-content:space-around">
            <div><div class="as-value" style="font-size:1.2rem">{{ rpu_count }}</div><div class="as-label" style="font-size:0.7rem">Всего записей</div></div>
            <div><div class="as-value" style="font-size:1.2rem">{{ "%.1f"|format(avg_rpu) }}%</div><div class="as-label" style="font-size:0.7rem">Средний уровень</div></div>
            <div><div class="as-value" style="font-size:1.2rem" style="color:#22c55e">{{ lucky_count }}</div><div class="as-label" style="font-size:0.7rem">🍀 Везучих</div></div>
            <div><div class="as-value" style="font-size:1.2rem" style="color:#f59e0b">{{ normal_count }}</div><div class="as-label" style="font-size:0.7rem">📊 Обычных</div></div>
            <div><div class="as-value" style="font-size:1.2rem" style="color:#ef4444">{{ unlucky_count }}</div><div class="as-label" style="font-size:0.7rem">🌧️ Невезучих</div></div>
            <div><div class="as-value" style="font-size:1.2rem">{{ total_spent|money }} ₽</div><div class="as-label" style="font-size:0.7rem">Потрачено всего</div></div>
        </div>
        {% else %}
        <div class="a-empty"><div class="a-empty-icon">📭</div>Нет данных RPU</div>
        {% endif %}
    </div>
</div>
{% endblock %}
