<?php
$logo = $r['logo'] ?? $r['cover_image'] ?? '';
$imgUrl = $logo ? base_url($logo) : asset('images/company-hero.svg');
?>
<div class="mj-card h-100 company-card" data-aos="fade-up">
  <a href="<?= base_url('company.php?id='.(int)$r['id']) ?>" class="d-block position-relative">
    <img class="mj-card-img" src="<?= e($imgUrl) ?>" alt="<?= e($r['name'] ?? 'Company') ?>">
    <?php if (!empty($r['is_verified'])): ?><span class="mj-badge good position-absolute top-0 start-0 m-3"><i class="bi bi-patch-check-fill"></i>Verified</span><?php endif; ?>
  </a>
  <div class="p-3">
    <h5 class="fw-bold mb-1"><a href="<?= base_url('company.php?id='.(int)$r['id']) ?>" class="text-decoration-none text-dark"><?= e($r['name'] ?? 'Company') ?></a></h5>
    <p class="text-muted small mb-2"><i class="bi bi-geo-alt me-1"></i><?= e(($r['city'] ?? '') ?: ($r['country'] ?? 'Global')) ?> <?= !empty($r['phone']) ? '• '.e($r['phone']) : '' ?></p>
    <div class="d-flex justify-content-between align-items-center"><span class="mj-badge"><i class="bi bi-star-fill"></i><?= number_format((float)($r['rating_avg'] ?? 0),1) ?> (<?= (int)($r['rating_count'] ?? 0) ?>)</span><a class="btn btn-sm btn-primary" href="<?= base_url('quotation-request.php?company_id='.(int)$r['id']) ?>">Request Quote</a></div>
  </div>
</div>
