<?php
//Developer: core tech web designTechnology
//Whatsapp: +2349162671360
//Telegram: @jeditech
include __DIR__ . '/config.php';

$is_logged_in = isset($_SESSION['user_id']) && !empty($_SESSION['user_id']);
?>
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title><?php echo $page_title; ?></title>

  <meta name="description" content="<?php echo isset($page_description) ? htmlspecialchars($page_description) : htmlspecialchars($site_data['web_name']) . ' - Virtual numbers, social media growth, airtime, data & bill payments.'; ?>">
  <meta property="og:type" content="website">
  <meta property="og:title" content="<?php echo $page_title; ?>">
  <meta property="og:url" content="<?php echo htmlspecialchars($site_data['web_url']); ?>">
  <meta property="og:image" content="<?php echo htmlspecialchars(!empty($site_data['logo_url']) ? $site_data['logo_url'] : $site_data['web_url'] . '/images/softbills.png'); ?>">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="cryptomus" content="eabb64c5" />

  <link rel="shortcut icon" type="image/png" href="<?php echo htmlspecialchars(!empty($site_data['favicon_url']) ? $site_data['favicon_url'] : (!empty($site_data['logo_url']) ? $site_data['logo_url'] : $site_data['web_url'] . '/images/softbills.png')); ?>"/>
  <?php include __DIR__ . '/pwa.php'; ?>
  <link rel="canonical" href="<?php echo $site_data['web_url']; ?>/" />

  <!-- Tailwind CSS -->
  <script src="https://cdn.tailwindcss.com"></script>
  <script>
  tailwind.config = {
    theme: {
      extend: {
        colors: {
          primary: { DEFAULT: '#4D148C', light: '#6B21A8', dark: '#310A61', glow: 'rgba(77,20,140,0.15)' },
          accent: { DEFAULT: '#FF6600', light: '#FF8533', dark: '#CC5200', glow: 'rgba(255,102,0,0.15)' },
        },
        fontFamily: { sans: ['Inter', 'sans-serif'] },
        boxShadow: {
          'glow-purple': '0 10px 25px -5px rgba(77,20,140,0.15)',
          'glow-orange': '0 10px 25px -5px rgba(255,102,0,0.2)',
          'premium': '0 20px 40px -15px rgba(15,23,42,0.05)'
        }
      }
    }
  }
  </script>
<!-- TikTok Pixel Code Start -->
<script>
!function (w, d, t) {
  w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(
var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};n=document.createElement("script")
;n.type="text/javascript",n.async=!0,n.src=r+"?sdkid="+e+"&lib="+t;e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)};


  ttq.load('D89SATBC77UA33STHUQ0');
  ttq.page();
}(window, document, 'ttq');
</script>
<!-- TikTok Pixel Code End -->

<!-- TikTok Pixel Code Start -->
<script>
!function (w, d, t) {
  w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(
var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};n=document.createElement("script")
;n.type="text/javascript",n.async=!0,n.src=r+"?sdkid="+e+"&lib="+t;e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)};


  ttq.load('D89SATBC77UA33STHUQ0');
  ttq.page();
}(window, document, 'ttq');
</script>
<!-- TikTok Pixel Code End -->

