{% extends "layouts/base.html" %}
{% load static i18n %}

{% block title %}{% trans "Battle Pass Manager" %} - {% trans "Base de Batalha" %}{% endblock %}

{% block extrastyle %}
<style>
.manager-bg { 
    background: radial-gradient(ellipse at center, #0f172a 0%, #1a1a2e 50%, #0f0f1e 100%); 
    min-height: 100vh; 
    padding: 40px 0; 
    position: relative;
}
.manager-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(111, 66, 193, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(13, 202, 240, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.card-glow { 
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.95) 0%, rgba(18, 18, 32, 0.95) 100%); 
    border: 1px solid rgba(111, 66, 193, 0.3); 
    border-radius: 16px; 
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(111, 66, 193, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}
.card-glow:hover {
    border-color: rgba(111, 66, 193, 0.6);
    box-shadow: 
        0 12px 40px rgba(111, 66, 193, 0.3),
        0 0 0 1px rgba(111, 66, 193, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 16px;
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover::before {
    transform: scaleX(1);
}
.stat-card:hover {
    transform: translateY(-8px);
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.3);
}
.stat-value {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #a8b4ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    margin-bottom: 8px;
}
.stat-label {
    font-size: 0.95rem;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-action {
    background: linear-gradient(135deg, #6f42c1 0%, #0dcaf0 100%);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(111, 66, 193, 0.4);
    position: relative;
    overflow: hidden;
}
.btn-action::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}
.btn-action:hover::before {
    width: 300px;
    height: 300px;
}
.btn-action:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(111, 66, 193, 0.6);
    color: white;
}

.season-card {
    border: 2px solid rgba(245, 158, 11, 0.4);
    box-shadow: 
        0 8px 32px rgba(245, 158, 11, 0.2),
        0 0 0 1px rgba(245, 158, 11, 0.1);
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.98) 0%, rgba(18, 18, 32, 0.98) 100%);
}
.season-card:hover {
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 
        0 12px 40px rgba(245, 158, 11, 0.3),
        0 0 0 1px rgba(245, 158, 11, 0.2);
}

.season-card .card-header {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-inactive {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quick-action-card {
    transition: all 0.3s ease;
    height: 100%;
}
.quick-action-card:hover {
    transform: translateY(-5px);
}
.quick-action-card .card-header {
    background: linear-gradient(135deg, rgba(111, 66, 193, 0.1) 0%, rgba(13, 202, 240, 0.1) 100%);
    border-bottom: 1px solid rgba(111, 66, 193, 0.2);
}

.page-header h2 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff 0%, #a8b4ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn {
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
}
.btn:hover {
    transform: translateY(-2px);
}

.btn-solid-white {
    background: #ffffff !important;
    color: #1a1a2e !important;
    border: none !important;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}
.btn-solid-white:hover {
    background: #f8f9fa !important;
    color: #1a1a2e !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}
.btn-solid-white:focus {
    background: #ffffff !important;
    color: #1a1a2e !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
    .stat-value {
        font-size: 2rem;
    }
    .manager-bg {
        padding: 20px 0;
    }
}
</style>
{% endblock %}

{% block content %}
<div class="manager-bg">
    <div class="container">
        <!-- Header -->
        <div class="d-flex flex-column flex-md-row justify-content-between align-items-start align-items-md-center mb-5">
            <div class="page-header mb-3 mb-md-0">
                <h2 class="mb-2">
                    <i class="bi bi-trophy-fill text-warning me-2"></i>
                    {% trans "Configurador de Base de Batalha" %}
                </h2>
                <p class="text-white-50 mb-0">{% trans "Gerencie temporadas, níveis e recompensas do Battle Pass" %}</p>
            </div>
            <div class="d-flex gap-2">
                <a href="{% url 'config_hub' %}" class="btn btn-solid-white">
                    <i class="bi bi-arrow-left me-2"></i>{% trans "Voltar" %}
                </a>
                <a href="{% url 'games:battle_pass_manager_season_create' %}" class="btn-action position-relative">
                    <i class="bi bi-plus-circle me-2"></i>{% trans "Nova Temporada" %}
                </a>
            </div>
        </div>

        <!-- Statistics Cards -->
        <div class="row g-4 mb-5">
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-calendar-event" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_seasons }}</div>
                    <div class="stat-label">{% trans "Temporadas" %}</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-list-ol" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_levels }}</div>
                    <div class="stat-label">{% trans "Níveis" %}</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-gift" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_rewards }}</div>
                    <div class="stat-label">{% trans "Recompensas" %}</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-people" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_progress }}</div>
                    <div class="stat-label">{% trans "Usuários Ativos" %}</div>
                </div>
            </div>
        </div>

        <!-- Additional Statistics -->
        <div class="row g-4 mb-5">
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-tasks" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_quests }}</div>
                    <div class="stat-label">{% trans "Quests Ativas" %}</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-trophy" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_milestones }}</div>
                    <div class="stat-label">{% trans "Milestones" %}</div>
                </div>
            </div>
            <div class="col-6 col-md-3">
                <div class="stat-card text-center position-relative">
                    <i class="bi bi-arrow-left-right" style="font-size: 2rem; opacity: 0.3; position: absolute; top: 10px; right: 15px;"></i>
                    <div class="stat-value">{{ total_exchanges }}</div>
                    <div class="stat-label">{% trans "Trocas Ativas" %}</div>
                </div>
            </div>
        </div>

        <!-- Active Season Card -->
        {% if season %}
        <div class="card card-glow season-card mb-4">
            <div class="card-header bg-transparent border-bottom border-warning">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <h5 class="text-white mb-0">
                            <i class="bi bi-trophy-fill text-warning me-2"></i>
                            {{ season.name }}
                        </h5>
                        <small class="text-white-50">
                            {% trans "De" %} {{ season.start_date|date:"d/m/Y H:i" }} 
                            {% trans "até" %} {{ season.end_date|date:"d/m/Y H:i" }}
                        </small>
                    </div>
                    <div>
                        {% if season.is_active %}
                        <span class="badge-active">
                            <i class="bi bi-check-circle me-1"></i>{% trans "Ativa" %}
                        </span>
                        {% else %}
                        <span class="badge-inactive">
                            <i class="bi bi-x-circle me-1"></i>{% trans "Inativa" %}
                        </span>
                        {% endif %}
                    </div>
                </div>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <p class="text-white mb-2">
                            <strong>{% trans "Preço Premium:" %}</strong> 
                            <span class="text-warning">{{ season.premium_price }} {% trans "moedas" %}</span>
                        </p>
                        <p class="text-white mb-2">
                            <strong>{% trans "Total de Níveis:" %}</strong> 
                            <span class="text-info">{{ total_levels }}</span>
                        </p>
                        <p class="text-white mb-3">
                            <strong>{% trans "Total de Recompensas:" %}</strong> 
                            <span class="text-info">{{ total_rewards }}</span>
                        </p>
                    </div>
                    <div class="col-md-6">
                        <p class="text-white mb-2">
                            <strong>{% trans "Usuários Participando:" %}</strong> 
                            <span class="text-success">{{ total_progress }}</span>
                        </p>
                    </div>
                </div>
                <div class="d-flex gap-2 mt-3">
                    <a href="{% url 'games:battle_pass_manager_season_detail' season_id=season.id %}" class="btn btn-info">
                        <i class="bi bi-eye me-2"></i>{% trans "Ver Detalhes" %}
                    </a>
                    <a href="{% url 'games:battle_pass_manager_season_edit' season_id=season.id %}" class="btn btn-warning">
                        <i class="bi bi-pencil me-2"></i>{% trans "Editar" %}
                    </a>
                    <a href="{% url 'games:battle_pass_manager_season_list' %}" class="btn btn-solid-white">
                        <i class="bi bi-list me-2"></i>{% trans "Todas as Temporadas" %}
                    </a>
                </div>
            </div>
        </div>
        {% else %}
        <div class="card card-glow mb-4">
            <div class="card-body text-center py-5">
                <i class="bi bi-trophy" style="font-size: 4rem; color: #6f42c1; opacity: 0.5;"></i>
                <h4 class="text-white mt-3">{% trans "Nenhuma temporada encontrada" %}</h4>
                <p class="text-white-50">{% trans "Crie sua primeira temporada de Battle Pass para começar" %}</p>
                <a href="{% url 'games:battle_pass_manager_season_create' %}" class="btn-action mt-3">
                    <i class="bi bi-plus-circle me-2"></i>{% trans "Criar Primeira Temporada" %}
                </a>
            </div>
        </div>
        {% endif %}

        <!-- Quick Actions -->
        <div class="row g-4">
            <div class="col-md-6">
                <div class="card card-glow quick-action-card">
                    <div class="card-header bg-transparent border-bottom">
                        <h5 class="text-white mb-0 d-flex align-items-center">
                            <i class="bi bi-calendar-event me-2 text-info" style="font-size: 1.5rem;"></i>
                            {% trans "Temporadas" %}
                        </h5>
                    </div>
                    <div class="card-body">
                        <p class="text-white-50 mb-4" style="line-height: 1.6;">
                            {% trans "Gerencie todas as temporadas do Battle Pass. Crie, edite ou ative temporadas." %}
                        </p>
                        <a href="{% url 'games:battle_pass_manager_season_list' %}" class="btn btn-outline-info w-100">
                            <i class="bi bi-list-ul me-2"></i>{% trans "Ver Todas as Temporadas" %}
                        </a>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="card card-glow quick-action-card">
                    <div class="card-header bg-transparent border-bottom">
                        <h5 class="text-white mb-0 d-flex align-items-center">
                            <i class="bi bi-arrow-left-right me-2 text-success" style="font-size: 1.5rem;"></i>
                            {% trans "Trocas de Itens" %}
                        </h5>
                    </div>
                    <div class="card-body">
                        <p class="text-white-50 mb-4" style="line-height: 1.6;">
                            {% trans "Configure itens que podem ser trocados por XP do Battle Pass." %}
                        </p>
                        <a href="{% url 'games:battle_pass_manager_exchange_list' %}" class="btn btn-outline-success w-100">
                            <i class="bi bi-list-ul me-2"></i>{% trans "Gerenciar Trocas" %} 
                            <span class="badge bg-success ms-2">{{ total_exchanges }}</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <!-- New Features Quick Actions -->
        <div class="row g-4 mt-2">
            <div class="col-md-6">
                <div class="card card-glow quick-action-card">
                    <div class="card-header bg-transparent border-bottom">
                        <h5 class="text-white mb-0 d-flex align-items-center">
                            <i class="bi bi-tasks me-2 text-info" style="font-size: 1.5rem;"></i>
                            {% trans "Missões/Quests" %}
                        </h5>
                    </div>
                    <div class="card-body">
                        <p class="text-white-50 mb-4" style="line-height: 1.6;">
                            {% trans "Gerencie missões diárias, semanais e especiais do Battle Pass." %}
                        </p>
                        <div class="d-flex gap-2">
                            <a href="{% url 'games:battle_pass_manager_quest_list' %}" class="btn btn-outline-info flex-fill">
                                <i class="bi bi-list-ul me-2"></i>{% trans "Ver Quests" %}
                            </a>
                            <a href="{% url 'games:battle_pass_manager_quest_create' %}" class="btn btn-info">
                                <i class="bi bi-plus-circle me-2"></i>{% trans "Nova" %}
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            {% if season %}
            <div class="col-md-6">
                <div class="card card-glow quick-action-card">
                    <div class="card-header bg-transparent border-bottom">
                        <h5 class="text-white mb-0 d-flex align-items-center">
                            <i class="bi bi-trophy me-2 text-warning" style="font-size: 1.5rem;"></i>
                            {% trans "Milestones" %}
                        </h5>
                    </div>
                    <div class="card-body">
                        <p class="text-white-50 mb-4" style="line-height: 1.6;">
                            {% trans "Configure marcos especiais com bônus de XP para níveis importantes." %}
                        </p>
                        <div class="d-flex gap-2">
                            <a href="{% url 'games:battle_pass_manager_milestone_list' season_id=season.id %}" class="btn btn-outline-warning flex-fill">
                                <i class="bi bi-list-ul me-2"></i>{% trans "Ver Milestones" %}
                            </a>
                            <a href="{% url 'games:battle_pass_manager_milestone_create' season_id=season.id %}" class="btn btn-warning">
                                <i class="bi bi-plus-circle me-2"></i>{% trans "Novo" %}
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}

