<script setup lang="ts">
const props = defineProps<{
  loggedIn: boolean;
}>();

const emit = defineEmits<{
  example: [content: string];
}>();

const examples = [
  "帮我写一个 Python 函数，计算斐波那契数列",
  "解释一下什么是闭包，并给出一个 JavaScript 示例",
  "帮我分析这段代码的性能瓶颈",
  "如何用 SQL 查询去重并统计数量？",
];
</script>

<template>
  <div class="agent-welcome">
    <div class="welcome-icon">
      <Icon name="lucide:sparkles" />
    </div>
    <h1 class="welcome-title">有什么可以帮你的？</h1>
    <p class="welcome-subtitle">
      {{ loggedIn ? "选择模型，开始对话" : "无需登录即可体验，登录后可保存对话记录" }}
    </p>
    <div class="welcome-examples">
      <button
        v-for="ex in examples"
        :key="ex"
        class="example-card"
        @click="emit('example', ex)"
      >
        <Icon name="lucide:message-square" class="example-icon" />
        <span>{{ ex }}</span>
      </button>
    </div>
  </div>
</template>

<style scoped>
.agent-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--color-surface-dark);
  color: var(--color-on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 24px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  color: var(--color-ink);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--color-muted);
  margin: 0 0 32px;
}

.welcome-examples {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
}

.example-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: 12px;
  font-size: 14px;
  color: var(--color-body);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.example-card:hover {
  background: var(--color-surface-soft);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.example-icon {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--color-primary);
}

@media (max-width: 640px) {
  .welcome-examples {
    grid-template-columns: 1fr;
  }
}
</style>
