<template>
  <div class="neu-container min-h-screen bg-gray-100">
    <!-- 顶部应用栏 -->
    <div class="neu-app-bar">
      <div class="container mx-auto px-4 py-3 flex items-center justify-between">
        <div class="flex items-center">
          <button class="neu-icon-button" @click="isMenuOpen = !isMenuOpen">
            <Menu class="w-5 h-5" />
          </button>
          <h1 class="text-xl font-medium text-gray-700 ml-4">Neumorphism</h1>
        </div>
        <div class="flex items-center space-x-4">
          <div class="neu-search-box">
            <Search class="w-5 h-5 text-gray-500" />
            <input type="text" placeholder="搜索..." class="neu-search-input">
          </div>
          <button class="neu-icon-button" @click="showNotifications = !showNotifications">
            <Bell class="w-5 h-5" />
            <span v-if="unreadCount > 0" class="neu-badge">{{ unreadCount }}</span>
          </button>
          <button class="neu-icon-button" @click="showProfile = !showProfile">
            <User class="w-5 h-5" />
          </button>
        </div>
      </div>
    </div>

    <!-- 侧边菜单 -->
    <div class="neu-side-menu" :class="{ 'is-open': isMenuOpen }">
      <nav class="space-y-2">
        <a href="#" class="neu-nav-item active">
          <Home class="w-5 h-5" />
          <span>首页</span>
        </a>
        <a href="#" class="neu-nav-item">
          <Inbox class="w-5 h-5" />
          <span>收件箱</span>
          <span class="neu-badge">12</span>
        </a>
        <a href="#" class="neu-nav-item">
          <Star class="w-5 h-5" />
          <span>收藏</span>
        </a>
        <a href="#" class="neu-nav-item">
          <Settings class="w-5 h-5" />
          <span>设置</span>
        </a>
      </nav>
    </div>

    <!-- 主要内容区 -->
    <div class="container mx-auto p-6">
      <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
        <!-- 统计卡片 -->
        <div class="neu-card">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">数据统计</h2>
            <div class="grid grid-cols-2 gap-4">
              <div class="neu-stat-card">
                <div class="neu-stat-icon">
                  <Users class="w-6 h-6" />
                </div>
                <div class="neu-stat-content">
                  <span class="text-gray-500">用户数</span>
                  <span class="text-2xl font-bold">1,234</span>
                </div>
              </div>
              <div class="neu-stat-card">
                <div class="neu-stat-icon">
                  <Activity class="w-6 h-6" />
                </div>
                <div class="neu-stat-content">
                  <span class="text-gray-500">活跃度</span>
                  <span class="text-2xl font-bold">89%</span>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 图表卡片 -->
        <div class="neu-card md:col-span-2">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">数据趋势</h2>
            <div class="neu-chart">
              <!-- 这里可以添加图表组件 -->
              <div class="h-48 flex items-end space-x-2">
                <div v-for="i in 7" :key="i" class="neu-chart-bar" :style="{ height: `${Math.random() * 100}%` }"></div>
              </div>
            </div>
          </div>
        </div>

        <!-- 任务列表 -->
        <div class="neu-card">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">任务列表</h2>
            <div class="space-y-4">
              <div v-for="task in tasks" :key="task.id" class="neu-task-item">
                <label class="neu-checkbox">
                  <input type="checkbox" v-model="task.completed">
                  <span class="neu-checkmark"></span>
                </label>
                <div class="flex-1">
                  <h3 class="font-medium" :class="{ 'line-through text-gray-400': task.completed }">
                    {{ task.title }}
                  </h3>
                  <p class="text-sm text-gray-500">{{ task.dueDate }}</p>
                </div>
                <button class="neu-icon-button">
                  <MoreVertical class="w-5 h-5" />
                </button>
              </div>
            </div>
          </div>
        </div>

        <!-- 消息列表 -->
        <div class="neu-card md:col-span-2">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">消息列表</h2>
            <div class="space-y-4">
              <div v-for="message in messages" :key="message.id" class="neu-message-item">
                <div class="neu-avatar" :class="message.avatarClass">
                  {{ message.initials }}
                </div>
                <div class="flex-1">
                  <div class="flex justify-between">
                    <h3 class="font-medium">{{ message.sender }}</h3>
                    <span class="text-sm text-gray-500">{{ message.time }}</span>
                  </div>
                  <p class="text-gray-600">{{ message.content }}</p>
                </div>
                <button class="neu-icon-button">
                  <MoreVertical class="w-5 h-5" />
                </button>
              </div>
            </div>
          </div>
        </div>

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

        <!-- 按钮组 -->
        <div class="neu-card">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">按钮样式</h2>
            <div class="space-y-4">
              <div class="flex flex-wrap gap-4">
                <button class="neu-button">主要按钮</button>
                <button class="neu-button outlined">次要按钮</button>
                <button class="neu-button text">文本按钮</button>
                <button class="neu-button icon">
                  <Plus class="w-5 h-5" />
                </button>
              </div>
              <div class="flex flex-wrap gap-4">
                <button class="neu-button small">小按钮</button>
                <button class="neu-button large">大按钮</button>
                <button class="neu-button loading">
                  <Loader2 class="w-5 h-5 animate-spin" />
                </button>
              </div>
            </div>
          </div>
        </div>

        <!-- 进度指示器 -->
        <div class="neu-card">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">进度指示器</h2>
            <div class="space-y-4">
              <div class="neu-progress">
                <div class="neu-progress-bar" style="width: 60%"></div>
              </div>
              <div class="neu-progress circular">
                <div class="neu-progress-circle"></div>
              </div>
              <div class="flex justify-between text-sm text-gray-500">
                <span>0%</span>
                <span>60%</span>
                <span>100%</span>
              </div>
            </div>
          </div>
        </div>

        <!-- 标签页 -->
        <div class="neu-card md:col-span-3">
          <div class="p-4">
            <h2 class="text-lg font-medium mb-4 text-gray-700">标签页</h2>
            <div class="neu-tabs">
              <button 
                v-for="tab in tabs" 
                :key="tab.id"
                class="neu-tab"
                :class="{ active: activeTab === tab.id }"
                @click="activeTab = tab.id"
              >
                {{ tab.label }}
              </button>
            </div>
            <div class="mt-4">
              <div v-if="activeTab === 'tab1'" class="neu-tab-content">
                <p>标签页 1 的内容</p>
              </div>
              <div v-if="activeTab === 'tab2'" class="neu-tab-content">
                <p>标签页 2 的内容</p>
              </div>
              <div v-if="activeTab === 'tab3'" class="neu-tab-content">
                <p>标签页 3 的内容</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

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

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

    <!-- 通知面板 -->
    <div v-if="showNotifications" class="neu-notification-panel">
      <div class="neu-notification-header">
        <h3 class="text-gray-700">通知</h3>
        <button class="neu-icon-button" @click="showNotifications = false">
          <X class="w-5 h-5" />
        </button>
      </div>
      <div class="neu-notification-list">
        <div v-for="notification in notifications" :key="notification.id" class="neu-notification-item">
          <div class="neu-notification-icon">
            <Bell class="w-5 h-5" />
          </div>
          <div class="flex-1">
            <h4 class="font-medium">{{ notification.title }}</h4>
            <p class="text-sm text-gray-500">{{ notification.content }}</p>
          </div>
          <span class="text-xs text-gray-400">{{ notification.time }}</span>
        </div>
      </div>
    </div>

    <!-- 个人资料面板 -->
    <div v-if="showProfile" class="neu-profile-panel">
      <div class="neu-profile-header">
        <div class="neu-avatar large">JD</div>
        <div class="ml-4">
          <h3 class="font-medium">John Doe</h3>
          <p class="text-sm text-gray-500">john.doe@example.com</p>
        </div>
        <button class="neu-icon-button" @click="showProfile = false">
          <X class="w-5 h-5" />
        </button>
      </div>
      <div class="neu-profile-menu">
        <a href="#" class="neu-profile-menu-item">
          <User class="w-5 h-5" />
          <span>个人资料</span>
        </a>
        <a href="#" class="neu-profile-menu-item">
          <Settings class="w-5 h-5" />
          <span>设置</span>
        </a>
        <a href="#" class="neu-profile-menu-item">
          <LogOut class="w-5 h-5" />
          <span>退出登录</span>
        </a>
      </div>
    </div>
  </div>
