<?php
/**
 * Shared page header. Expected variables (set before including this file):
 *   $pageTitle  - string, required
 *   $isHome     - bool, optional (default false). true only for index.php.
 *   $activeNav  - string, optional. One of:
 *                 'about', 'solutions', 'capi', 'cati', 'online', 'idi',
 *                 'eye-tracking', 'mystery-shopping', 'case-studies', 'blog', 'contact'
 */
if (!isset($isHome)) { $isHome = false; }
if (!isset($activeNav)) { $activeNav = ''; }

// SEO meta — each page can set $metaDescription / $metaKeywords before including
// this file. Falls back to sitewide defaults so every page has something set.
if (!isset($metaDescription)) {
    $metaDescription = 'Globinex Research delivers CAPI, CATI, online (CAWI), IDI/TDI, mystery shopping and eye-tracking market research services to help businesses make smarter, data-driven decisions.';
}
if (!isset($metaKeywords)) {
    $metaKeywords = 'market research, CAPI, CATI, online research, CAWI, IDI, in-depth interviews, mystery shopping, eye tracking, Globinex Research';
}
require_once __DIR__ . '/config.php';

$gxSolutionKeys = ['solutions', 'capi', 'cati', 'online', 'idi', 'eye-tracking', 'mystery-shopping'];
$gxSolutionsActive = in_array($activeNav, $gxSolutionKeys, true) ? ' active' : '';

function gx_active($key, $activeNav) {
    return $key === $activeNav ? ' active' : '';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title><?php echo $pageTitle; ?></title>
  <meta name="description" content="<?php echo htmlspecialchars($metaDescription); ?>" />
  <meta name="keywords" content="<?php echo htmlspecialchars($metaKeywords); ?>" />
  <link rel="shortcut icon" href="images/favicon.ico" sizes="16x16 32x32" />

  <?php if (defined('GX_GA4_MEASUREMENT_ID') && GX_GA4_MEASUREMENT_ID): ?>
  <!-- Google Analytics 4 -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo GX_GA4_MEASUREMENT_ID; ?>"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '<?php echo GX_GA4_MEASUREMENT_ID; ?>');
  </script>
  <?php endif; ?>

  <!-- Bootstrap 5 -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
  <!-- Bootstrap Icons -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" />
  <!-- Font Awesome (used by blog "Read More" arrows) -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
  <!-- Fonts -->
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <?php if ($isHome): ?>
  <link href="https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700&family=Rethink+Sans:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600&family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
  <?php else: ?>
  <link href="https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700;800&family=Rethink+Sans:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
  <?php endif; ?>
  <!-- Custom -->
  <link rel="stylesheet" href="css/custom.css" />
  <?php if ($isHome): ?>
  <link rel="stylesheet" href="css/trust.css" />
  <?php else: ?>
  <link rel="stylesheet" href="css/pages.css" />
  <?php endif; ?>
</head>
<body<?php echo $isHome ? '' : ' class="dark"'; ?>>

  <!-- ============ TOP BAR ============ -->
  <div class="topbar">
    <div class="container">Data-Driven Insights for Smarter Business Decisions</div>
  </div>

  <!-- ============ NAVBAR ============ -->
  <nav class="gx-nav" id="gxNav">
    <div class="container">
      <div class="d-flex align-items-center justify-content-between">
        <a class="brand" href="<?php echo $isHome ? '#' : 'index.php'; ?>"><img src="images/logo.png" alt="Globinex Research" /></a>

        <button class="navbar-toggler border-0 d-lg-none text-white fs-3 p-0" type="button"
                data-bs-toggle="collapse" data-bs-target="#gxMenu">
          <i class="bi bi-list"></i>
        </button>

        <div class="collapse navbar-collapse d-lg-flex flex-grow-1 justify-content-lg-center" id="gxMenu">
          <ul class="navbar-nav flex-row flex-wrap gap-lg-4 gap-3 mx-lg-auto my-3 my-lg-0">
            <li class="nav-item"><a class="nav-link<?php echo gx_active('about', $activeNav); ?>" href="about.php">About GXR</a></li>
            <li class="nav-item dropdown gx-dropdown">
              <a class="nav-link gx-drop-toggle<?php echo $gxSolutionsActive; ?>" href="solutions.php">Solutions <i class="bi bi-chevron-down small"></i></a>
              <ul class="dropdown-menu gx-dropdown-menu">
                <li><a class="dropdown-item<?php echo gx_active('capi', $activeNav); ?>" href="capi-computer-assisted-personal-interviewing.php">CAPI</a></li>
                <li><a class="dropdown-item<?php echo gx_active('cati', $activeNav); ?>" href="cati-computer-assisted-telephonic-interviewing.php">CATI</a></li>
                <li><a class="dropdown-item<?php echo gx_active('online', $activeNav); ?>" href="online-services-cawi.php">Online Research</a></li>
                <li><a class="dropdown-item<?php echo gx_active('idi', $activeNav); ?>" href="idi-in-depth-interviews.php">IDI / TDI</a></li>
                <li><a class="dropdown-item<?php echo gx_active('eye-tracking', $activeNav); ?>" href="eye-tracking.php">Eye Tracking</a></li>
                <li><a class="dropdown-item<?php echo gx_active('mystery-shopping', $activeNav); ?>" href="mystery-shopping.php">Mystery Shopping</a></li>
              </ul>
            </li>
            <li class="nav-item"><a class="nav-link<?php echo gx_active('case-studies', $activeNav); ?>" href="case-studies.php">Case Studies</a></li>
            <li class="nav-item"><a class="nav-link<?php echo gx_active('blog', $activeNav); ?>" href="blog/">Blog</a></li>
            <li class="nav-item"><a class="nav-link<?php echo gx_active('contact', $activeNav); ?>" href="contact.php">Contact</a></li>
          </ul>
          <div class="lang-switch d-none d-lg-block" id="langSwitch">
            <div class="gtranslate_wrapper"></div>
          </div>
        </div>
      </div>
    </div>
  </nav>

  <!-- GTranslate widget settings + loader -->
  <script>
    window.gtranslateSettings = {
      "default_language": "en",
      "languages": ["en", "ar", "fr", "es", "de", "zh-CN", "hi", "ur", "pt", "ru", "ja", "tr"],
      "wrapper_selector": ".gtranslate_wrapper"
    };
  </script>
  <script src="https://cdn.gtranslate.net/widgets/latest/dropdown.js" defer></script>
