<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>
<div class="d-flex justify-content-between align-items-center mb-3">
    <h3>آراء العملاء</h3>
    <a href="/admin/site-testimonials/create" class="btn btn-dark btn-sm"><?= lang('App.add_new') ?></a>
</div>
<div class="row">
<?php foreach ($testimonials as $t): ?>
    <div class="col-md-4 mb-3">
        <div class="card p-3">
            <div class="d-flex align-items-center gap-2 mb-2">
                <?php if (!empty($t['photo'])): ?>
                    <img src="<?= base_url('uploads/testimonials/' . $t['photo']) ?>" style="width:40px;height:40px;border-radius:50%;object-fit:cover;">
                <?php endif; ?>
                <b><?= esc($t['client_name']) ?></b>
            </div>
            <div class="text-warning mb-2"><?= str_repeat('⭐', (int) $t['rating']) ?></div>
            <p class="small"><?= esc($t['content']) ?></p>
            <div>
                <a href="/admin/site-testimonials/<?= $t['id'] ?>/edit" class="btn btn-sm btn-outline-primary"><?= lang('App.edit') ?></a>
                <form method="post" action="/admin/site-testimonials/<?= $t['id'] ?>/delete" class="d-inline" onsubmit="return confirm('?')">
                    <?= csrf_field() ?><button class="btn btn-sm btn-outline-danger"><?= lang('App.delete') ?></button>
                </form>
            </div>
        </div>
    </div>
<?php endforeach; ?>
<?php if (empty($testimonials)): ?><p class="text-muted"><?= lang('App.no_data') ?></p><?php endif; ?>
</div>
<?= $this->endSection() ?>
