<?php
declare(strict_types=1);
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/includes/functions.php';
$list = testimonials_all();
$pageTitle = 'Testimonials — ' . setting('company_name', SITE_NAME);
$current = 'testimonials';
$breadcrumbTitle = 'Testimonials';
require __DIR__ . '/includes/head.php';
require __DIR__ . '/includes/preloader.php';
require __DIR__ . '/includes/offcanvas.php';
require __DIR__ . '/includes/header.php';
require __DIR__ . '/includes/breadcrumb.php';
?>
  <main>
    <section class="ot-space">
      <div class="container">
        <style>
          .testi-pro-card {
            background: #fff;
            border: 1px solid #e7edf5;
            border-radius: 16px;
            padding: 26px 24px;
            height: 100%;
            box-shadow: 0 10px 28px rgba(4, 34, 62, 0.06);
            transition: all 0.25s ease;
          }

          .testi-pro-card:hover {
            transform: translateY(-4px);
            border-color: var(--ot-theme-color);
            box-shadow: 0 14px 32px rgba(4, 34, 62, 0.12);
          }

          .testi-pro-stars {
            color: #f2b01e;
            letter-spacing: 2px;
            font-size: 16px;
          }

          .testi-pro-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid #fff;
            box-shadow: 0 4px 10px rgba(4, 34, 62, 0.16);
          }
        </style>

        <div class="ot-title-area text-center mb-50">
          <span class="ot-sec-subtitle">Testimonials</span>
          <h3 class="ot-sec-title ot-text-anime-3">What Our Customers Say</h3>
          <p class="ot-sec-text mx-auto" style="max-width:760px;">
            Real feedback from homeowners and businesses who chose Bhatt Enterprises
            for reliable solar installation and long-term support.
          </p>
        </div>

        <div class="row gy-4">
          <?php if ($list): ?>
            <?php foreach ($list as $t): ?>
              <?php
                $rating = max(1, min(5, (int)($t['rating'] ?? 5)));
                $name = trim((string)($t['client_name'] ?? 'Happy Customer'));
                if ($name === '') {
                    $name = 'Happy Customer';
                }
              ?>
              <div class="col-md-6 col-lg-4">
                <div class="testi-pro-card">
                  <div class="testi-pro-stars mb-15"><?= str_repeat('★', $rating) ?></div>
                  <p class="ot-sec-text mb-25"><?= h((string)($t['content'] ?? 'Excellent solar service and support.')) ?></p>
                  <div class="d-flex align-items-center gap-3">
                    <img src="<?= asset('assets/img/about/ab-user-1-1.png') ?>" alt="<?= h($name) ?>" class="testi-pro-avatar">
                    <div>
                      <h4 class="ot-box-title mb-0"><?= h($name) ?></h4>
                      <p class="text-muted small mb-0">Verified Client</p>
                    </div>
                  </div>
                </div>
              </div>
            <?php endforeach; ?>
          <?php else: ?>
            <div class="col-12">
              <div class="alert alert-info text-center mb-0">
                Testimonials will appear here once you add them from the admin panel.
              </div>
            </div>
          <?php endif; ?>
        </div>
      </div>
    </section>
  </main>
<?php require __DIR__ . '/includes/footer.php'; ?>