</template>

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

const showDialog = ref(false)
const showNotifications = ref(false)
const showProfile = ref(false)
const isMenuOpen = ref(false)
const activeTab = ref('tab1')
const unreadCount = ref(3)

const tasks = ref([
  { id: 1, title: '完成项目报告', dueDate: '今天', completed: false },
  { id: 2, title: '回复客户邮件', dueDate: '明天', completed: true },
  { id: 3, title: '准备会议材料', dueDate: '后天', completed: false }
])

const messages = ref([
  { 
    id: 1, 
    sender: 'Alice', 
    content: '你好，请问项目进展如何？', 
    time: '10:30', 
    initials: 'A',
    avatarClass: 'bg-blue-500'
  },
  { 
    id: 2, 
    sender: 'Bob', 
    content: '会议时间改到下午3点', 
    time: '09:15', 
    initials: 'B',
    avatarClass: 'bg-green-500'
  }
])

const notifications = ref([
  { 
    id: 1, 
    title: '新消息', 
    content: 'Alice 给你发送了一条消息', 
    time: '刚刚'
  },
  { 
    id: 2, 
    title: '系统通知', 
    content: '系统将在今晚进行维护', 
    time: '1小时前'
  }
])

const tabs = ref([
  { id: 'tab1', label: '标签页 1' },
  { id: 'tab2', label: '标签页 2' },
  { id: 'tab3', label: '标签页 3' }
])
</script>

<style scoped>
.neu-container {
  font-family: 'Inter', sans-serif;
}