<!-- TikTok Pixel Code Start -->
<script>
!function (w, d, t) {
  w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(
var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};n=document.createElement("script")
;n.type="text/javascript",n.async=!0,n.src=r+"?sdkid="+e+"&lib="+t;e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)};


  ttq.load('D89SATBC77UA33STHUQ0');
  ttq.page();
}(window, document, 'ttq');
</script>
<!-- TikTok Pixel Code End -->

  <!-- Google Fonts -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
  <!-- Font Awesome 6 -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

  <style>
    body { font-family: 'Inter', sans-serif; background: #FFFFFF; color: #1E293B; overflow-x: hidden; }
    .glassmorphism { background: rgba(255,255,255,0.85); backdrop-filter: blur(12px); border: 1px solid rgba(15,23,42,0.06); }
    .no-scrollbar::-webkit-scrollbar { display: none; }
    .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
    body.dark-theme {
      background: #07111f !important;
      color: #e5ecf7 !important;
    }
    body.dark-theme .glassmorphism,
    body.dark-theme .bg-white,
    body.dark-theme .rounded-2xl,
    body.dark-theme .rounded-3xl,
    body.dark-theme .rounded-\[28px\],
    body.dark-theme .border-slate-200,
    body.dark-theme .border-slate-100 {
      background-color: #0f172a !important;
      color: #e5ecf7 !important;
      border-color: rgba(148,163,184,0.2) !important;
    }
    body.dark-theme .text-slate-900,
    body.dark-theme .text-slate-800,
    body.dark-theme .text-slate-700,
    body.dark-theme .text-gray-800,
    body.dark-theme .text-gray-700 {
      color: #f8fafc !important;
    }
    body.dark-theme .text-slate-500,
    body.dark-theme .text-slate-600,
    body.dark-theme .text-gray-500,
    body.dark-theme .text-gray-600,
    body.dark-theme .text-gray-400 {
      color: #94a3b8 !important;
    }
    body.dark-theme .bg-slate-50,
    body.dark-theme .bg-gray-50 {
      background-color: #111827 !important;
    }
  </style>
</head>
<body class="min-h-screen">

<!-- Background Orbs -->
<div class="absolute top-[-5%] left-[-5%] w-[45vw] h-[45vw] rounded-full bg-primary/5 blur-[100px] pointer-events-none"></div>
<div class="absolute top-[25%] right-[-10%] w-[40vw] h-[40vw] rounded-full bg-accent/5 blur-[100px] pointer-events-none"></div>

<?php
$current_page = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '.php');
if (empty($current_page) || $current_page === 'index') $current_page = 'home';
?>

