<template>
  <div class="flat-container min-h-screen bg-gray-50">
    <!-- 顶部应用栏 -->
    <div class="flat-app-bar">
      <div class="container mx-auto px-4 py-3 flex items-center justify-between">
        <div class="flex items-center">
          <Menu class="w-5 h-5 text-white mr-4" />
          <h1 class="text-xl font-medium text-white">Flat Design</h1>
        </div>
        <div class="flex items-center space-x-4">
          <button class="flat-icon-button">
            <Search class="w-5 h-5" />
          </button>
          <button class="flat-icon-button">
            <Bell class="w-5 h-5" />
          </button>
          <button class="flat-icon-button">
            <User class="w-5 h-5" />
          </button>
        </div>
      </div>
    </div>

    <!-- 主要内容区 -->
    <div class="container mx-auto p-6">
      <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
        <!-- 左侧导航 -->
        <div class="flat-card">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-900">导航菜单</h2>
            <nav class="space-y-2">
              <a href="#" class="flat-nav-item active">
                <Home class="w-5 h-5" />
                <span>首页</span>
              </a>
              <a href="#" class="flat-nav-item">
                <Inbox class="w-5 h-5" />
                <span>收件箱</span>
                <span class="flat-badge">12</span>
              </a>
              <a href="#" class="flat-nav-item">
                <Star class="w-5 h-5" />
                <span>收藏</span>
              </a>
              <a href="#" class="flat-nav-item">
                <Settings class="w-5 h-5" />
                <span>设置</span>
              </a>
            </nav>
          </div>
        </div>

        <!-- 中间内容 -->
        <div class="md:col-span-2 space-y-6">
          <!-- 卡片列表 -->
          <div class="flat-card">
            <div class="p-4">
              <h2 class="text-lg font-medium mb-4 text-gray-900">卡片列表</h2>
              <div class="space-y-4">
                <div class="flat-list-item">
                  <div class="flat-avatar bg-blue-500">JD</div>
                  <div class="flex-1">
                    <h3 class="font-medium text-gray-900">卡片标题</h3>
                    <p class="text-gray-600">卡片副标题</p>
                  </div>
                  <button class="flat-icon-button">
                    <MoreVertical class="w-5 h-5" />
                  </button>
                </div>
                <div class="flat-list-item">
                  <div class="flat-avatar bg-indigo-500">AB</div>
                  <div class="flex-1">
                    <h3 class="font-medium text-gray-900">另一个标题</h3>
                    <p class="text-gray-600">另一个副标题</p>
                  </div>
                  <button class="flat-icon-button">
                    <MoreVertical class="w-5 h-5" />
                  </button>
                </div>
              </div>
            </div>
          </div>

          <!-- 表单元素 -->
          <div class="flat-card">
            <div class="p-4">
              <h2 class="text-lg font-medium mb-4 text-gray-900">表单元素</h2>
              <div class="space-y-4">
                <div class="flat-input-group">
                  <label class="text-gray-700">文本输入</label>
                  <input type="text" placeholder="请输入内容" class="flat-input">
                </div>
                <div class="flat-input-group">
                  <label class="text-gray-700">密码输入</label>
                  <input type="password" placeholder="请输入密码" class="flat-input">
                </div>
                <div class="flat-input-group">
                  <label class="text-gray-700">下拉选择</label>
                  <select class="flat-input">
                    <option>选项 1</option>
                    <option>选项 2</option>
                    <option>选项 3</option>
                  </select>
                </div>
                <div class="flex items-center space-x-4">
                  <label class="flat-checkbox">
                    <input type="checkbox">
                    <span class="flat-checkmark"></span>
                    <span class="text-gray-700">复选框</span>
                  </label>
                  <label class="flat-radio">
                    <input type="radio" name="radio">
                    <span class="flat-radiomark"></span>
                    <span class="text-gray-700">单选框</span>
                  </label>
                </div>
                <div class="flat-switch">
                  <input type="checkbox" id="switch1">
                  <label for="switch1" class="text-gray-700">开关</label>
                </div>
              </div>
            </div>
          </div>

          <!-- 按钮组 -->
          <div class="flat-card">
            <div class="p-4">
              <h2 class="text-lg font-medium mb-4 text-gray-900">按钮样式</h2>
              <div class="flex flex-wrap gap-4">
                <button class="flat-button">主要按钮</button>
                <button class="flat-button outlined">次要按钮</button>
                <button class="flat-button text">文本按钮</button>
                <button class="flat-button icon">
                  <Plus class="w-5 h-5" />
                </button>
              </div>
            </div>
          </div>

          <!-- 进度指示器 -->
          <div class="flat-card">
            <div class="p-4">
              <h2 class="text-lg font-medium mb-4 text-gray-900">进度指示器</h2>
              <div class="space-y-4">
                <div class="flat-progress">
                  <div class="flat-progress-bar" style="width: 60%"></div>
                </div>
                <div class="flat-progress circular">
                  <div class="flat-progress-circle"></div>
                </div>
              </div>
            </div>
          </div>

          <!-- 对话框 -->
          <div class="flat-card">
            <div class="p-4">
              <h2 class="text-lg font-medium mb-4 text-gray-900">对话框示例</h2>
              <button class="flat-button" @click="showDialog = true">打开对话框</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部导航栏 -->
    <div class="flat-bottom-nav">
      <a href="#" class="flat-bottom-nav-item active">
        <Home class="w-6 h-6" />
        <span>首页</span>
      </a>
      <a href="#" class="flat-bottom-nav-item">
        <Search class="w-6 h-6" />
        <span>搜索</span>
      </a>
      <a href="#" class="flat-bottom-nav-item">
        <Plus class="w-6 h-6" />
        <span>添加</span>
      </a>
      <a href="#" class="flat-bottom-nav-item">
        <Bell class="w-6 h-6" />
        <span>通知</span>
      </a>
      <a href="#" class="flat-bottom-nav-item">
        <User class="w-6 h-6" />
        <span>我的</span>
      </a>
    </div>

    <!-- 对话框 -->
    <div v-if="showDialog" class="flat-dialog-overlay">
      <div class="flat-dialog">
        <div class="flat-dialog-header">
          <h3 class="text-gray-900">对话框标题</h3>
          <button class="flat-icon-button" @click="showDialog = false">
            <X class="w-5 h-5" />
          </button>
        </div>
        <div class="flat-dialog-content">
          <p class="text-gray-600">这是一个扁平化设计风格的对话框示例。</p>
        </div>
        <div class="flat-dialog-actions">
          <button class="flat-button text" @click="showDialog = false">取消</button>
          <button class="flat-button" @click="showDialog = false">确定</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { 
  Menu, Search, Bell, User, Home, 
  Inbox, Star, Settings, MoreVertical,
  Plus, X
} from 'lucide-vue-next'

