<template>
  <div class="theme-switch">
    <el-tooltip effect="dark" :content="isDark ? '切换到浅色模式' : '切换到深色模式'" placement="bottom">
      <el-button class="switch-btn" circle text @click="themeStore.toggleDarkMode">
        <el-icon :size="18">
          <Moon v-if="isDark" />
          <Sunny v-else />
        </el-icon>
      </el-button>
    </el-tooltip>

    <el-tooltip effect="dark" content="主题设置" placement="bottom">
      <el-button class="switch-btn" circle text @click="emit('openSettings')">
        <el-icon :size="18"><Setting /></el-icon>
      </el-button>
    </el-tooltip>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { Moon, Sunny, Setting } from '@element-plus/icons-vue'
import { useThemeStore } from '@/store/theme'

const emit = defineEmits<{
  openSettings: []
}>()

const themeStore = useThemeStore()
const isDark = computed(() => themeStore.isDark)
</script>

<style lang="scss" scoped>
.theme-switch {
  display: flex;
  align-items: center;
  gap: 4px;

  .switch-btn {
    width: 36px;
    height: 36px;
    color: var(--text-secondary);
    transition: all var(--transition-base) var(--transition-timing);

    &:hover {
      color: var(--color-primary);
      background-color: var(--bg-hover);
    }
  }
}
</style>
