{% extends "base.html" %}

{% block title %}Ethio-gebeya | Marketplace{% endblock %}

{% block content %}
<main class="container py-4">
    <h1 class="mb-4">Welcome to Ethio-gebeya</h1>
    
    <div class="row">
        {% for product in products %}
        <div class="col-md-4 mb-4">
            <div class="card h-100">
                <div class="card-body">
                    <h5 class="card-title">{{ product.name }}</h5>
                    <p class="card-text text-muted">{{ product.description|truncatewords:20 }}</p>
                    <p class="card-text fw-bold">Price: {{ product.price }} ETB</p>
                    <a href="{% url 'product_detail' product.pk %}" class="btn btn-primary">View Details</a>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>

    <div class="mt-4">
        {% if user.is_authenticated %}
        <a class="btn btn-secondary" href="{% url 'dashboard' %}">Open Dashboard</a>
        {% else %}
        <a class="btn btn-primary" href="{% url 'login' %}">Sign In</a>
        {% endif %}
    </div>
</main>
{% endblock %}