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

{% block content %}
<style>
  :root {
    --primary-glow: #4b0082;
    --secondary-glow: #8a2be2;
    --accent-color: #ffd700;
    --success-color: #00ff7f;
    --text-glow: 0 0 10px rgba(255, 255, 255, 0.5);
  }

  body {
    background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
  }

  .quests-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2rem;
    position: relative;
  }

  .quests-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
  }

  .quests-header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-color) 0%, #ffa500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: var(--text-glow);
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
  }

  .quests-header h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-glow), var(--secondary-glow));
    border-radius: 2px;
  }

  .quest-section {
    margin-bottom: 4rem;
    position: relative;
  }

  .quest-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: -20px;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-glow), var(--secondary-glow));
    border-radius: 2px;
    opacity: 0.3;
  }

  .quest-section h2 {
    color: var(--accent-color);
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(75,0,130,0.2) 0%, rgba(138,43,226,0.2) 100%);
    border-radius: 1rem;
    border-left: 4px solid var(--primary-glow);
    box-shadow: 0 4px 15px rgba(75,0,130,0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    text-shadow: 0 0 10px rgba(255,215,0,0.3);
  }

  .quest-section h2 i {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px rgba(255,215,0,0.5));
  }

  .quest-card {
    background: linear-gradient(145deg, rgba(30, 30, 47, 0.95) 0%, rgba(41, 41, 61, 0.95) 100%);
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 
      0 8px 32px rgba(0,0,0,0.4),
      0 0 0 1px rgba(255,255,255,0.1),
      inset 0 1px 0 rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
  }

  .quest-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(75,0,130,0.1) 0%, rgba(138,43,226,0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
  }

  .quest-card:hover::before {
    opacity: 1;
  }

  .quest-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
      0 16px 48px rgba(75,0,130,0.5),
      0 0 0 1px rgba(255,215,0,0.2),
      inset 0 1px 0 rgba(255,255,255,0.2);
    border-color: rgba(255,215,0,0.3);
  }

  .quest-card.completed {
    opacity: 0.85;
    border-left: 5px solid var(--success-color);
    background: linear-gradient(145deg, rgba(0,255,127,0.1) 0%, rgba(30, 30, 47, 0.95) 100%);
  }

  .quest-card.completed::after {
    content: '✓';
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--success-color), #00ff00);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: bold;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,255,127,0.4);
  }

  .quest-card.premium {
    border-left: 5px solid var(--accent-color);
    background: linear-gradient(145deg, rgba(255,215,0,0.1) 0%, rgba(30, 30, 47, 0.95) 100%);
    position: relative;
  }

  .quest-card.premium::after {
    content: '👑';
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px rgba(255,215,0,0.8));
  }

  .quest-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1.5rem;
  }

  .quest-title {
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1.3;
  }

  .quest-description {
    color: rgba(255,255,255,0.85);
    margin-bottom: 0;
    line-height: 1.6;
    font-size: 1rem;
  }

  .quest-reward {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, rgba(255,215,0,0.15) 0%, rgba(255,165,0,0.15) 100%);
    border-radius: 1rem;
    border: 1px solid rgba(255,215,0,0.3);
    box-shadow: 0 4px 12px rgba(255,215,0,0.2);
  }

  .quest-reward i {
    font-size: 1.3rem;
    filter: drop-shadow(0 0 5px rgba(255,215,0,0.8));
    animation: pulse 2s ease-in-out infinite;
  }

  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
  }

  .quest-badges {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
  }

  .badge:hover {
    transform: scale(1.05);
  }

  .badge-premium {
    background: linear-gradient(135deg, var(--accent-color) 0%, #ffa500 100%);
    color: #000;
    box-shadow: 0 4px 15px rgba(255,215,0,0.4);
    animation: shimmer 3s ease-in-out infinite;
  }

  @keyframes shimmer {
    0%, 100% { box-shadow: 0 4px 15px rgba(255,215,0,0.4); }
    50% { box-shadow: 0 4px 20px rgba(255,215,0,0.6); }
  }

  .badge-completed {
    background: linear-gradient(135deg, var(--success-color) 0%, #00ff00 100%);
    color: #000;
    box-shadow: 0 4px 15px rgba(0,255,127,0.4);
  }

  .quest-progress {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.1);
  }

  .quest-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.95rem;
    font-weight: 600;
  }

  .quest-progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
  }

  .quest-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, #00ff00 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(0,255,127,0.5);
  }

  .quest-objective-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.5rem;
  }

  .quest-objective-info i {
    color: var(--accent-color);
  }

  .quest-progress {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border-radius: 1rem;
    border: 1px solid rgba(255,255,255,0.1);
  }

  .quest-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.95rem;
    font-weight: 600;
  }

  .quest-progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
  }

  .quest-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, #00ff00 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(0,255,127,0.5);
  }

  .quest-objective-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0.5rem;
  }

  .quest-objective-info i {
    color: var(--accent-color);
  }

  .quest-required-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255,165,0,0.9);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(255,165,0,0.1);
    border-radius: 0.5rem;
    border-left: 3px solid rgba(255,165,0,0.5);
  }

  .quest-required-item.missing-item {
    background: rgba(255,107,107,0.1);
    border-left-color: rgba(255,107,107,0.5);
  }

  .quest-required-item i {
    color: rgba(255,165,0,0.9);
  }

  .quest-required-item-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid rgba(255,165,0,0.3);
    box-shadow: 0 2px 8px rgba(255,165,0,0.2);
    object-fit: cover;
    flex-shrink: 0;
  }

  .quest-required-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
  }

  .quest-required-item-name {
    font-weight: 600;
    color: rgba(255,165,0,0.95);
  }

  .quest-required-item-details {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
  }

  .quest-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .btn-complete {
    background: linear-gradient(135deg, var(--success-color) 0%, #00ff00 100%);
    color: #000;
    padding: 1rem 2rem;
    border-radius: 2rem;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,255,127,0.4);
    position: relative;
    overflow: hidden;
  }

  .btn-complete::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
  }

  .btn-complete:hover::before {
    width: 300px;
    height: 300px;
  }

  .btn-complete:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,255,127,0.6);
    color: #000;
    text-decoration: none;
  }

  .btn-complete:active {
    transform: translateY(-1px) scale(1.02);
  }

  .btn-complete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }

  .btn-back {
    background: linear-gradient(135deg, var(--primary-glow) 0%, var(--secondary-glow) 100%);
    color: white;
    padding: 1rem 2rem;
    border-radius: 2rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
    position: relative;
    overflow: hidden;
  }

  .btn-back::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-back:hover::before {
    width: 300px;
    height: 300px;
  }

  .btn-back:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(138, 43, 226, 0.6);
    color: white;
    text-decoration: none;
  }

  .empty-quests {
    text-align: center;
    color: rgba(255,255,255,0.7);
    padding: 4rem 2rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
    border-radius: 2rem;
    border: 2px dashed rgba(255,255,255,0.1);
    margin: 3rem 0;
  }

  .empty-quests i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.4;
    display: block;
  }

  .empty-quests p {
    font-size: 1.2rem;
    margin: 0;
  }

  /* Responsividade */
  @media (max-width: 768px) {
    .quests-container {
      padding: 1rem;
    }

    .quests-header h1 {
      font-size: 2rem;
    }

    .quest-section h2 {
      font-size: 1.5rem;
      padding: 0.75rem 1rem;
    }

    .quest-card {
      padding: 1.5rem;
    }

    .quest-header {
      flex-direction: column;
      gap: 1rem;
    }

    .quest-actions {
      flex-direction: column;
      gap: 1rem;
      align-items: stretch;
    }

    .btn-complete {
      width: 100%;
      justify-content: center;
    }
  }