<!-- Navbar -->
<nav class="sticky top-0 z-40 glassmorphism border-b border-slate-200/50 shadow-sm">
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
    <div class="flex items-center justify-between h-20">
      <!-- Logo -->
      <a href="<?php echo $site_data['web_url']; ?>/" class="flex items-center gap-2">
        <img src="<?php echo htmlspecialchars(!empty($site_data['logo_url']) ? $site_data['logo_url'] : $site_data['web_url'] . '/images/softbills.png'); ?>" alt="<?php echo $site_data['web_name']; ?>" class="h-9 w-auto" onerror="this.style.display='none';this.nextElementSibling.style.display='inline'">
        <span style="display:none" class="text-xl font-black text-slate-900"><?php echo $site_data['web_name']; ?></span>
      </a>

      <!-- Desktop Nav -->
      <div class="hidden md:flex items-center space-x-8">
        <a href="<?php echo $site_data['web_url']; ?>/" class="text-slate-800 hover:text-accent transition-all font-medium text-sm <?php echo $current_page === 'home' ? 'text-accent' : ''; ?>">Home</a>
        <a href="<?php echo $site_data['web_url']; ?>/services" class="text-slate-800 hover:text-accent transition-all font-medium text-sm <?php echo $current_page === 'services' ? 'text-accent' : ''; ?>">Services</a>
        <a href="<?php echo $site_data['web_url']; ?>/faq" class="text-slate-800 hover:text-accent transition-all font-medium text-sm <?php echo $current_page === 'faq' ? 'text-accent' : ''; ?>">FAQ</a>
        <a href="<?php echo $site_data['web_url']; ?>/blog" class="text-slate-800 hover:text-accent transition-all font-medium text-sm <?php echo $current_page === 'blog' ? 'text-accent' : ''; ?>">Blog</a>
        <a href="<?php echo $site_data['web_url']; ?>/contact" class="text-slate-800 hover:text-accent transition-all font-medium text-sm <?php echo $current_page === 'contact' ? 'text-accent' : ''; ?>">Support</a>
      </div>

      <!-- Right Actions -->
      <div class="hidden md:flex items-center space-x-4">
        <button onclick="toggleTheme()" class="rounded-full border border-slate-200 bg-white/80 p-2.5 text-slate-600 shadow-sm transition hover:text-accent" title="Toggle theme">
          <i id="themeIcon" class="fa-solid fa-moon text-sm"></i>
        </button>
        <?php if ($is_logged_in): ?>
          <a href="<?php echo $site_data['web_url']; ?>/user/dashboard" class="text-slate-800 hover:text-accent font-semibold text-sm px-4 py-2">Dashboard</a>
          <a href="<?php echo $site_data['web_url']; ?>/logout" class="bg-primary hover:bg-primary-light text-white font-bold text-sm px-6 py-3 rounded-xl transition-all shadow-glow-purple">Log Out</a>
        <?php else: ?>
          <a href="<?php echo $site_data['web_url']; ?>/signin" class="text-slate-800 hover:text-accent font-semibold text-sm px-4 py-2">Sign In</a>
          <a href="<?php echo $site_data['web_url']; ?>/signup" class="bg-primary hover:bg-primary-light text-white font-bold text-sm px-6 py-3 rounded-xl transition-all shadow-glow-purple flex items-center gap-2">
            <span>Get Started</span><i class="fa-solid fa-arrow-right"></i>
          </a>
        <?php endif; ?>
      </div>

      <!-- Mobile Hamburger -->
      <button id="hamBtn" class="md:hidden text-slate-800 p-2 rounded-lg border border-slate-200">
        <i class="fa-solid fa-bars text-xl"></i>
      </button>
    </div>
  </div>

  <!-- Mobile Menu -->
  <div id="mobMenu" class="hidden md:hidden glassmorphism border-t border-slate-200/50 absolute left-0 right-0 py-5 px-6 flex flex-col gap-4 shadow-xl">
    <a href="<?php echo $site_data['web_url']; ?>/" class="text-slate-800 hover:text-accent py-2 border-b border-slate-100 font-medium">Home</a>
    <a href="<?php echo $site_data['web_url']; ?>/services" class="text-slate-800 hover:text-accent py-2 border-b border-slate-100 font-medium">Services</a>
    <a href="<?php echo $site_data['web_url']; ?>/faq" class="text-slate-800 hover:text-accent py-2 border-b border-slate-100 font-medium">FAQ</a>
    <a href="<?php echo $site_data['web_url']; ?>/blog" class="text-slate-800 hover:text-accent py-2 border-b border-slate-100 font-medium">Blog</a>
    <a href="<?php echo $site_data['web_url']; ?>/contact" class="text-slate-800 hover:text-accent py-2 border-b border-slate-100 font-medium">Support</a>
    <div class="flex flex-col gap-3 pt-2">
      <button onclick="toggleTheme()" class="flex items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white/80 py-3 font-semibold text-slate-700">
        <i id="mobileThemeIcon" class="fa-solid fa-moon"></i> Toggle Theme
      </button>
      <?php if ($is_logged_in): ?>
        <a href="<?php echo $site_data['web_url']; ?>/user/dashboard" class="text-center border border-slate-200 py-3 rounded-xl font-semibold">Dashboard</a>
        <a href="<?php echo $site_data['web_url']; ?>/logout" class="text-center bg-primary text-white font-bold py-3 rounded-xl shadow-glow-purple">Log Out</a>
      <?php else: ?>
        <a href="<?php echo $site_data['web_url']; ?>/signin" class="text-center border border-slate-200 py-3 rounded-xl font-semibold">Sign In</a>
        <a href="<?php echo $site_data['web_url']; ?>/signup" class="text-center bg-primary text-white font-bold py-3 rounded-xl shadow-glow-purple">Get Started Free →</a>
      <?php endif; ?>
    </div>
  </div>
</nav>

<div class="page-body relative">

<script>
function toggleTheme() {
  var body = document.body;
  var dark = body.classList.toggle('dark-theme');
  localStorage.setItem('publicTheme', dark ? 'dark' : 'light');
  var icons = [document.getElementById('themeIcon'), document.getElementById('mobileThemeIcon')];
  icons.forEach(function(icon){ if (icon) icon.className = dark ? 'fa-solid fa-sun text-sm' : 'fa-solid fa-moon text-sm'; });
}
(function(){
  var saved = localStorage.getItem('publicTheme');
  if (saved === 'dark') {
    document.body.classList.add('dark-theme');
  }
  var icons = [document.getElementById('themeIcon'), document.getElementById('mobileThemeIcon')];
  icons.forEach(function(icon){
    if (icon) {
      icon.className = document.body.classList.contains('dark-theme') ? 'fa-solid fa-sun text-sm' : 'fa-solid fa-moon text-sm';
    }
  });
})();
document.getElementById('hamBtn').addEventListener('click', function(){
  document.getElementById('mobMenu').classList.toggle('hidden');
});
</script>
