{% extends 'base.html' %}

{% block title %}{{ shop.name }} - UMKM Pemagarsari{% endblock %}

{% block content %}
<section class="py-5">
    <div class="container">
        <!-- Shop Header -->
        <div class="bg-white rounded-4 shadow-sm p-4 p-md-5 mb-5 overflow-hidden position-relative">
            <div class="position-absolute top-0 end-0 p-4 opacity-10">
                <i class="fa-solid fa-shop fa-8x"></i>
            </div>
            <div class="row align-items-center position-relative z-1">
                <div class="col-md-auto mb-4 mb-md-0 text-center">
                    <div class="bg-emerald rounded-circle d-flex align-items-center justify-content-center text-white mx-auto" style="width: 120px; height: 120px; overflow: hidden;">
                        {% if shop.logo %}
                        <img src="{{ shop.logo.url }}" alt="{{ shop.name }}" class="img-fluid w-100 h-100 object-fit-cover">
                        {% else %}
                        <i class="fa-solid fa-shop fa-3x"></i>
                        {% endif %}
                    </div>
                </div>
                <div class="col-md ps-md-4">
                    <h1 class="fw-bold mb-2">{{ shop.name }}</h1>
                    <p class="text-muted mb-4">{{ shop.description }}</p>
                    <div class="d-flex flex-wrap gap-3">
                        <div class="d-flex align-items-center bg-light px-3 py-2 rounded-pill">
                            <i class="fa-brands fa-whatsapp text-success me-2"></i>
                            <span class="fw-bold">{{ shop.whatsapp_number }}</span>
                        </div>
                        <div class="d-flex align-items-center bg-light px-3 py-2 rounded-pill">
                            <i class="fa-solid fa-box text-emerald me-2"></i>
                            <span>{{ products.count }} Produk</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-auto mt-4 mt-md-0">
                    <a href="https://wa.me/{{ shop.whatsapp_number }}" target="_blank" class="btn btn-whatsapp rounded-pill px-4 py-2 w-100">
                        <i class="fa-brands fa-whatsapp me-2"></i>Chat Penjual
                    </a>
                </div>
            </div>
        </div>

        <!-- Shop Products -->
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h4 class="fw-bold mb-0">Produk dari {{ shop.name }}</h4>
        </div>

        <div class="row g-4">
            {% for product in products %}
            <div class="col-12 col-sm-6 col-lg-3">
                <div class="product-card">
                    <div class="product-img-wrapper">
                        {% if product.image %}
                        <img src="{{ product.image.url }}" alt="{{ product.name }}" class="img-fluid w-100 h-100 object-fit-cover">
                        {% else %}
                        <i class="fa-solid fa-image"></i>
                        {% endif %}
                    </div>
                    <div class="p-4">
                        <small class="text-muted d-block mb-2">{{ product.category.name }}</small>
                        <h5 class="fw-bold mb-3">
                            <a href="{% url 'product_detail' product.slug %}" class="text-decoration-none text-dark">{{ product.name }}</a>
                        </h5>
                        <div class="d-flex justify-content-between align-items-center">
                            <span class="product-price">Rp {{ product.price|floatformat:0 }}</span>
                            <a href="{{ product.whatsapp_link }}" target="_blank" class="btn btn-whatsapp btn-sm px-3">
                                <i class="fa-brands fa-whatsapp me-2"></i>Pesan
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            {% empty %}
            <div class="col-12 text-center py-5">
                <p class="text-muted">Toko ini belum menambahkan produk.</p>
            </div>
            {% endfor %}
        </div>
    </div>
</section>
{% endblock %}
