{% extends 'base.html' %}
{% load static %}

{% block content %}
<div class="artist-header py-5 bg-black border-bottom border-secondary position-relative">
    <div class="container py-4">
        <div class="row align-items-center">
            <div class="col-md-3 text-center text-md-start mb-4 mb-md-0">
                <div class="rounded-circle overflow-hidden border border-warning border-3 shadow-lg" style="width: 200px; height: 200px; margin: 0 auto;">
                    {% if artist.image_url %}
                    <img src="{{ artist.image_url }}" alt="{{ artist.name }}" class="img-fluid h-100 w-100 object-fit-cover">
                    {% else %}
                    <div class="h-100 w-100 bg-dark d-flex align-items-center justify-content-center">
                        <i class="bi bi-person-fill display-1 text-secondary"></i>
                    </div>
                    {% endif %}
                </div>
            </div>
            <div class="col-md-9 text-center text-md-start">
                <span class="badge bg-dark border border-warning text-warning px-3 py-2 mb-2">FEATURED ARTIST</span>
                <h1 class="display-3 fw-bold text-white mb-2">{{ artist.name }}</h1>
                <p class="h4 text-warning mb-3 fw-light">{{ artist.style }} Master</p>
                <p class="text-secondary mb-0 lead col-lg-10">{{ artist.description }}</p>
            </div>
        </div>
    </div>
</div>

<div class="container py-5">
    <div class="d-flex justify-content-between align-items-end mb-4">
        <div>
            <h2 class="fw-bold text-white mb-0">SIGNATURE <span class="text-warning">BANK</span></h2>
            <p class="text-secondary mb-0">Choose a preset to explore the 64-bit signal chain.</p>
        </div>
        <div class="text-end d-none d-md-block">
            <span class="badge bg-black border border-secondary text-secondary">BANK_ID: {{ artist.id|add:100 }}</span>
        </div>
    </div>

    <div class="row g-4">
        {% for preset in presets %}
        <div class="col-md-4">
            <div class="card bg-dark border-secondary h-100 transition-all hover-glow overflow-hidden">
                <div class="card-body p-4">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <h4 class="text-white mb-0">{{ preset.title }}</h4>
                        <i class="bi bi-soundwave text-warning fs-4"></i>
                    </div>
                    <p class="text-secondary small mb-4">{{ preset.description|truncatewords:25 }}</p>
                    
                    <div class="mb-4">
                        <div class="d-flex flex-wrap gap-1">
                            {% for step in preset.steps.all|slice:":3" %}
                            <span class="badge bg-black border border-secondary text-secondary" style="font-size: 0.6rem;">{{ step.module.name }}</span>
                            {% endfor %}
                            {% if preset.steps.count > 3 %}
                            <span class="badge bg-black border border-secondary text-secondary" style="font-size: 0.6rem;">+{{ preset.steps.count|add:"-3" }}</span>
                            {% endif %}
                        </div>
                    </div>

                    <a href="{% url 'preset_detail' preset.slug %}" class="btn btn-warning w-100 fw-bold stretched-link">VIEW CHAIN</a>
                </div>
                <div class="card-footer bg-black border-secondary py-2">
                    <div class="d-flex justify-content-between align-items-center">
                        <small class="text-secondary fw-bold" style="font-size: 0.7rem;">STATUS: READY</small>
                        <small class="text-info fw-bold" style="font-size: 0.7rem;">LATENCY: 2.9ms</small>
                    </div>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12">
            <div class="text-center py-5 bg-dark border border-secondary rounded">
                <p class="text-secondary mb-0">No presets found for this artist.</p>
            </div>
        </div>
        {% endfor %}
    </div>
</div>

<style>
.hover-glow:hover {
    border-color: #FFD700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.1);
    transform: translateY(-5px);
}
.transition-all {
    transition: all 0.3s ease;
}
</style>
{% endblock %}