const showDialog = ref(false)
</script>

<style scoped>
.flat-container {
  font-family: 'Segoe UI', sans-serif;
  position: relative;
  overflow: hidden;
}

.flat-app-bar {
  @apply sticky top-0 z-10 bg-blue-500;
}

.flat-icon-button {
  @apply p-2 text-white;
  transition: all 0.2s ease;
}

.flat-icon-button:hover {
  @apply bg-blue-600;
}

.flat-card {
  @apply bg-white p-4;
  border: 1px solid #e5e7eb;
}

.flat-nav-item {
  @apply flex items-center space-x-3 p-2 text-gray-700;
  transition: all 0.2s ease;
}

.flat-nav-item:hover {
  @apply bg-gray-100;
}

.flat-nav-item.active {
  @apply bg-blue-500 text-white;
}

.flat-badge {
  @apply bg-red-500 text-white text-xs px-2 py-1;
}

.flat-list-item {
  @apply flex items-center space-x-4 p-2;
  transition: all 0.2s ease;
}

.flat-list-item:hover {
  @apply bg-gray-50;
}

.flat-avatar {
  @apply w-10 h-10 flex items-center justify-center text-white font-medium;
}

.flat-input-group {
  @apply space-y-1;
}

.flat-input {
  @apply w-full px-3 py-2 text-gray-900;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.flat-input:focus {
  @apply outline-none;
  border-color: #3b82f6;
}

.flat-input::placeholder {
  @apply text-gray-400;
}

.flat-checkbox,
.flat-radio {
  @apply flex items-center space-x-2 cursor-pointer;
}

.flat-checkmark,
.flat-radiomark {
  @apply w-5 h-5;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.flat-checkmark {
  @apply rounded;
}

.flat-radiomark {
  @apply rounded-full;
}

.flat-checkbox input:checked + .flat-checkmark,
.flat-radio input:checked + .flat-radiomark {
  @apply bg-blue-500 border-blue-500;
}

.flat-switch {
  @apply flex items-center space-x-2;
}

.flat-switch input {
  @apply hidden;
}

.flat-switch label {
  @apply relative inline-block w-12 h-6 cursor-pointer;
  background: #e5e7eb;
  transition: all 0.2s ease;
}

.flat-switch label:after {
  content: '';
  @apply absolute w-5 h-5 bg-white top-0.5 left-0.5;
  transition: all 0.2s ease;
}

.flat-switch input:checked + label {
  @apply bg-blue-500;
}

.flat-switch input:checked + label:after {
  @apply translate-x-6;
}

.flat-button {
  @apply px-4 py-2 text-white;
  background: #3b82f6;
  transition: all 0.2s ease;
}

.flat-button:hover {
  @apply bg-blue-600;
}

.flat-button.outlined {
  @apply bg-transparent border border-blue-500 text-blue-500;
}

.flat-button.text {
  @apply bg-transparent border-none text-blue-500;
}

.flat-button.icon {
  @apply p-2;
}

.flat-progress {
  @apply h-1;
  background: #e5e7eb;
}

.flat-progress-bar {
  @apply h-full;
  background: #3b82f6;
}

.flat-progress.circular {
  @apply w-12 h-12;
  background: transparent;
  border: 4px solid #e5e7eb;
}

.flat-progress-circle {
  @apply w-full h-full border-4;
  border-color: #3b82f6;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.flat-bottom-nav {
  @apply fixed bottom-0 left-0 right-0 bg-white flex justify-around items-center py-2;
  border-top: 1px solid #e5e7eb;
}

.flat-bottom-nav-item {
  @apply flex flex-col items-center space-y-1 text-gray-600;
  transition: all 0.2s ease;
}

.flat-bottom-nav-item:hover {
  @apply text-blue-500;
}

.flat-bottom-nav-item.active {
  @apply text-blue-500;
}

.flat-dialog-overlay {
  @apply fixed inset-0 bg-black/50 flex items-center justify-center;
}

.flat-dialog {
  @apply bg-white w-full max-w-md;
  border: 1px solid #e5e7eb;
}

.flat-dialog-header {
  @apply flex justify-between items-center p-4 border-b border-gray-200;
}

.flat-dialog-content {
  @apply p-4;
}

.flat-dialog-actions {
  @apply flex justify-end space-x-2 p-4 border-t border-gray-200;
}
</style> 