<?php
session_start();
date_default_timezone_set('Asia/Kuala_Lumpur');
$tarikh = date("d/m/Y");

// Default jika session tiada
$nama = 'Admin Tanpa Nama';
$no_ic = '-';
$jawatan = 'Tiada Jawatan';
$status = 'Admin';

// Tentukan jawatan dan status berdasarkan session
if (isset($_SESSION['id_admin'])) {
    $nama = $_SESSION['nama'] ?? 'Admin Tanpa Nama';
    $no_ic = $_SESSION['no_ic'] ?? '-';
    $jawatan = $_SESSION['jawatan'] ?? 'Tiada Jawatan';
    $jenis_admin = $_SESSION['jenis_admin'] ?? 'admin'; // 'utama' atau 'admin'

    if ($jenis_admin == 'utama') {
        $status = 'Admin Utama';
    } else {
        $status = 'Admin';
    }
} else {
    // Jika bukan admin, redirect ke login
    header('Location: login_admin.php');
    exit;
}
?>

<!-- Bootstrap CSS & Icon -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;600&display=swap" rel="stylesheet" />

<style>
  body {
    font-family: 'Rubik', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f6f9;
  }
  .header-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(90deg, #3b0a77, #ff6f00);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1030;
  }
  .header-title {
    font-size: 42px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .header-subtitle {
    font-size: 22px;
  }
  .header-logo {
    height: 70px;
    background: white;
    padding: 5px;
    border-radius: 8px;
  }
</style>

<div class="header-main d-flex justify-content-between align-items-center">
  <div class="d-flex align-items-center gap-3">
    <img src="images/logo_kolej.png" alt="Logo KKSJ" class="header-logo" />
    <div>
      <div class="header-title">
        <i class="bi bi-mortarboard-fill"></i> e-SPEKTRA
      </div>
      <div class="header-subtitle">Sistem Pengurusan Kegiatan dan Rekod Aktiviti</div>
    </div>
  </div>
  <div class="text-end" style="font-size:14px;">
    <div>Tarikh hari ini : <?= htmlspecialchars($tarikh) ?></div>
    <div>Login sebagai : <strong><?= strtoupper(htmlspecialchars($nama)) ?></strong> / <?= htmlspecialchars($no_ic) ?></div>
    <div>Jawatan : <?= htmlspecialchars($jawatan) ?></div>
    <div>Status : <?= htmlspecialchars($status) ?></div>
  </div>
</div>
