<?php
// views/partials/header.php

require_once __DIR__ . '/../../src/Helpers/Language.php';
require_once __DIR__ . '/../../src/Helpers/Auth.php';

$currentLang = Language::current();
$currentCurrency = Language::currency();
$currentUser = Auth::user();
?>
<header class="bg-teal-950 text-white sticky top-0 z-40 border-b border-teal-800/50 backdrop-blur-md bg-opacity-95 shadow-lg">
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3.5 flex items-center justify-between gap-4">
    
    <!-- Logo & Brand Header -->
    <a href="index.php" class="flex items-center gap-3 group">
      <div class="w-10 h-10 rounded-xl bg-gradient-to-br from-amber-400 to-amber-600 flex items-center justify-center text-teal-950 font-black text-xl shadow-md group-hover:scale-105 transition-transform">
        ف
      </div>
      <div>
        <h1 class="font-extrabold text-base md:text-lg tracking-tight text-white flex items-center gap-2">
          <?= Language::t('academyName') ?>
        </h1>
        <p class="text-[10px] text-amber-300/80 font-medium tracking-wide hidden sm:block">
          <?= Language::t('subTitle') ?>
        </p>
      </div>
    </a>

    <!-- Control Actions & Navigation -->
    <div class="flex items-center gap-2 sm:gap-3">
      
      <!-- Currency Switcher -->
      <div class="inline-flex rounded-lg bg-teal-900/80 p-0.5 border border-teal-700/60 text-xs font-semibold">
        <a href="?currency=NGN" class="px-2 py-1 rounded-md transition-colors <?= $currentCurrency === 'NGN' ? 'bg-amber-500 text-teal-950 font-bold' : 'text-teal-200 hover:text-white' ?>">
          NGN (₦)
        </a>
        <a href="?currency=USD" class="px-2 py-1 rounded-md transition-colors <?= $currentCurrency === 'USD' ? 'bg-amber-500 text-teal-950 font-bold' : 'text-teal-200 hover:text-white' ?>">
          USD ($)
        </a>
      </div>

      <!-- Language Switcher -->
      <div class="inline-flex rounded-lg bg-teal-900/80 p-0.5 border border-teal-700/60 text-xs font-semibold">
        <a href="?lang=en" class="px-2.5 py-1 rounded-md transition-colors <?= $currentLang === 'en' ? 'bg-teal-700 text-white font-bold' : 'text-teal-200 hover:text-white' ?>">
          EN
        </a>
        <a href="?lang=ar" class="px-2.5 py-1 rounded-md transition-colors <?= $currentLang === 'ar' ? 'bg-teal-700 text-white font-bold' : 'text-teal-200 hover:text-white' ?>">
          العربية
        </a>
      </div>

      <!-- User Auth / Portal Links -->
      <?php if ($currentUser): ?>
        <a href="index.php?page=portal" class="bg-amber-500 hover:bg-amber-400 text-teal-950 font-extrabold text-xs px-3.5 py-2 rounded-xl transition-all shadow-md flex items-center gap-1.5">
          <span>🎓</span>
          <span><?= Language::t('myPortal') ?></span>
        </a>
        <button onclick="handleLogout()" class="bg-teal-800/80 hover:bg-red-600/80 text-white text-xs px-3 py-2 rounded-xl transition-all border border-teal-700">
          <?= Language::t('logout') ?>
        </button>
      <?php else: ?>
        <button onclick="openModal('login')" class="text-xs font-bold text-teal-200 hover:text-white px-3 py-2 rounded-xl hover:bg-teal-900/50 transition-colors">
          <?= Language::t('login') ?>
        </button>
        <button onclick="openModal('register')" class="bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-400 hover:to-amber-500 text-teal-950 font-extrabold text-xs px-4 py-2 rounded-xl transition-all shadow-md">
          <?= Language::t('register') ?>
        </button>
      <?php endif; ?>

    </div>
  </div>
</header>
