<div class="col-md-3">
    <div class="card mx-0 tour-card position-relative">
        {% if tour.subcategory and tour.subcategory.parent_category %}
            <span class="badge position-absolute top-0 end-0 m-2 rounded-pill px-3 py-2 z-10 
                {% if tour.subcategory.parent_category.name == 'Economy' %}
                    badge-economy text-black
                {% elif tour.subcategory.parent_category.name == 'Value' %}
                    badge-value text-dark
                {% elif tour.subcategory.parent_category.name == 'Luxury' %}
                    badge-luxury text-white
                {% else %}
                badge-value text-dark
                {% endif %}">
                {{ tour.subcategory.parent_category.name }}
            </span>
        {% endif %}
        {% if tour.image %}
            <img src="{{ url_for('static', filename='uploads/' + tour.image) }}" class="card-img-top" alt="{{ tour.title }}">
        {% else %}
            <img src="{{ url_for('static', filename='uploads/spotting-the-sri-lankan-leopard-slider-11.avif') }}" class="card-img-top" alt="{{ tour.title }}">
        {% endif %}
        <div class="card-body">
            <div class="d-flex justify-content-between align-items-start mb-1">
                <h5 class="card-title mb-0">{{ tour.title }}</h5>
                <div class="views-count" alt="Views">
                    <i class="fa-regular fa-eye me-1"></i>
                    <span >{{ tour.views|default(0) }}</span>
                </div>
            </div>
            {% if tour.subcategory %}
                <p class="tour-subcategory mb-3">{{ tour.subcategory.name }}</p>
            {% endif %}
            <div class="d-flex justify-content-between align-items-center">
                <a href="{{ url_for('main.request_quote') }}" class="btn rounded-pill primary_btn">Request a Quote</a>
                <a href="{{ url_for('main.tour_detail', slug=tour.slug) }}" class="btn btn-link btn-sm">Read More</a>
            </div>
        </div>
    </div>
</div>

<style>
.views-count {
    font-size: 0.85rem;
    color: #6B7280;
    background-color: #F3F4F6;
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.views-count i {
    font-size: 0.9rem;
}

.tour-subcategory {
    font-size: 0.8rem;
    color: #6B7280;
    
    margin-top: -2px;
}

.tour-card {
    overflow: hidden;
}

.tour-card .badge {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    font-weight: 500;
}

.card-img-top {
    height: 200px;
    object-fit: cover;
}

.badge-economy {
    background-color: #dafb90;
}

.badge-value {
    background-color: #ffc107;
}

.badge-luxury {
    background-color: #6610f2;
}
</style>