{#
// inputs:
// - product: object - product data object
// - layout:  string - one of [grid, list, table]
// - exclude: array  - indicates which content should be excluded from the template (default: [])
#}

{% set product = inputs.product %}
{% set layout = inputs.layout %}
{% set exclude = inputs.exclude|default([]) %}

{% set root_classes = classnames('product-card') %}

{% if layout %}
    {% set root_classes = classnames(root_classes, 'product-card--layout--'~layout) %}
{% endif %}

<div class="{{ root_classes }}">
    <div class="product-card__actions-list">
        <button class="product-card__action product-card__action--quickview" type="button" aria-label="Quick view">
            {{ svg('quickview-16.svg') }}
        </button>
        {% if not ('actions' in exclude) %}
            <button class="product-card__action product-card__action--wishlist" type="button" aria-label="Add to wish list">
                {{ svg('wishlist-16.svg') }}
            </button>
            <button class="product-card__action product-card__action--compare" type="button" aria-label="Add to compare">
                {{ svg('compare-16.svg') }}
            </button>
        {% endif %}
    </div>

    <div class="product-card__image">
        <div class="image image--type--product">
            <a href="product-full.html" class="image__body">
                <img class="image__tag" src="{{ image(product.images[0], {size: 245}) }}" alt="">
            </a>
        </div>

        {% if not ('status-badge' in exclude) %}
            {% include '/components/status-badge.twig' with {inputs: {
                classes: 'product-card__fit',
                style: 'success',
                text: 'Part Fit for 2011 Ford Focus S',
                tooltip: 'Part Fit for 2011 Ford Focus S',
                icon: 'success',
            }} %}
        {% endif %}
    </div>

    <div class="product-card__info">
        {% if not ('meta' in exclude) %}
            <div class="product-card__meta"><span class="product-card__meta-title">SKU:</span> {{ product.sku }}</div>
        {% endif %}

        <div class="product-card__name">
            <div>
                {% if product.badges %}
                    <div class="product-card__badges">
                        {% for badge in product.badges %}
                            <div class="{{ classnames('tag-badge', 'tag-badge--'~badge) }}">{{ badge }}</div>
                        {% endfor %}
                    </div>
                {% endif %}

                <a href="product-full.html">{{ product.name }}</a>
            </div>
        </div>

        <div class="product-card__rating">
            {% include '/components/rating.twig' with {inputs: {
                classes: 'product-card__rating-stars',
                rating: product.rating
            }} %}
            <div class="product-card__rating-label">{{ product.rating }} on {{ product.reviews }} reviews</div>
        </div>

        {% if not ('features' in exclude) %}
            <div class="product-card__features">
                <ul>
                    <li>Speed: 750 RPM</li>
                    <li>Power Source: Cordless-Electric</li>
                    <li>Battery Cell Type: Lithium</li>
                    <li>Voltage: 20 Volts</li>
                    <li>Battery Capacity: 2 Ah</li>
                </ul>
            </div>
        {% endif %}
    </div>

    <div class="product-card__footer">
        <div class="product-card__prices">
            {% if product.compareAtPrice %}
                <div class="product-card__price product-card__price--new">{{ product.price|currency }}</div>
                <div class="product-card__price product-card__price--old">{{ product.compareAtPrice|currency }}</div>
            {% else %}
                <div class="product-card__price product-card__price--current">{{ product.price|currency }}</div>
            {% endif %}
        </div>
        {% if not ('buttons' in exclude) %}
            <button class="product-card__addtocart-icon" type="button" aria-label="Add to cart">
                {{ svg('cart-20.svg') }}
            </button>
            {% if not ('list-buttons' in exclude) %}
                <button class="product-card__addtocart-full" type="button">
                    Add to cart
                </button>
                <button class="product-card__wishlist" type="button">
                    {{ svg('wishlist-16.svg') }}
                    <span>Add to wishlist</span>
                </button>
                <button class="product-card__compare" type="button">
                    {{ svg('compare-16.svg') }}
                    <span>Add to compare</span>
                </button>
            {% endif %}
        {% endif %}
    </div>
</div>
