<?php
declare(strict_types=1);
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/includes/functions.php';
$q = trim((string)($_GET['q'] ?? ''));
$services = services_all();
if ($q !== '') {
    $services = array_values(array_filter($services, static function ($s) use ($q) {
        return stripos((string)$s['title'], $q) !== false
            || stripos((string)($s['short_description'] ?? ''), $q) !== false;
    }));
}
$pageTitle = 'Services — ' . setting('company_name', SITE_NAME);
$current = 'services';
$breadcrumbTitle = 'Services';
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>

 
    <!-- breadcrumb-area end -->

    <section class="ot-service-area service-inner-style ot-space ot-bg-style" data-background="<?= asset('assets/img/bg/service-bg-5-1.jpg') ?>">
      <div class="container">
       
        <div class="ot-service-wrapp">
          <div class="row gy-30">
            <?php $i = 0; foreach ($services as $s): $i++; ?>
              <div class="col-xl-4 col-md-6">
                <div class="ot-service-box5">
                  <div class="ot-service-img ot-img-hover">
                    <img src="<?= h(img_url($s['image_path'] ?? null)) ?>" alt="">
                  </div>
                  <div class="ot-service-mask-wrapp p-relative">
                    <div class="ot-service-icon"><i class="<?= h((string)$s['icon_class']) ?>"></i></div>
                    <div class="ot-service-card-5 bg-mask">
                      <div class="ot-service-content">
                        <div class="ot-service-top mb-30 d-flex align-items-center justify-content-end">
                          <span class="ot-service-number"><?= str_pad((string)$i, 2, '0', STR_PAD_LEFT) ?></span>
                        </div>
                        <h3 class="ot-box-title mb-15 mt-40">
                          <a href="service-detail.php?slug=<?= urlencode((string)$s['slug']) ?>"><?= h((string)$s['title']) ?></a>
                        </h3>
                        <p class="ot-sec-text mb-25"><?= h((string)$s['short_description']) ?></p>
                        <div class="ot-service-btn">
                          <a href="service-detail.php?slug=<?= urlencode((string)$s['slug']) ?>" class="ot-btn-arrow-primary">
                            <span class="arrow-icon"><i class="flaticon-right-arrow"></i></span><span>Read more</span>
                          </a>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            <?php endforeach; ?>
          </div>
          <?php if (!$services): ?>
            <p class="text-center">No services match your search.</p>
          <?php endif; ?>
        </div>
      </div>
    </section>
  </main>
<?php require __DIR__ . '/includes/footer.php'; ?>