</style>

<div class="quests-container">
  <a href="{% url 'games:battle_pass' %}" class="btn-back">
    <i class="fas fa-arrow-left"></i> {% trans "Voltar ao Battle Pass" %}
  </a>

  <div class="quests-header">
    <h1>
      <i class="fas fa-tasks"></i> {% trans "Missões do Battle Pass" %}
    </h1>
  </div>

  {% if daily_quests %}
  <div class="quest-section">
    <h2><i class="fas fa-calendar-day"></i> {% trans "Missões Diárias" %}</h2>
    {% for quest_data in daily_quests %}
    <div class="quest-card {% if quest_data.progress.completed %}completed{% endif %} {% if quest_data.quest.is_premium %}premium{% endif %}">
      <div class="quest-header">
        <div>
          <div class="quest-title">{{ quest_data.quest.title }}</div>
          <div class="quest-description">{{ quest_data.quest.description }}</div>
        </div>
        <div class="quest-badges">
          {% if quest_data.quest.is_premium %}
          <span class="badge badge-premium">Premium</span>
          {% endif %}
          {% if quest_data.progress.completed %}
          <span class="badge badge-completed">{% trans "Completa" %}</span>
          {% endif %}
        </div>
      </div>
      
      {% if not quest_data.progress.completed %}
      <div class="quest-progress">
        <div class="quest-progress-label">
          <span>{% trans "Progresso" %}</span>
          <span>{{ quest_data.progress.progress }} / {{ quest_data.quest.objective_target }}</span>
        </div>
        <div class="quest-progress-bar">
          <div class="quest-progress-fill" style="width: {% if quest_data.quest.objective_target > 0 %}{% widthratio quest_data.progress.progress quest_data.quest.objective_target 100 %}{% else %}0{% endif %}%"></div>
        </div>
        <div class="quest-objective-info">
          <i class="fas fa-bullseye"></i>
          <span>{% trans "Objetivo" %}: {{ quest_data.quest.get_objective_type_display }}</span>
        </div>
        {% if quest_data.quest.required_item_id %}
        <div class="quest-required-item {% if not quest_data.has_required_item %}missing-item{% endif %}">
          <img src="{% item_image_url quest_data.quest.required_item_id %}" 
               alt="{{ quest_data.quest.required_item_name }}"
               class="quest-required-item-icon"
               title="{{ quest_data.quest.required_item_name }}">
          <div class="quest-required-item-info">
            <div class="quest-required-item-name">
              <i class="fas fa-exclamation-triangle"></i> {% trans "Requer" %}: {{ quest_data.quest.required_item_name }}
            </div>
            <div class="quest-required-item-details">
              <span>x{{ quest_data.quest.required_item_amount }}</span>
              {% if quest_data.quest.required_item_enchant > 0 %}
              <span>+{{ quest_data.quest.required_item_enchant }}</span>
              {% endif %}
              {% if quest_data.bag_item_info %}
              <span style="color: rgba(255,255,255,0.7); margin-left: 0.5rem; font-size: 0.85rem;">
                ({% trans "Você tem" %}: x{{ quest_data.bag_item_info.quantity }}{% if quest_data.bag_item_info.enchant > 0 %} +{{ quest_data.bag_item_info.enchant }}{% endif %})
              </span>
              {% endif %}
              {% if not quest_data.has_required_item %}
              <span style="color: #ff6b6b; font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-times-circle"></i> {% trans "Item não encontrado ou quantidade insuficiente" %}
              </span>
              {% else %}
              <span style="color: var(--success-color); font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-check-circle"></i> {% trans "Item disponível" %}
              </span>
              {% endif %}
            </div>
          </div>
        </div>
        {% endif %}
      </div>
      {% endif %}
      
      <div class="quest-actions">
        <div class="quest-reward">
          <i class="fas fa-star"></i>
          <span>+{{ quest_data.quest.xp_reward }} XP</span>
        </div>
        {% if not quest_data.progress.completed %}
          {% if quest_data.can_complete %}
            {% if quest_data.quest.required_item_id %}
              {% if quest_data.has_required_item %}
              <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
                <i class="fas fa-check"></i> {% trans "Completar" %}
              </a>
              {% else %}
              <button class="btn-complete" disabled>
                <i class="fas fa-exclamation-triangle"></i> {% trans "Item requerido não encontrado" %}
              </button>
              {% endif %}
            {% else %}
            <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
              <i class="fas fa-check"></i> {% trans "Completar" %}
            </a>
            {% endif %}
          {% else %}
          <button class="btn-complete" disabled>
            <i class="fas fa-lock"></i> {% trans "Objetivo não atingido" %}
          </button>
          {% endif %}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>
  {% endif %}

  {% if weekly_quests %}
  <div class="quest-section">
    <h2><i class="fas fa-calendar-week"></i> {% trans "Missões Semanais" %}</h2>
    {% for quest_data in weekly_quests %}
    <div class="quest-card {% if quest_data.progress.completed %}completed{% endif %} {% if quest_data.quest.is_premium %}premium{% endif %}">
      <div class="quest-header">
        <div>
          <div class="quest-title">{{ quest_data.quest.title }}</div>
          <div class="quest-description">{{ quest_data.quest.description }}</div>
        </div>
        <div class="quest-badges">
          {% if quest_data.quest.is_premium %}
          <span class="badge badge-premium">Premium</span>
          {% endif %}
          {% if quest_data.progress.completed %}
          <span class="badge badge-completed">{% trans "Completa" %}</span>
          {% endif %}
        </div>
      </div>
      
      {% if not quest_data.progress.completed %}
      <div class="quest-progress">
        <div class="quest-progress-label">
          <span>{% trans "Progresso" %}</span>
          <span>{{ quest_data.progress.progress }} / {{ quest_data.quest.objective_target }}</span>
        </div>
        <div class="quest-progress-bar">
          <div class="quest-progress-fill" style="width: {% if quest_data.quest.objective_target > 0 %}{% widthratio quest_data.progress.progress quest_data.quest.objective_target 100 %}{% else %}0{% endif %}%"></div>
        </div>
        <div class="quest-objective-info">
          <i class="fas fa-bullseye"></i>
          <span>{% trans "Objetivo" %}: {{ quest_data.quest.get_objective_type_display }}</span>
        </div>
        {% if quest_data.quest.required_item_id %}
        <div class="quest-required-item {% if not quest_data.has_required_item %}missing-item{% endif %}">
          <img src="{% item_image_url quest_data.quest.required_item_id %}" 
               alt="{{ quest_data.quest.required_item_name }}"
               class="quest-required-item-icon"
               title="{{ quest_data.quest.required_item_name }}">
          <div class="quest-required-item-info">
            <div class="quest-required-item-name">
              <i class="fas fa-exclamation-triangle"></i> {% trans "Requer" %}: {{ quest_data.quest.required_item_name }}
            </div>
            <div class="quest-required-item-details">
              <span>x{{ quest_data.quest.required_item_amount }}</span>
              {% if quest_data.quest.required_item_enchant > 0 %}
              <span>+{{ quest_data.quest.required_item_enchant }}</span>
              {% endif %}
              {% if quest_data.bag_item_info %}
              <span style="color: rgba(255,255,255,0.7); margin-left: 0.5rem; font-size: 0.85rem;">
                ({% trans "Você tem" %}: x{{ quest_data.bag_item_info.quantity }}{% if quest_data.bag_item_info.enchant > 0 %} +{{ quest_data.bag_item_info.enchant }}{% endif %})
              </span>
              {% endif %}
              {% if not quest_data.has_required_item %}
              <span style="color: #ff6b6b; font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-times-circle"></i> {% trans "Item não encontrado ou quantidade insuficiente" %}
              </span>
              {% else %}
              <span style="color: var(--success-color); font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-check-circle"></i> {% trans "Item disponível" %}
              </span>
              {% endif %}
            </div>
          </div>
        </div>
        {% endif %}
      </div>
      {% endif %}
      
      <div class="quest-actions">
        <div class="quest-reward">
          <i class="fas fa-star"></i>
          <span>+{{ quest_data.quest.xp_reward }} XP</span>
        </div>
        {% if not quest_data.progress.completed %}
          {% if quest_data.can_complete %}
            {% if quest_data.quest.required_item_id %}
              {% if quest_data.has_required_item %}
              <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
                <i class="fas fa-check"></i> {% trans "Completar" %}
              </a>
              {% else %}
              <button class="btn-complete" disabled>
                <i class="fas fa-exclamation-triangle"></i> {% trans "Item requerido não encontrado" %}
              </button>
              {% endif %}
            {% else %}
            <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
              <i class="fas fa-check"></i> {% trans "Completar" %}
            </a>
            {% endif %}
          {% else %}
          <button class="btn-complete" disabled>
            <i class="fas fa-lock"></i> {% trans "Objetivo não atingido" %}
          </button>
          {% endif %}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>
  {% endif %}

  {% if seasonal_quests %}
  <div class="quest-section">
    <h2><i class="fas fa-calendar-alt"></i> {% trans "Missões de Temporada" %}</h2>
    {% for quest_data in seasonal_quests %}
    <div class="quest-card {% if quest_data.progress.completed %}completed{% endif %} {% if quest_data.quest.is_premium %}premium{% endif %}">
      <div class="quest-header">
        <div>
          <div class="quest-title">{{ quest_data.quest.title }}</div>
          <div class="quest-description">{{ quest_data.quest.description }}</div>
        </div>
        <div class="quest-badges">
          {% if quest_data.quest.is_premium %}
          <span class="badge badge-premium">Premium</span>
          {% endif %}
          {% if quest_data.progress.completed %}
          <span class="badge badge-completed">{% trans "Completa" %}</span>
          {% endif %}
        </div>
      </div>
      
      {% if not quest_data.progress.completed %}
      <div class="quest-progress">
        <div class="quest-progress-label">
          <span>{% trans "Progresso" %}</span>
          <span>{{ quest_data.progress.progress }} / {{ quest_data.quest.objective_target }}</span>
        </div>
        <div class="quest-progress-bar">
          <div class="quest-progress-fill" style="width: {% if quest_data.quest.objective_target > 0 %}{% widthratio quest_data.progress.progress quest_data.quest.objective_target 100 %}{% else %}0{% endif %}%"></div>
        </div>
        <div class="quest-objective-info">
          <i class="fas fa-bullseye"></i>
          <span>{% trans "Objetivo" %}: {{ quest_data.quest.get_objective_type_display }}</span>
        </div>
        {% if quest_data.quest.required_item_id %}
        <div class="quest-required-item {% if not quest_data.has_required_item %}missing-item{% endif %}">
          <img src="{% item_image_url quest_data.quest.required_item_id %}" 
               alt="{{ quest_data.quest.required_item_name }}"
               class="quest-required-item-icon"
               title="{{ quest_data.quest.required_item_name }}">
          <div class="quest-required-item-info">
            <div class="quest-required-item-name">
              <i class="fas fa-exclamation-triangle"></i> {% trans "Requer" %}: {{ quest_data.quest.required_item_name }}
            </div>
            <div class="quest-required-item-details">
              <span>x{{ quest_data.quest.required_item_amount }}</span>
              {% if quest_data.quest.required_item_enchant > 0 %}
              <span>+{{ quest_data.quest.required_item_enchant }}</span>
              {% endif %}
              {% if quest_data.bag_item_info %}
              <span style="color: rgba(255,255,255,0.7); margin-left: 0.5rem; font-size: 0.85rem;">
                ({% trans "Você tem" %}: x{{ quest_data.bag_item_info.quantity }}{% if quest_data.bag_item_info.enchant > 0 %} +{{ quest_data.bag_item_info.enchant }}{% endif %})
              </span>
              {% endif %}
              {% if not quest_data.has_required_item %}
              <span style="color: #ff6b6b; font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-times-circle"></i> {% trans "Item não encontrado ou quantidade insuficiente" %}
              </span>
              {% else %}
              <span style="color: var(--success-color); font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-check-circle"></i> {% trans "Item disponível" %}
              </span>
              {% endif %}
            </div>
          </div>
        </div>
        {% endif %}
      </div>
      {% endif %}
      
      <div class="quest-actions">
        <div class="quest-reward">
          <i class="fas fa-star"></i>
          <span>+{{ quest_data.quest.xp_reward }} XP</span>
        </div>
        {% if not quest_data.progress.completed %}
          {% if quest_data.can_complete %}
            {% if quest_data.quest.required_item_id %}
              {% if quest_data.has_required_item %}
              <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
                <i class="fas fa-check"></i> {% trans "Completar" %}
              </a>
              {% else %}
              <button class="btn-complete" disabled>
                <i class="fas fa-exclamation-triangle"></i> {% trans "Item requerido não encontrado" %}
              </button>
              {% endif %}
            {% else %}
            <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
              <i class="fas fa-check"></i> {% trans "Completar" %}
            </a>
            {% endif %}
          {% else %}
          <button class="btn-complete" disabled>
            <i class="fas fa-lock"></i> {% trans "Objetivo não atingido" %}
          </button>
          {% endif %}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>
  {% endif %}

  {% if special_quests %}
  <div class="quest-section">
    <h2><i class="fas fa-star"></i> {% trans "Missões Especiais" %}</h2>
    {% for quest_data in special_quests %}
    <div class="quest-card {% if quest_data.progress.completed %}completed{% endif %} {% if quest_data.quest.is_premium %}premium{% endif %}">
      <div class="quest-header">
        <div>
          <div class="quest-title">{{ quest_data.quest.title }}</div>
          <div class="quest-description">{{ quest_data.quest.description }}</div>
        </div>
        <div class="quest-badges">
          {% if quest_data.quest.is_premium %}
          <span class="badge badge-premium">Premium</span>
          {% endif %}
          {% if quest_data.progress.completed %}
          <span class="badge badge-completed">{% trans "Completa" %}</span>
          {% endif %}
        </div>
      </div>
      
      {% if not quest_data.progress.completed %}
      <div class="quest-progress">
        <div class="quest-progress-label">
          <span>{% trans "Progresso" %}</span>
          <span>{{ quest_data.progress.progress }} / {{ quest_data.quest.objective_target }}</span>
        </div>
        <div class="quest-progress-bar">
          <div class="quest-progress-fill" style="width: {% if quest_data.quest.objective_target > 0 %}{% widthratio quest_data.progress.progress quest_data.quest.objective_target 100 %}{% else %}0{% endif %}%"></div>
        </div>
        <div class="quest-objective-info">
          <i class="fas fa-bullseye"></i>
          <span>{% trans "Objetivo" %}: {{ quest_data.quest.get_objective_type_display }}</span>
        </div>
        {% if quest_data.quest.required_item_id %}
        <div class="quest-required-item {% if not quest_data.has_required_item %}missing-item{% endif %}">
          <img src="{% item_image_url quest_data.quest.required_item_id %}" 
               alt="{{ quest_data.quest.required_item_name }}"
               class="quest-required-item-icon"
               title="{{ quest_data.quest.required_item_name }}">
          <div class="quest-required-item-info">
            <div class="quest-required-item-name">
              <i class="fas fa-exclamation-triangle"></i> {% trans "Requer" %}: {{ quest_data.quest.required_item_name }}
            </div>
            <div class="quest-required-item-details">
              <span>x{{ quest_data.quest.required_item_amount }}</span>
              {% if quest_data.quest.required_item_enchant > 0 %}
              <span>+{{ quest_data.quest.required_item_enchant }}</span>
              {% endif %}
              {% if quest_data.bag_item_info %}
              <span style="color: rgba(255,255,255,0.7); margin-left: 0.5rem; font-size: 0.85rem;">
                ({% trans "Você tem" %}: x{{ quest_data.bag_item_info.quantity }}{% if quest_data.bag_item_info.enchant > 0 %} +{{ quest_data.bag_item_info.enchant }}{% endif %})
              </span>
              {% endif %}
              {% if not quest_data.has_required_item %}
              <span style="color: #ff6b6b; font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-times-circle"></i> {% trans "Item não encontrado ou quantidade insuficiente" %}
              </span>
              {% else %}
              <span style="color: var(--success-color); font-weight: 700; margin-left: 0.5rem; display: block; margin-top: 0.25rem;">
                <i class="fas fa-check-circle"></i> {% trans "Item disponível" %}
              </span>
              {% endif %}
            </div>
          </div>
        </div>
        {% endif %}
      </div>
      {% endif %}
      
      <div class="quest-actions">
        <div class="quest-reward">
          <i class="fas fa-star"></i>
          <span>+{{ quest_data.quest.xp_reward }} XP</span>
        </div>
        {% if not quest_data.progress.completed %}
          {% if quest_data.can_complete %}
            {% if quest_data.quest.required_item_id %}
              {% if quest_data.has_required_item %}
              <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
                <i class="fas fa-check"></i> {% trans "Completar" %}
              </a>
              {% else %}
              <button class="btn-complete" disabled>
                <i class="fas fa-exclamation-triangle"></i> {% trans "Item requerido não encontrado" %}
              </button>
              {% endif %}
            {% else %}
            <a href="{% url 'games:complete_quest' quest_data.quest.id %}" class="btn-complete">
              <i class="fas fa-check"></i> {% trans "Completar" %}
            </a>
            {% endif %}
          {% else %}
          <button class="btn-complete" disabled>
            <i class="fas fa-lock"></i> {% trans "Objetivo não atingido" %}
          </button>
          {% endif %}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>
  {% endif %}

  {% if not daily_quests and not weekly_quests and not seasonal_quests and not special_quests %}
  <div class="empty-quests">
    <i class="fas fa-inbox" style="font-size: 3rem; margin-bottom: 1rem; opacity: 0.5;"></i>
    <p>{% trans "Não há missões disponíveis no momento." %}</p>
  </div>
  {% endif %}
</div>
{% endblock %}

