{% extends "base.html" %}
{% block title %}Entreprises — GMAO Collège{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-3">
    <h2 class="mb-0 h5"><i class="bi bi-building"></i> Entreprises</h2>
    <a href="{{ url_for('companies.create') }}" class="btn btn-primary btn-sm">
        <i class="bi bi-plus-lg"></i> <span class="d-none d-sm-inline">Nouvelle</span><span class="d-sm-none">+</span>
    </a>
</div>

<div class="row g-2 g-md-3">
{% for company in companies %}
<div class="col-6 col-md-6 col-lg-4">
    <div class="card h-100 border-0 shadow-sm {% if not company.is_active %}opacity-50{% endif %}">
        <div class="card-body py-2 px-3">
            <h6 class="card-title mb-1">
                {{ company.name }}
                {% if not company.is_active %}<span class="badge bg-secondary" style="font-size:0.6rem;">Inactive</span>{% endif %}
            </h6>
            {% if company.trade_name %}<p class="text-muted mb-1" style="font-size:0.8rem;">{{ company.trade_name }}</p>{% endif %}
            <p class="mb-1"><span class="badge bg-info" style="font-size:0.7rem;">{{ company.specialty }}</span></p>
            {% if company.contact_name %}<p class="mb-1" style="font-size:0.8rem;"><i class="bi bi-person"></i> {{ company.contact_name }}</p>{% endif %}
            {% if company.contact_phone %}
            <p class="mb-0" style="font-size:0.85rem;">
                <a href="tel:{{ company.contact_phone }}" class="text-decoration-none"><i class="bi bi-telephone"></i> {{ company.contact_phone }}</a>
            </p>
            {% endif %}
        </div>
        <div class="card-footer bg-transparent py-1">
            <a href="{{ url_for('companies.detail', id=company.id) }}" class="btn btn-sm btn-outline-primary">Voir</a>
        </div>
    </div>
</div>
{% endfor %}
</div>
{% endblock %}