<?php
// admin/header.php - Admin backend header layout
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
require_once 'config.php';

// Check authentication
if (basename($_SERVER['PHP_SELF']) !== 'login.php') {
    if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
        header('Location: login.php');
        exit;
    }
}

require_once '../products.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Admin - Tee Store</title>
  <link rel="stylesheet" href="../style.css">
  <link rel="stylesheet" href="admin.css">
  
  <!-- Prevent dark mode flash -->
  <script>
    (function() {
      var savedTheme = localStorage.getItem('theme') || 'light';
      document.documentElement.setAttribute('data-theme', savedTheme);
    })();
  </script>
</head>
<body>

  <!-- Minimal Admin Navigation Bar -->
  <header>
    <div class="container nav-container">
      <a href="index.php" class="logo">Tee Store. <span style="font-weight: 300; opacity: 0.6;">Admin</span></a>
      
      <?php if (isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true): ?>
      <nav class="nav-center">
        <div style="display: flex; gap: 24px;">
          <a href="index.php" style="<?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'opacity: 1; font-weight: 600;' : 'opacity: 0.6;'; ?> font-size: 12px;">Dashboard</a>
          <a href="products.php" style="<?php echo basename($_SERVER['PHP_SELF']) == 'products.php' ? 'opacity: 1; font-weight: 600;' : 'opacity: 0.6;'; ?> font-size: 12px;">Products</a>
        </div>
      </nav>
      <?php endif; ?>
      
      <div class="nav-actions">
        <a href="../index.php" class="btn btn-storefront" style="font-size: 11px; padding: 4px 12px; border-radius: 4px; border: 1px solid var(--border-color); opacity: 0.8; height: 28px; display: inline-flex; align-items: center;">View Storefront</a>
        
        <button class="theme-toggle-btn" id="theme-toggle" aria-label="Toggle light/dark theme">
          <!-- SVG icon representing theme toggle -->
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="theme-icon-sun">
            <circle cx="12" cy="12" r="5"></circle>
            <line x1="12" y1="1" x2="12" y2="3"></line>
            <line x1="12" y1="21" x2="12" y2="23"></line>
            <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
            <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
            <line x1="1" y1="12" x2="3" y2="12"></line>
            <line x1="21" y1="12" x2="23" y2="12"></line>
            <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
            <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
          </svg>
        </button>
        
        <?php if (isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true): ?>
          <a href="login.php?action=logout" style="font-size: 11px; opacity: 0.6; margin-left: 8px;">Logout</a>
        <?php endif; ?>
      </div>
    </div>
  </header>
  
  <main style="padding: 40px 0; flex: 1;">
