<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TAMIM1280 | File Hub</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@500;700&display=swap');
        body {
            background-color: #020617;
            background-image: radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.15) 0%, transparent 50%), url('https://www.transparenttextures.com/patterns/stardust.png');
            color: #e2e8f0; font-family: 'Rajdhani', sans-serif;
        }
        .glow-text { text-shadow: 0 0 10px rgba(34, 211, 238, 0.8); }
        .cyber-card { background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 1rem; }
        .cyber-button { background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%); }
        .logo-font { font-family: 'Orbitron', sans-serif; }

        /* ড্রপডাউন এনিমেশন */
        #userDropdown {
            display: none;
            transform-origin: top right;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            opacity: 0;
            transform: scale(0.95);
        }
        #userDropdown.active {
            display: block;
            opacity: 1;
            transform: scale(1);
        }
    </style>
</head>
<body class="min-h-screen">

<header class="w-full border-b border-white/5 bg-slate-950/50 backdrop-blur-md sticky top-0 z-50">
    <div class="max-w-7xl mx-auto px-4 flex justify-between items-center h-16 md:h-20">
        <!-- User Logo -->
        <a href="index.php" class="logo-font text-xl sm:text-2xl font-bold tracking-tighter">
            PANEL <span class="text-cyan-400 glow-text">HUB</span>
        </a>
        
        <div class="flex items-center space-x-2 md:space-x-4">
            <?php if (isset($_SESSION['user_id'])): ?>
                <!-- ব্যালেন্স এবং Add Money -->
                <div class="flex items-center bg-black/40 border border-white/10 rounded-full pl-3 pr-1 py-1">
                    <div class="flex flex-col pr-3">
                        <span class="text-[8px] uppercase font-black text-gray-500 leading-none">Credit</span>
                        <span class="text-xs md:text-sm font-bold text-cyan-400 tracking-tighter">৳ <?php echo number_format($_SESSION['user_balance'], 2); ?></span>
                    </div>
                    <a href="add-money.php" class="w-7 h-7 md:w-8 md:h-8 rounded-full bg-cyan-500 flex items-center justify-center text-black hover:bg-white transition-all shadow-[0_0_10px_rgba(34,211,238,0.3)]">
                        <i class="fa-solid fa-plus text-xs"></i>
                    </a>
                </div>

                <!-- ইউজার প্রোফাইল (ক্লিক ইভেন্টসহ) -->
                <div class="relative">
                    <div id="profileBtn" class="h-9 w-9 md:h-10 md:w-10 rounded-full border border-cyan-500/50 p-0.5 cursor-pointer hover:border-white transition-all">
                        <img src="https://ui-avatars.com/api/?name=<?php echo $_SESSION['username']; ?>&background=0ea5e9&color=fff" class="rounded-full w-full h-full object-cover shadow-[0_0_15px_rgba(34,211,238,0.2)]">
                    </div>
                    
                    <!-- ড্রপডাউন মেনু -->
                    <div id="userDropdown" class="absolute right-0 mt-3 w-52 bg-slate-900/95 border border-white/10 rounded-2xl py-2 backdrop-blur-xl shadow-[0_10px_40px_rgba(0,0,0,0.8)] z-[100]">
                        <div class="px-4 py-3 border-b border-white/5 mb-2">
                            <p class="text-[9px] text-cyan-500 uppercase font-black tracking-widest">Logged In As</p>
                            <p class="text-sm font-bold text-white truncate uppercase"><?php echo $_SESSION['username']; ?></p>
                        </div>
                        
                        <a href="dashboard.php" class="flex items-center px-4 py-2.5 text-xs font-bold text-gray-400 hover:text-cyan-400 hover:bg-white/5 transition-all uppercase tracking-widest">
                            <i class="fa-solid fa-gauge-high mr-3 w-4"></i> Dashboard
                        </a>
                        
                        <a href="logout.php" class="flex items-center px-4 py-2.5 text-xs font-bold text-red-400 hover:text-red-500 hover:bg-red-500/5 transition-all uppercase tracking-widest border-t border-white/5 mt-1">
                            <i class="fa-solid fa-power-off mr-3 w-4"></i> Logout Session
                        </a>
                    </div>
                </div>

            <?php else: ?>
                <a href="login.php" class="text-[10px] md:text-xs font-black uppercase text-gray-400 tracking-widest">Login</a>
                <a href="register.php" class="cyber-button px-4 py-1.5 md:px-6 md:py-2 rounded-lg text-[10px] md:text-xs font-black text-white uppercase tracking-widest">Register</a>
            <?php endif; ?>
        </div>
    </div>
</header>

<script>
    // প্রোফাইল ড্রপডাউন কন্ট্রোল
    const profileBtn = document.getElementById('profileBtn');
    const userDropdown = document.getElementById('userDropdown');

    if(profileBtn) {
        profileBtn.addEventListener('click', function(e) {
            e.stopPropagation(); // ক্লিক করার সময় ইভেন্টটি যেন বাইরে না যায়
            userDropdown.classList.toggle('active');
        });

        // স্ক্রিনের অন্য কোথাও ক্লিক করলে মেনু বন্ধ হয়ে যাবে
        document.addEventListener('click', function(e) {
            if (!userDropdown.contains(e.target) && !profileBtn.contains(e.target)) {
                userDropdown.classList.remove('active');
            }
        });
    }
</script>