{% extends 'tops/base.html' %}
{% load static i18n %}

{% block title %}{% trans "Castle & Siege Ranking" %}{% endblock %}

{% block tops_content %}
<div class="tops-siege">
    <div class="tops-header-section">
        <h1>{% trans "Castle & Siege Ranking" %}</h1>
        <p class="lead">{% trans "Status dos castelos e cerco" %}</p>
    </div>

    <div class="tops-table-container">
        {% if castles %}
        <div class="tops-castles-grid">
            {% for castle in castles %}
            <div class="tops-castle-card">
                <div class="tops-castle-image-container">
                    {% if castle.image_path %}
                        <img src="{% static castle.image_path %}" alt="{{ castle.name }}" class="tops-castle-image">
                    {% else %}
                        <div class="tops-castle-image-placeholder">
                            <i class="fas fa-chess-rook"></i>
                            <span>{{ castle.name }}</span>
                        </div>
                    {% endif %}
                    <div class="tops-castle-overlay">
                        <div class="tops-castle-status">
                            {% if castle.siege_date %}
                                <span class="tops-badge warning">
                                    <i class="fas fa-fire"></i> {% trans "Cerco Ativo" %}
                                </span>
                            {% else %}
                                <span class="tops-badge secondary">
                                    <i class="fas fa-shield-alt"></i> {% trans "Sem Cerco" %}
                                </span>
                            {% endif %}
                        </div>
                    </div>
                </div>
                
                <div class="tops-castle-content">
                    <div class="tops-castle-header">
                        <h3 class="tops-castle-name">{{ castle.name }}</h3>
                    </div>
                    
                    <div class="tops-castle-info">
                        {% if castle.clan_name %}
                        <div class="tops-castle-owner">
                            <div class="tops-info-label">
                                <i class="fas fa-crown"></i> {% trans "Proprietário" %}
                            </div>
                            <div class="tops-flex">
                                {% if castle.clan_crest_image_base64 %}
                                    <img src="data:image/png;base64,{{ castle.clan_crest_image_base64 }}" alt="Owner Crest" class="tops-crest">
                                {% endif %}
                                <span class="tops-player-name">{{ castle.clan_name }}</span>
                            </div>
                        </div>
                        {% else %}
                        <div class="tops-castle-owner">
                            <div class="tops-info-label">
                                <i class="fas fa-crown"></i> {% trans "Proprietário" %}
                            </div>
                            <span class="tops-text-muted">{% trans "Sem proprietário" %}</span>
                        </div>
                        {% endif %}
                        
                        {% if castle.siege_date %}
                        <div class="tops-castle-siege">
                            <div class="tops-info-label">
                                <i class="fas fa-calendar-alt"></i> {% trans "Data do Cerco" %}
                            </div>
                            <span class="tops-badge info">{{ castle.siege_date|date:"d/m/Y H:i" }}</span>
                        </div>
                        {% endif %}
                        
                        {% if castle.stax %}
                        <div class="tops-castle-tax">
                            <div class="tops-info-label">
                                <i class="fas fa-coins"></i> {% trans "Taxa" %}
                            </div>
                            <span class="tops-badge success">{{ castle.stax }}%</span>
                        </div>
                        {% endif %}
                    </div>
                    
                    {% if castle.siege_participants %}
                    <div class="tops-castle-participants">
                        <div class="tops-info-label">
                            <i class="fas fa-users"></i> {% trans "Participantes do Cerco" %}
                        </div>
                        <div class="tops-participants-list">
                            {% for participant in castle.siege_participants %}
                            <div class="tops-participant">
                                <div class="tops-flex">
                                    {% if participant.clan_crest_image_base64 %}
                                        <img src="data:image/png;base64,{{ participant.clan_crest_image_base64 }}" alt="Participant Crest" class="tops-crest">
                                    {% endif %}
                                    <span>{{ participant.clan_name }}</span>
                                </div>
                            </div>
                            {% endfor %}
                        </div>
                    </div>
                    {% endif %}
                </div>
            </div>
            {% endfor %}
        </div>
        {% else %}
        <div class="tops-empty-state">
            <i class="fas fa-exclamation-triangle"></i>
            <h3>{% trans "Nenhum dado disponível" %}</h3>
            <p>{% trans "Não foi possível carregar os dados dos castelos no momento." %}</p>
        </div>
        {% endif %}
    </div>
</div>

<style>
/* ===== CASTLE & SIEGE - CSS MELHORADO ===== */

.tops-castles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-top: 20px;
}

.tops-castle-card {
    background: rgba(53, 47, 35, 0.9);
    border-radius: 20px;
    border: 1px solid rgba(230, 199, 125, 0.3);
    overflow: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
}

.tops-castle-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #e6c77d, #d1a44f, #9b7530, #e6c77d);
    border-radius: 22px;
    z-index: -1;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.tops-castle-card:hover::before {
    opacity: 0.5;
}

.tops-castle-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(230, 199, 125, 0.3);
    border-color: rgba(230, 199, 125, 0.6);
}

.tops-castle-image-container {
    position: relative;
    width: 100%;
    height: 250px;
    overflow: hidden;
}

.tops-castle-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.tops-castle-card:hover .tops-castle-image {
    transform: scale(1.1);
}

.tops-castle-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(230, 199, 125, 0.15), rgba(155, 117, 48, 0.15));
    color: #e6c77d;
    font-size: 16px;
    text-align: center;
}

.tops-castle-image-placeholder i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.8;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.tops-castle-image-placeholder span {
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.tops-castle-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 2;
}

.tops-castle-content {
    padding: 25px;
}

.tops-castle-header {
    margin-bottom: 20px;
    text-align: center;
}

.tops-castle-name {
    color: #e6c77d;
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #e6c77d, #d1a44f, #9b7530, #e6c77d);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
}

.tops-castle-info {
    margin-bottom: 20px;
}

.tops-castle-info > div {
    margin-bottom: 15px;
    padding: 12px 15px;
    background: rgba(230, 199, 125, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(230, 199, 125, 0.1);
    transition: all 0.3s ease;
}

.tops-castle-info > div:hover {
    background: rgba(230, 199, 125, 0.1);
    border-color: rgba(230, 199, 125, 0.3);
    transform: translateX(5px);
}

.tops-info-label {
    color: #e6c77d;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tops-info-label i {
    margin-right: 8px;
    opacity: 0.8;
}

.tops-castle-participants {
    border-top: 1px solid rgba(230, 199, 125, 0.2);
    padding-top: 20px;
}

.tops-participants-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tops-participant {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(230, 199, 125, 0.1);
    transition: all 0.3s ease;
}

.tops-participant:hover {
    background: rgba(230, 199, 125, 0.1);
    border-color: rgba(230, 199, 125, 0.3);
    transform: translateX(3px);
}

.tops-participant span {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

/* Animações */
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Responsividade */
@media (max-width: 768px) {
    .tops-castles-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .tops-castle-card {
        margin-bottom: 0;
    }
    
    .tops-castle-content {
        padding: 20px;
    }
    
    .tops-castle-name {
        font-size: 20px;
    }
    
    .tops-castle-image-container {
        height: 200px;
    }
}

@media (max-width: 576px) {
    .tops-castle-content {
        padding: 15px;
    }
    
    .tops-castle-name {
        font-size: 18px;
    }
    
    .tops-castle-image-container {
        height: 180px;
    }
    
    .tops-castle-overlay {
        top: 10px;
        right: 10px;
    }
}
</style>
{% endblock %} 