<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h2 class="mb-0">Sepet Yönetimi</h2>
        <div class="d-flex gap-2 align-items-center">
            <form class="d-flex" action="/admin/content/carts" method="GET">
                <input type="search" name="search" class="form-control form-control-sm me-2"
                    placeholder="User ID ile Ara..." value="{{ .Search }}">
                <button class="btn btn-sm btn-outline-secondary" type="submit"><i class="bi bi-search"></i></button>
            </form>
        </div>
    </div>

    <div class="card border-0 shadow-sm">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead class="bg-light">
                    <tr>
                        <th class="ps-3 border-0 text-muted small text-uppercase">ID</th>
                        <th class="border-0 text-muted small text-uppercase">Kullanıcı (User ID)</th>
                        <th class="border-0 text-muted small text-uppercase">Ürün Sayısı (Çeşit)</th>
                        <th class="border-0 text-muted small text-uppercase">Oluşturulma Tarihi</th>
                        <th class="border-0 text-muted small text-uppercase text-end pe-3">İşlemler</th>
                    </tr>
                </thead>
                <tbody>
                    {{ range .Carts }}
                    <tr>
                        <td class="ps-3"><span class="text-secondary fw-medium">#{{ .ID }}</span></td>
                        <td>
                            <div class="d-flex align-items-center">
                                <div class="ms-2">
                                    <div class="fw-semibold text-dark">Kullanıcı ID: {{ .UserID }}</div>
                                </div>
                            </div>
                        </td>
                        <td>
                            <span class="badge bg-info text-dark rounded-pill">{{ len .Items }} çeşit ürün
                                eklendi</span>
                        </td>
                        <td class="text-secondary small">
                            {{ .CreatedAt.Format "02.01.2006 15:04" }}
                        </td>
                        <td class="text-end pe-3">
                            <form action="/admin/carts/{{ .ID }}/delete" method="POST" class="d-inline"
                                onsubmit="return confirm('Bu sepeti silmek istediğinize emin misiniz?');">
                                <button type="submit" class="btn btn-sm btn-outline-danger" title="Sil">
                                    <i class="bi bi-trash"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    {{ else }}
                    <tr>
                        <td colspan="5" class="text-center py-5 text-muted">
                            <i class="bi bi-cart-x fs-1 d-block mb-2"></i>
                            Henüz kullanıcılar sepet oluşturmamış.
                        </td>
                    </tr>
                    {{ end }}
                </tbody>
            </table>
        </div>
    </div>
</div>