<template>
  <div class="flex items-center gap-3">
    <div v-if="isEditorActive" class="flex items-center gap-2 group">
      <div class="text-right hidden lg:block">
        <p class="text-[10px] uppercase tracking-wider font-bold text-gray-400 dark:text-gray-500 mb-[-2px]">Current Project</p>
        <Tooltip text="Rename project">
          <button @click="$emit('open-save-modal')" class="text-sm font-bold text-gray-800 dark:text-gray-200 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors truncate max-w-[160px]">
            {{ projectStore.currentProject?.name || 'Untitled project' }}
          </button>
        </Tooltip>
      </div>

      <!-- Mobile/Tablet simplified view -->
      <button @click="$emit('open-save-modal')" class="lg:hidden text-sm font-bold text-gray-800 dark:text-gray-200 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors truncate max-w-[120px]">
        {{ projectStore.currentProject?.name || 'Untitled' }}
      </button>
    </div>

    <div v-if="isEditorActive" class="h-8 w-px bg-gray-200 dark:bg-gray-700 mx-1"></div>

    <div class="flex items-center gap-1">
      <Tooltip v-if="isEditorActive" text="Save project">
        <button @click="$emit('save-project')" class="w-8 h-8 rounded-lg flex items-center justify-center text-gray-500 hover:text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 transition-all">
          <i class="fas fa-save"></i>
        </button>
      </Tooltip>

      <Tooltip v-if="isEditorActive && projectStore.currentProject" text="Save as...">
        <button @click="$emit('open-save-modal', 'save-as')" class="w-8 h-8 rounded-lg flex items-center justify-center text-gray-500 hover:text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 transition-all">
          <i class="fas fa-clone"></i>
        </button>
      </Tooltip>
      
      <Tooltip text="New project">
        <button @click="$emit('open-new-project-modal')" class="w-8 h-8 rounded-lg flex items-center justify-center text-gray-500 hover:text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 transition-all">
          <i class="fas fa-plus"></i>
        </button>
      </Tooltip>
      
      <Tooltip text="My projects">
        <button @click="$emit('open-project-list')" class="w-8 h-8 rounded-lg flex items-center justify-center text-gray-500 hover:text-indigo-600 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 transition-all">
          <i class="fas fa-folder-open"></i>
        </button>
      </Tooltip>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { useProjectStore } from '@/stores/useProjectStore';
  import { useProjectManager } from '@/composables/useProjectManager';
  import Tooltip from '@/components/utilities/Tooltip.vue';

  defineEmits(['save-project', 'open-save-modal', 'open-project-list', 'open-new-project-modal']);

  const projectStore = useProjectStore();
  const { isEditorActive } = useProjectManager();
</script>

