<script setup>
import { ref } from 'vue'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { useAppStore } from './stores/app.js'

const statusBarHeight = ref(0)
const safeAreaTop = ref(0)
const safeAreaBottom = ref(0)

onLaunch(async () => {
  console.log('App Launch')
  const store = useAppStore()
  await store.initialize()

  // 使用新的推荐 API 替代已弃用的 getSystemInfoSync
  const deviceInfo = uni.getDeviceInfo()
  const windowInfo = uni.getWindowInfo()
  const appBaseInfo = uni.getAppBaseInfo()

  statusBarHeight.value = windowInfo.statusBarHeight || 20
  safeAreaTop.value = windowInfo.safeAreaInsets?.top || windowInfo.statusBarHeight || 20
  safeAreaBottom.value = windowInfo.safeAreaInsets?.bottom || 0
  uni.setStorageSync('statusBarHeight', statusBarHeight.value)
  uni.setStorageSync('safeAreaTop', safeAreaTop.value)
  uni.setStorageSync('safeAreaBottom', safeAreaBottom.value)
})

onShow(() => {
  console.log('App Show')
})

onHide(() => {
  console.log('App Hide')
})
</script>

<style>

page {
  background-color: #0F071A;
  color: #F3E8FF;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 28rpx;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

/* 标题字体 - Cinzel (原型标准) */
.font-serif, .page-title, .section-title {
  font-family: 'Cinzel', 'Inter', serif;
}

/* 星空背景 */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  opacity: var(--opacity);
  animation: float-star var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes float-star {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: var(--opacity);
  }
  50% {
    transform: translate(var(--x), var(--y)) scale(1.5);
    opacity: 1;
  }
}

.status-bar-space {
  width: 100%;
  background: transparent;
  flex-shrink: 0;
}

.safe-area-bottom {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-area-top {
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}

/* ==================== 玻璃态卡片 - 原型标准 ==================== */
.glass-card {
  background: rgba(168, 85, 247, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(168, 85, 247, 0.15);
  border-radius: 40rpx; /* 原型标准：2.5rem = 40px */
  transition: all 0.3s ease;
}

.glass-card:active {
  transform: scale(0.98);
  box-shadow: 0 4rpx 20rpx rgba(168, 85, 247, 0.05);
}

.glass-card-gold {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(232, 121, 249, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 40rpx;
  box-shadow: inset 0 0 20rpx rgba(168, 85, 247, 0.08),
              0 0 20px rgba(168, 85, 247, 0.1);
  transition: all 0.3s ease;
}

.glass-card-gold:active {
  transform: scale(0.98);
  box-shadow: inset 0 0 10rpx rgba(168, 85, 247, 0.05),
              0 2rpx 12px rgba(168, 85, 247, 0.08);
}

/* 原型标准输入框 - 40rpx 圆角 */
.glass-input {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(168, 85, 247, 0.15);
  border-radius: 40rpx; /* 原型标准：2.5rem = 40px */
  padding: 24rpx 32rpx;
  color: #F3E8FF;
  font-size: 28rpx;
  transition: all 0.3s ease;
}

.glass-input:active {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}

.glass-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* 发光边框 - 头像/卡片专用 */
.glow-border {
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

/* 强发光效果 - 头像专用 */
.glow-strong {
  box-shadow: 0 0 40px rgba(168, 85, 247, 0.1);
}

/* 左侧紫色边框 - 记录卡片专用 */
.border-left-purple {
  border-left: 4rpx solid #C084FC;
}

.btn-primary {
  background: linear-gradient(135deg, #9333EA 0%, #7C3AED 100%);
  border-radius: 32rpx;
  padding: 28rpx 48rpx;
  color: white !important;
  font-weight: 600;
  font-size: 30rpx;
  border: none;
  box-shadow: 0 8rpx 32rpx rgba(168, 85, 247, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24rpx;
  padding: 24rpx 40rpx;
  color: rgba(255, 255, 255, 0.8);
  font-size: 28rpx;
}

.bottom-nav {
  background: rgba(15, 7, 26, 0.85);
  backdrop-filter: blur(40rpx);
  -webkit-backdrop-filter: blur(40rpx);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-item {
  color: rgba(255, 255, 255, 0.3);
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.nav-item.active {
  color: #C084FC;
  transform: translateY(-8rpx);
  text-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
}

.step-indicator {
  display: flex;
  gap: 12rpx;
}

.step-dot {
  width: 24rpx;
  height: 8rpx;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4rpx;
  transition: all 0.7s ease;
}

.step-dot.active {
  width: 40rpx;
  background: #A855F7;
  box-shadow: 0 0 24rpx rgba(168, 85, 247, 0.6);
}

.hint-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 32rpx;
  padding: 12rpx 24rpx;
  font-size: 22rpx;
  color: rgba(243, 232, 255, 0.8);
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8rpx);
  transition: all 0.2s ease;
}

.hint-chip:active {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.4);
  transform: scale(1.05);
  box-shadow: 0 8rpx 15rpx rgba(168, 85, 247, 0.3);
}

.ai-reply-card {
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 20rpx;
  padding: 24rpx;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.1);
}

.typing-text {
  overflow: hidden;
  white-space: pre-wrap;
  animation: reveal 2s steps(60, end);
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10rpx); }
  to { opacity: 1; transform: translateY(0); }
}

/* 星芒加载动画 - 原型标准（双环旋转） */
.starlight-loader {
  position: relative;
  width: 80rpx;
  height: 80rpx;
  margin: 40rpx auto;
}

.starlight-loader::before,
.starlight-loader::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3rpx solid transparent;
  border-top-color: #C084FC;
  border-right-color: #A855F7;
  animation: starlight-spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.starlight-loader::before {
  width: 70%;
  height: 70%;
  border-top-color: #E879F9;
  border-right-color: #9333EA;
  animation-delay: -0.75s;
}

@keyframes starlight-spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) rotate(180deg) scale(1.2);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg) scale(1);
  }
}

/* 加载文字 - 脉冲效果 */
.loading-text {
  text-align: center;
  font-size: 24rpx;
  color: rgba(192, 132, 252, 0.6);
  letter-spacing: 4rpx;
  margin-top: 24rpx;
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* 简化 loader 备用 */
.starlight-loader-simple {
  width: 44rpx;
  height: 44rpx;
  border-radius: 50%;
  border: 2rpx solid #A855F7;
  border-top-color: transparent;
  animation: spin 0.8s infinite linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

::-webkit-scrollbar-thumb {
  background: transparent;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20rpx); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.animate-pulse-slow {
  animation: pulse 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10rpx); }
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.text-primary { color: #A855F7; }
.text-primary-light { color: #C084FC; }
.text-accent { color: #E879F9; }
.text-muted { color: rgba(255, 255, 255, 0.4); }
.text-white-90 { color: rgba(255, 255, 255, 0.9); }
.text-white-70 { color: rgba(255, 255, 255, 0.7); }
.text-white-50 { color: rgba(255, 255, 255, 0.5); }
.font-serif { font-family: 'Cinzel', serif; }

.bg-dark { background-color: #0F071A; }
.bg-gradient-purple {
  background: linear-gradient(180deg, #1A0B2E 0%, #0F071A 50%, #050208 100%);
}
.bg-aurora-top {
  background: rgba(168, 85, 247, 0.08);
  filter: blur(120rpx);
  border-radius: 50%;
}
.bg-aurora-bottom {
  background: rgba(139, 92, 246, 0.05);
  filter: blur(100rpx);
  border-radius: 50%;
}

.safe-area-bottom {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-area-top {
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}
</style>
