<?php
// File: /artist/header.php

// Start the session at the very beginning
session_start();

// --- CORRECTED PATH TO DB.PHP ---
// Use __DIR__ . '/../' to reliably go up one level from the /artist/ directory to the root
require_once __DIR__ . '/../db.php'; 

// Security Check: Ensure the user is logged in and is an artist
if (!isset($_SESSION['user_id']) || !isset($_SESSION['role']) || $_SESSION['role'] !== 'artist') {
    // If not, redirect to the main login page
    header('Location: ../login.php');
    exit(); // Stop script execution
}

// Fetch the username for the welcome message
$username = $_SESSION['username'] ?? 'Artist';

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Artist Dashboard - UCF</title>
    <!-- Font Awesome for icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Link to the dashboard stylesheet -->
    <link rel="stylesheet" href="../css/dashboard.css">
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        'ucf-green-light': '#E0F2F1',
                        'ucf-green': '#499FA4',
                        'ucf-green-dark': '#004D40',
                        'ucf-charcoal': '#3D4A55',
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gray-100 font-sans">

    <div class="flex">
        <!-- Collapsible Sidebar -->
        <aside id="sidebar" class="bg-ucf-charcoal text-white h-screen fixed top-0 left-0 z-40 transition-all duration-300 w-64">
            <div class="p-4 text-2xl font-bold border-b border-gray-700">
                <span class="sidebar-text">UCF Artist</span>
            </div>
            <nav class="mt-4">
                <a href="index.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-tachometer-alt w-8 text-center"></i>
                    <span class="sidebar-text ml-2">Dashboard</span>
                </a>
                <a href="profile.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-user-circle w-8 text-center"></i>
                    <span class="sidebar-text ml-2">My Profile</span>
                </a>
                <a href="paintings.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-palette w-8 text-center"></i>
                    <span class="sidebar-text ml-2">My Paintings</span>
                </a>
                <a href="orders.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-receipt w-8 text-center"></i>
                    <span class="sidebar-text ml-2">My Sales</span>
                </a>
                <a href="competitions.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-trophy w-8 text-center"></i>
                    <span class="sidebar-text ml-2">Competitions</span>
                </a>
                <a href="tickets.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200">
                    <i class="fas fa-life-ring w-8 text-center"></i>
                    <span class="sidebar-text ml-2">Support Tickets</span>
                </a>
                <a href="../logout.php" class="flex items-center py-3 px-4 hover:bg-ucf-green-dark transition-colors duration-200 mt-8">
                    <i class="fas fa-sign-out-alt w-8 text-center"></i>
                    <span class="sidebar-text ml-2">Logout</span>
                </a>
            </nav>
        </aside>

        <!-- Main Content Area -->
        <main id="main-content" class="flex-1 transition-all duration-300 ml-64">
            <!-- Top Navigation Bar -->
            <div class="bg-white shadow-md p-4 flex justify-between items-center">
                <button id="menu-toggle" class="text-ucf-charcoal text-2xl">
                    <i class="fas fa-bars"></i>
                </button>
                <div class="user-profile">
                    <a href="profile.php" class="text-ucf-green hover:underline">Welcome, <?php echo htmlspecialchars($username); ?></a>
                </div>
            </div>

            <!-- Start of the page-specific content -->
            <div class="content-area">

