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

{% block title %}{{ product.title }} - ShinaStore{% endblock %}

{% block content %}
<div class="container py-5">
    <nav aria-label="breadcrumb" class="mb-4">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'index' %}" class="text-decoration-none text-muted">Home</a></li>
            <li class="breadcrumb-item"><a href="{% url 'index' %}?category={{ product.category.id }}" class="text-decoration-none text-muted">{{ product.category.name }}</a></li>
            <li class="breadcrumb-item active" aria-current="page">{{ product.title }}</li>
        </ol>
    </nav>

    <div class="row g-5">
        <div class="col-md-6">
            <div class="card border-0 shadow-sm overflow-hidden" style="border-radius: 24px;">
                <img src="{{ product.image_url }}" class="img-fluid w-100" alt="{{ product.title }}" style="min-height: 500px; object-fit: cover;">
            </div>
        </div>
        <div class="col-md-6">
            <div class="ps-md-4">
                <span class="badge bg-rose mb-3 px-3 py-2" style="background-color: #F43F5E;">{{ product.category.name }}</span>
                <h1 class="display-5 fw-bold text-slate mb-3" style="font-family: 'Montserrat', sans-serif;">{{ product.title }}</h1>
                <p class="h3 text-rose fw-bold mb-4" style="color: #F43F5E;">${{ product.price }}</p>
                
                <div class="mb-4">
                    <h5 class="fw-bold mb-3">Description</h5>
                    <p class="text-muted leading-relaxed">
                        {{ product.description }}
                    </p>
                </div>

                <div class="mb-4">
                    <p class="text-muted">Stock availability: 
                        {% if product.stock > 0 %}
                            <span class="text-success fw-bold">In Stock ({{ product.stock }})</span>
                        {% else %}
                            <span class="text-danger fw-bold">Out of Stock</span>
                        {% endif %}
                    </p>
                </div>

                <div class="d-grid gap-2">
                    {% if product.stock > 0 %}
                        <a href="{% url 'add_to_cart' product.pk %}" class="btn btn-lg py-3 fw-bold shadow-sm" style="background-color: #0F172A; color: white; border-radius: 12px; transition: transform 0.2s;">
                            Add to Cart
                        </a>
                    {% else %}
                        <button class="btn btn-lg btn-secondary py-3 fw-bold" disabled style="border-radius: 12px;">
                            Out of Stock
                        </button>
                    {% endif %}
                </div>

                <div class="mt-5 p-4 bg-light" style="border-radius: 16px; border-left: 4px solid #F43F5E;">
                    <div class="d-flex align-items-center">
                        <div class="me-3">
                            <i class="bi bi-shield-check h3 text-rose"></i>
                        </div>
                        <div>
                            <h6 class="mb-1 fw-bold">Secure Checkout</h6>
                            <p class="mb-0 small text-muted">100% Secure payment with 256-bit SSL encryption.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Related Products -->
    {% if related_products %}
    <div class="mt-5 pt-5">
        <h3 class="fw-bold mb-4" style="font-family: 'Montserrat', sans-serif;">You might also like</h3>
        <div class="row g-4">
            {% for rel in related_products %}
            <div class="col-md-3">
                <div class="card h-100 border-0 shadow-sm product-card" style="border-radius: 20px; transition: all 0.3s ease;">
                    <a href="{% url 'product_detail' rel.pk %}" class="text-decoration-none">
                        <img src="{{ rel.image_url }}" class="card-img-top" alt="{{ rel.title }}" style="height: 250px; object-fit: cover; border-top-left-radius: 20px; border-top-right-radius: 20px;">
                        <div class="card-body p-3">
                            <h6 class="text-slate fw-bold mb-1">{{ rel.title }}</h6>
                            <p class="text-rose fw-bold mb-0">${{ rel.price }}</p>
                        </div>
                    </a>
                </div>
            </div>
            {% endfor %}
        </div>
    </div>
    {% endif %}
</div>

<style>
    .product-card:hover {
        transform: translateY(-10px);
        box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
    }
    .bg-rose { background-color: #F43F5E; }
    .text-rose { color: #F43F5E; }
    .text-slate { color: #0F172A; }
</style>
{% endblock %}
