{% extends "base.html" %}

{% block title %}Arama Sonuçları - FaturaYol{% endblock %}
{% block page_title %}"{{ query }}" için Arama Sonuçları{% endblock %}

{% block content %}
<div class="mb-5">
    <h5 class="fw-bold mb-3"><i class="bi bi-building me-2 text-primary"></i>Firmalar ({{ firmalar|length }})</h5>
    <div class="row">
        {% for firma in firmalar %}
        <div class="col-md-4 mb-3">
            <div class="card border-0 shadow-sm">
                <div class="card-body">
                    <h6 class="fw-bold mb-1">{{ firma.ad }}</h6>
                    <p class="small text-muted mb-2">VN: {{ firma.vergi_no }}</p>
                    <a href="{% url 'firma_detay' firma.pk %}" class="btn btn-sm btn-outline-primary rounded-pill">Detaya Git</a>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12 text-muted">Eşleşen firma bulunamadı.</div>
        {% endfor %}
    </div>
</div>

<div>
    <h5 class="fw-bold mb-3"><i class="bi bi-file-earmark-text me-2 text-primary"></i>Faturalar ({{ faturalar|length }})</h5>
    <div class="card border-0 shadow-sm">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead>
                    <tr>
                        <th class="ps-4">Fatura No</th>
                        <th>Firma</th>
                        <th>Tarih</th>
                        <th>Genel Toplam</th>
                        <th class="text-end pe-4">İşlem</th>
                    </tr>
                </thead>
                <tbody>
                    {% for fatura in faturalar %}
                    <tr>
                        <td class="ps-4 fw-medium">{{ fatura.fatura_no }}</td>
                        <td>{{ fatura.firma.ad }}</td>
                        <td>{{ fatura.tarih|date:"d.m.Y" }}</td>
                        <td class="fw-bold">₺{{ fatura.genel_toplam }}</td>
                        <td class="text-end pe-4">
                            <a href="{% url 'fatura_detay' fatura.pk %}" class="btn btn-sm btn-light rounded-pill">İncele</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="5" class="text-center py-4 text-muted">Eşleşen fatura bulunamadı.</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
