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

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1><i class="bi bi-box-seam"></i> {{ part.name }}</h1>
    <a href="{{ url_for('parts.edit', id=part.id) }}" class="btn btn-outline-primary"><i class="bi bi-pencil"></i> Modifier</a>
</div>

{% if part.is_low_stock %}
<div class="alert alert-danger">
    <i class="bi bi-exclamation-triangle"></i> <strong>Stock bas !</strong>
    Il reste {{ part.quantity }} {{ part.unit }} (minimum : {{ part.min_quantity }}).
</div>
{% endif %}

<div class="card mb-3">
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <table class="table table-sm mb-0">
                    <tr><th>Référence</th><td>{{ part.reference or '—' }}</td></tr>
                    <tr><th>Catégorie</th><td><span class="badge bg-secondary">{{ part.category }}</span></td></tr>
                    <tr><th>Unité</th><td>{{ part.unit }}</td></tr>
                    <tr><th>Fournisseur</th><td>{{ part.supplier or '—' }}</td></tr>
                </table>
            </div>
            <div class="col-md-6">
                <table class="table table-sm mb-0">
                    <tr><th>Quantité en stock</th><td class="{% if part.is_low_stock %}text-danger fw-bold{% endif %}">{{ part.quantity }} {{ part.unit }}</td></tr>
                    <tr><th>Quantité minimale</th><td>{{ part.min_quantity }} {{ part.unit }}</td></tr>
                    <tr><th>Prix unitaire</th><td>{{ "%.2f"|format(part.unit_price) if part.unit_price else '—' }} €</td></tr>
                    <tr><th>Emplacement</th><td>{{ part.location or '—' }}</td></tr>
                </table>
            </div>
        </div>
    </div>
</div>

{% if part.description %}
<div class="card">
    <div class="card-header"><i class="bi bi-file-text"></i> Description</div>
    <div class="card-body">{{ part.description }}</div>
</div>
{% endif %}
{% endblock %}