<?php
/**
 * @var array $results
 * @var string $query
 */
?>
<?php if (!empty($results)): ?>
    <div class="search-results-dropdown">
        <?php foreach ($results as $customer): ?>
            <a href="<?= url('customers/show/' . $customer->id) ?>" class="search-result-item">
                <div class="d-flex align-items-center gap-3">
                    <?php if (!empty($customer->photo)): ?>
                        <img src="<?= uploadUrl($customer->photo) ?>" alt="" class="rounded-circle" 
                             width="40" height="40" style="object-fit:cover;">
                    <?php else: ?>
                        <div class="rounded-circle d-flex align-items-center justify-content-center" 
                             style="width:40px;height:40px;background:var(--gold);color:#000;font-size:16px;font-weight:600;flex-shrink:0;">
                            <?= strtoupper(substr($customer->first_name ?? '?', 0, 1) . substr($customer->last_name ?? '', 0, 1)) ?>
                        </div>
                    <?php endif; ?>
                    <div class="flex-grow-1 min-width-0">
                        <div class="fw-medium text-truncate">
                            <?= e($customer->first_name . ' ' . $customer->last_name) ?>
                        </div>
                        <div class="small text-muted text-truncate">
                            <?php if (!empty($customer->email)): ?>
                                <i class="fas fa-envelope me-1"></i><?= e($customer->email) ?>
                            <?php endif; ?>
                            <?php if (!empty($customer->phone)): ?>
                                <i class="fas fa-phone ms-2 me-1"></i><?= e($customer->phone) ?>
                            <?php endif; ?>
                        </div>
                    </div>
                    <i class="fas fa-chevron-right text-gold"></i>
                </div>
            </a>
        <?php endforeach; ?>
    </div>
<?php else: ?>
    <div class="search-results-empty text-center text-muted py-3">
        <i class="fas fa-search fa-2x mb-2"></i>
        <p class="mb-0">No customers found matching "<?= e($query) ?>"</p>
    </div>
<?php endif; ?>