.neu-app-bar {
  @apply sticky top-0 z-10 bg-gray-100;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

.neu-icon-button {
  @apply p-2 rounded-full text-gray-600;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-icon-button:active {
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-search-box {
  @apply flex items-center px-4 py-2 rounded-full;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-search-input {
  @apply ml-2 bg-transparent outline-none w-48;
}

.neu-side-menu {
  @apply fixed top-0 left-0 h-full w-64 bg-gray-100 p-4 transform -translate-x-full transition-transform duration-300;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

.neu-side-menu.is-open {
  @apply translate-x-0;
}

.neu-card {
  @apply rounded-xl p-4;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

.neu-stat-card {
  @apply flex items-center p-4 rounded-xl;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-stat-icon {
  @apply w-12 h-12 rounded-full flex items-center justify-center text-blue-500;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-stat-content {
  @apply ml-4;
}

.neu-chart {
  @apply p-4 rounded-xl;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-chart-bar {
  @apply w-8 bg-blue-500 rounded-t;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-task-item {
  @apply flex items-center space-x-4 p-2 rounded-lg;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-message-item {
  @apply flex items-center space-x-4 p-4 rounded-lg;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-nav-item {
  @apply flex items-center space-x-3 p-2 rounded-lg text-gray-600;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-nav-item:hover {
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-nav-item.active {
  @apply text-blue-500;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-badge {
  @apply bg-red-500 text-white text-xs px-2 py-1 rounded-full;
  box-shadow: 2px 2px 4px #d1d9e6, -2px -2px 4px #ffffff;
}

.neu-avatar {
  @apply w-10 h-10 rounded-full flex items-center justify-center text-white font-medium;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-avatar.large {
  @apply w-16 h-16;
}

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

.neu-input {
  @apply w-full px-4 py-2 rounded-lg text-gray-600;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-input:focus {
  @apply outline-none;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff, 0 0 0 2px rgba(59, 130, 246, 0.2);
}

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

.neu-checkmark,
.neu-radiomark {
  @apply w-5 h-5;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-checkmark {
  @apply rounded;
}

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

.neu-checkbox input:checked + .neu-checkmark,
.neu-radio input:checked + .neu-radiomark {
  @apply bg-blue-500;
  box-shadow: inset 4px 4px 8px #2563eb, inset -4px -4px 8px #3b82f6;
}

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

.neu-switch input {
  @apply hidden;
}

.neu-switch label {
  @apply relative inline-block w-12 h-6 rounded-full cursor-pointer;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-switch label:after {
  content: '';
  @apply absolute w-5 h-5 rounded-full top-0.5 left-0.5;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

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

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

.neu-button {
  @apply px-4 py-2 rounded-lg text-white;
  background: linear-gradient(145deg, #3b82f6, #2563eb);
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-button:hover {
  box-shadow: inset 4px 4px 8px #2563eb, inset -4px -4px 8px #3b82f6;
}

.neu-button.outlined {
  @apply bg-transparent border border-blue-500 text-blue-500;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-button.text {
  @apply bg-transparent border-none text-blue-500;
  box-shadow: none;
}

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

.neu-button.small {
  @apply px-3 py-1 text-sm;
}

.neu-button.large {
  @apply px-6 py-3 text-lg;
}

.neu-button.loading {
  @apply cursor-wait;
}

.neu-progress {
  @apply h-2 rounded-full overflow-hidden;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-progress-bar {
  @apply h-full rounded-full;
  background: linear-gradient(145deg, #3b82f6, #2563eb);
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-progress.circular {
  @apply w-12 h-12 rounded-full;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

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

.neu-tabs {
  @apply flex space-x-2 p-1 rounded-lg;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-tab {
  @apply px-4 py-2 rounded-md text-gray-600;
  transition: all 0.2s ease;
}

.neu-tab:hover {
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-tab.active {
  @apply text-blue-500;
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}

.neu-tab-content {
  @apply p-4 rounded-lg;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-bottom-nav {
  @apply fixed bottom-0 left-0 right-0 flex justify-around items-center py-2 bg-gray-100;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

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

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

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

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

.neu-dialog {
  @apply rounded-lg p-4 bg-gray-100 w-full max-w-md;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

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

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

.neu-dialog-actions {
  @apply flex justify-end space-x-2 p-4 border-t border-gray-200;
}

.neu-notification-panel {
  @apply fixed top-0 right-0 w-80 bg-gray-100 rounded-lg;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

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

.neu-notification-list {
  @apply max-h-96 overflow-y-auto;
}

.neu-notification-item {
  @apply flex items-center space-x-4 p-4 border-b border-gray-200;
}

.neu-notification-icon {
  @apply w-10 h-10 rounded-full flex items-center justify-center text-blue-500;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
}

.neu-profile-panel {
  @apply fixed top-0 right-0 w-80 bg-gray-100 rounded-lg;
  box-shadow: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
}

.neu-profile-header {
  @apply flex items-center p-4 border-b border-gray-200;
}

.neu-profile-menu {
  @apply space-y-2 p-4;
}

.neu-profile-menu-item {
  @apply flex items-center space-x-3 p-2 rounded-lg text-gray-600;
  box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
  transition: all 0.2s ease;
}

.neu-profile-menu-item:hover {
  box-shadow: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
}
</style> 