{% extends 'master.html' %}
{% load static %}
{% block content %}

<div class="container mt-5 mb-5" style="margin-top: 120px  !important;">
    <h2 class="text-center fw-bold mt-5 mb-4">Ad Categories</h2>
    
    {% if categories %}
        <div class="row g-4">
            {% for category in categories %}
                <div class="col-md-4 col-lg-3">
                    <div class="category-card shadow-sm">
                        <a href="{% url 'category_detail' category.id %}" class="text-decoration-none">
                            <div class="category-img-container">
                                <img src="{{ category.image.url }}" class="img-fluid rounded" alt="{{ category.name }}">
                            </div>
                            <div class="category-info text-center p-3">
                                <h5 class="fw-semibold text-dark">{{ category.name }}</h5>
                            </div>
                        </a>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% else %}
        <p class="text-center text-muted">No categories available.</p>
    {% endif %}
</div>

<!-- Custom Styles -->
<style>
.category-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.2);
}

.category-img-container {
    overflow: hidden;
    border-bottom: 1px solid #ddd;
}

.category-img-container img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}

.category-card:hover .category-img-container img {
    transform: scale(1.05);
}

.category-info {
    padding: 15px;
}

.category-info h5 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

@media (max-width: 768px) {
    .category-info h5 {
        font-size: 1rem;
    }
}
</style>

{% endblock %}
