<?php
declare(strict_types=1);
if (!isset($pdo)) {
    require_once __DIR__ . '/includes/functions.php';
    require_once __DIR__ . '/includes/middleware.php';
    $pdo = require __DIR__ . '/config/database.php';
}

// Fetch all active services
$services = $pdo->query("SELECT id, service_name, cac_fee, service_fee, (cac_fee+service_fee) AS total FROM services WHERE status='active' AND service_name NOT LIKE 'Package:%' AND service_name NOT LIKE 'Plan:%' ORDER BY service_name ASC")->fetchAll();

$meta = [
  'title' => 'CAC Services in Nigeria | Business Registration & Compliance | Go Legal',
  'description' => 'Explore professional services for CAC business registration, TIN, SCUML, annual returns, and more. We make corporate compliance simple for Nigerian founders.',
  'canonical' => url('services.php')
];
include __DIR__ . '/includes/header.php';
$cu = current_user();
?>

<section class="section" style="padding-top:48px; padding-bottom: 48px;">
  <div style="text-align:center;margin-bottom:48px;max-width:700px;margin-left:auto;margin-right:auto;">
    <h1 style="font-size:42px; margin:0 0 16px; letter-spacing:-0.02em;">Corporate <span class="gradient-text">Compliance Made Simple.</span></h1>
    <p class="lead">From your first incorporation to ongoing annual returns, TIN registration, and SCUML certification. Select the service you need and let us handle the bureaucracy for you.</p>
  </div>
  
  <div class="grid grid-3">
    <?php foreach ($services as $svc): 
      $name = (string)$svc['service_name'];
      $iconKey = 'services';
      if (stripos($name,'Business Name')!==false) $iconKey='start';
      elseif (stripos($name,'Company')!==false) $iconKey='applications';
      elseif (stripos($name,'NGO')!==false || stripos($name,'Trustee')!==false) $iconKey='users';
      elseif (stripos($name,'SCUML')!==false) $iconKey='approved';
      elseif (stripos($name,'Trademark')!==false) $iconKey='approved';
      elseif (stripos($name,'Annual Returns')!==false) $iconKey='processing';
    ?>
      <div class="card reveal" style="display:flex;flex-direction:column;justify-content:space-between">
        <div>
          <div style="display:flex;align-items:center;margin-bottom:12px">
            <span class="service-icon" aria-hidden="true" style="margin-right:8px"><?=ui_icon($iconKey,24)?></span>
            <strong style="font-size: 16px;"><?=e($svc['service_name'])?></strong>
          </div>
          <p class="muted" style="font-size: 14px; margin-bottom: 16px;">Professional handling and all statutory fees included.</p>
          <div style="margin-bottom:24px">
            <div class="muted" style="font-size:12px;font-weight:600;text-transform:uppercase;margin-bottom:4px">Total Fee</div>
            <div style="font-size:24px;font-weight:700;color:var(--text)">₦<?=e(money((float)$svc['total']))?></div>
          </div>
        </div>
        <a class="btn primary" href="<?=cta_url('customer/new_application.php?service_id='.e((string)$svc['id']))?>">Start Application</a>
      </div>
    <?php endforeach; ?>
  </div>
  <div style="text-align:center;margin-top:48px;">
    <p class="muted">Need a complete package instead?</p>
    <a class="btn ghost" href="<?=url('pricing.php')?>">View our all-inclusive bundles</a>
  </div>
</section>

<?php include __DIR__ . '/includes/footer.php'; ?>
