{% from "macros.html" import panel %}

<div class="quests-summary mb-4">
    <div class="row">
        <div class="col-md-4">
            <div class="stat-card">
                <div class="stat-value">{{ total_tokens }}</div>
                <div class="stat-label">Tokens Earned</div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="stat-card">
                <div class="stat-value">{{ completed_count }}</div>
                <div class="stat-label">Quests Completed</div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="stat-card">
                <div class="stat-value">{{ quests|selectattr('enabled', 'equalto', true)|list|length }}</div>
                <div class="stat-label">Active Quests</div>
            </div>
        </div>
    </div>
</div>

<div class="quests-list">
    {% for quest in quests %}
    {% if quest.enabled %}
    <div class="quest-card quest-status-{{ quest.status }}">
        <div class="quest-header">
            <h5 class="quest-name">{{ quest.name }}</h5>
            <span class="quest-reward">+{{ quest.reward_tokens }} ⚡</span>
        </div>
        <p class="quest-description">{{ quest.description }}</p>

        <div class="quest-progress">
            {% if quest.status == 'completed' %}
            <div class="progress">
                <div class="progress-bar bg-success" style="width: 100%"></div>
            </div>
            <span class="quest-status-badge completed">Completed</span>
            {% elif quest.status == 'claimed' %}
            <div class="progress">
                <div class="progress-bar bg-success" style="width: 100%"></div>
            </div>
            <span class="quest-status-badge claimed">Reward Claimed</span>
            {% elif quest.on_cooldown %}
            <div class="progress">
                <div class="progress-bar bg-secondary" style="width: 100%"></div>
            </div>
            <span class="quest-status-badge cooldown">
                Cooldown: {{ quest.cooldown_hours_remaining }}h remaining
            </span>
            {% else %}
            <div class="progress">
                <div class="progress-bar" style="width: {{ (quest.current_value / quest.target_value * 100)|int }}%"></div>
            </div>
            <span class="quest-progress-text">{{ quest.current_value }} / {{ quest.target_value }}</span>
            {% endif %}
        </div>

        <div class="quest-meta">
            <span class="quest-type">{{ quest.type }}</span>
            {% if quest.repeatable %}
            <span class="quest-repeatable">↻ Repeatable</span>
            {% endif %}
            {% if quest.completion_count > 0 %}
            <span class="quest-completions">Completed {{ quest.completion_count }} time{% if quest.completion_count != 1 %}s{% endif %}</span>
            {% endif %}
        </div>
    </div>
    {% endif %}
    {% endfor %}
</div>

{% if not quests|selectattr('enabled', 'equalto', true)|list|length %}
<div class="alert alert-info">
    No active quests available. Check back later or contact an administrator.
</div>
{% endif %}
