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

{% block extrastyle %}
<link rel="stylesheet" href="{% static 'marketplace/css/marketplace.css' %}?v=1.0">
{% endblock %}

{% block content %}
<div class="reports-container">
  <div class="container">
    <!-- Header Compacto -->
    <div class="marketplace-header">
      <div class="marketplace-header-icon">
        <i class="fas fa-shopping-bag"></i>
      </div>
      <h1 class="marketplace-title">{% trans "Minhas Compras" %}</h1>
      <p class="marketplace-subtitle">
        <i class="fas fa-check-circle me-2"></i>{% trans "Personagens que você adquiriu no marketplace" %}
      </p>
    </div>

    <!-- Breadcrumbs -->
    <nav aria-label="breadcrumb" class="mb-4">
      <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="{% url 'dashboard' %}">{% trans "Dashboard" %}</a>
        </li>
        <li class="breadcrumb-item">
          <a href="{% url 'marketplace:list' %}">{% trans "Marketplace" %}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{% trans "Minhas Compras" %}</li>
      </ol>
    </nav>

    <!-- Purchases List -->
    <div class="reports-card">
      <div class="reports-card-header">
        <i class="fas fa-receipt reports-icon"></i>
        <h2 class="reports-card-title">{% trans "Histórico de Compras" %}</h2>
        <p class="reports-card-description">{% trans "Personagens adquiridos" %}</p>
      </div>
      <div class="reports-card-body">
        {% if purchases %}
        <div class="marketplace-grid">
          {% for purchase in purchases %}
          <div class="character-card">
            <!-- Header -->
            <div class="character-card-header">
              <div class="character-badge">
                <span class="character-level">LVL {{ purchase.char_level }}</span>
                <span class="character-class">{{ purchase.class_name }}</span>
              </div>
              <span class="status-badge status-{{ purchase.status }}">
                {{ purchase.get_status_display }}
              </span>
            </div>

            <!-- Info -->
            <div class="character-info">
              <h3 class="character-name">{{ purchase.char_name }}</h3>
              
              <div class="purchase-detail-info">
                <div class="info-row">
                  <i class="fas fa-user text-info me-2"></i>
                  <span class="info-label">{% trans "Vendedor" %}:</span>
                  <span class="info-value">{{ purchase.seller.username }}</span>
                </div>
                <div class="info-row">
                  <i class="fas fa-calendar text-warning me-2"></i>
                  <span class="info-label">{% trans "Comprado em" %}:</span>
                  <span class="info-value">{{ purchase.sold_at|date:"d/m/Y H:i" }}</span>
                </div>
              </div>
            </div>

            <!-- Price -->
            <div class="character-price">
              <span class="price-label">{% trans "Valor Pago" %}</span>
              <div class="price-value">
                <span class="currency">R$</span>
                <span class="amount">{{ purchase.price }}</span>
              </div>
            </div>

            <!-- Action -->
            <div class="character-actions">
              <a href="{% url 'marketplace:character_detail' purchase.id %}" class="btn btn-primary btn-block">
                <i class="fas fa-eye me-2"></i>{% trans "Ver Detalhes" %}
              </a>
            </div>
          </div>
          {% endfor %}
        </div>
        {% else %}
        <div class="empty-state">
          <i class="fas fa-shopping-basket fa-3x mb-3"></i>
          <p>{% trans "Você ainda não comprou nenhum personagem." %}</p>
          <a href="{% url 'marketplace:list' %}" class="btn btn-primary mt-3">
            <i class="fas fa-search me-2"></i>{% trans "Explorar Marketplace" %}
          </a>
        </div>
        {% endif %}
      </div>
    </div>

    <!-- Return Button -->
    <div class="text-center mt-4">
      <a href="{% url 'marketplace:list' %}" class="report-back-button">
        <i class="fas fa-arrow-left me-2"></i>{% trans "Voltar ao Marketplace" %}
      </a>
    </div>
  </div>
</div>
{% endblock %}

{% block extrajs %}
<script src="{% static 'marketplace/js/marketplace.js' %}?v=1.0"></script>
{% endblock %}

