<template>
  <div id="app">
    <div class="header">
      <h1>Vue3 猜数游戏</h1>
      <div class="toggle-buttons">
        <button
          :class="{ active: currentView === 'composition' }"
          @click="currentView = 'composition'"
        >
          组合式 API
        </button>
        <button
          :class="{ active: currentView === 'options' }"
          @click="currentView = 'options'"
        >
          选项式 API
        </button>
        <button
          :class="{ active: currentView === 'both' }"
          @click="currentView = 'both'"
        >
          对比查看
        </button>
      </div>
    </div>

    <div class="content">
      <!-- 单独显示组合式 -->
      <GuessComposition v-if="currentView === 'composition'" />

      <!-- 单独显示选项式 -->
      <GuessOptions v-if="currentView === 'options'" />

      <!-- 并排对比显示 -->
      <div v-if="currentView === 'both'" class="comparison">
        <GuessComposition />
        <GuessOptions />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import GuessComposition from "./components/GuessComposition.vue";
import GuessOptions from "./components/GuessOptions.vue";

const currentView = ref("both"); // 默认显示对比视图
</script>

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

#app {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2.5em;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-buttons button {
  padding: 10px 20px;
  border: 2px solid white;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s;
}

.toggle-buttons button:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.toggle-buttons button.active {
  background-color: white;
  color: #667eea;
}

.content {
  max-width: 1400px;
  margin: 0 auto;
}

.comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 20px;
  justify-items: center;
}

@media (max-width: 768px) {
  .comparison {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 1.8em;
  }

  .toggle-buttons button {
    font-size: 14px;
    padding: 8px 15px;
  }
}
</style>
