<template>
  <div id="app">«    <!-- 测试模式切换按钮 -->
    <div class="test-mode-toggle" style="display: none;">
      <button @click="toggleTestMode" class="test-btn">
        {{ isTestMode ? '切换到思维导图' : '测试Markdown渲染' }}
      </button>
    </div>
    
    <!-- 测试模式 -->
    <div v-if="isTestMode" class="test-mode">
      <MarkdownTest />
    </div>
    
    <!-- 正常模式 -->
    <div v-else>
      <!-- AI侧边栏 -->
      <AISidebar @start-realtime-generation="handleStartRealtimeGeneration" />
      
      <!-- 主内容区域 -->
      <div class="main-content">
        <MindMap ref="mindMapRef" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import MindMap from "./components/MindMap.vue";
import AISidebar from "./components/AISidebar.vue";
import MarkdownTest from "./components/MarkdownTest.vue";

const mindMapRef = ref(null);
const isTestMode = ref(false);

// 切换测试模式
const toggleTestMode = () => {
  isTestMode.value = !isTestMode.value;
};

// 处理开始实时生成事件
const handleStartRealtimeGeneration = () => {
  // console.log('🎬 开始实时生成，切换到思维导图界面');
  if (mindMapRef.value) {
    mindMapRef.value.showMindMapPage();
  }
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
}

.main-content {
  flex: 1;
  margin-left: 350px;
  transition: margin-left 0.3s ease;
  width: calc(100% - 350px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
}

/* Mind Elixir 全局样式 */
.mind-elixir {
  height: 100%;
  width: 100%;
}

.mind-elixir .map-container {
  height: 100%;
  width: 100%;
}

/* 测试模式样式 */
.test-mode-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.test-btn {
  padding: 10px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
  transition: all 0.2s ease;
}

.test-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

.test-mode {
  height: 100vh;
  overflow: auto;
}
</style>
