<template>
  <view class="container">
    <view class="header">
      <view class="language-switch" @click="handleLanguageSwitch">
        <text class="language-text">{{ currentLocaleName }}</text>
      </view>
      <text class="title">{{ t('home.title') }}</text>
      <text class="subtitle">{{ t('home.subtitle') }}</text>
    </view>
    
    <view class="content">
      <view class="card">
        <text class="card-title">{{ t('home.systemInfo') }}</text>
        <view class="info-item">
          <text class="label">{{ t('home.framework') }}:</text>
          <text class="value">{{ t('home.frameworkValue') }}</text>
        </view>
        <view class="info-item">
          <text class="label">{{ t('home.platform') }}:</text>
          <text class="value">{{ t('home.platformValue') }}</text>
        </view>
      </view>
      
      <view class="action-section">
        <button type="primary" @click="handleClick">{{ t('home.startButton') }}</button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useLocaleStore } from '@/store/locale'

const { t } = useI18n()
const localeStore = useLocaleStore()

// 获取当前语言名称
const currentLocaleName = computed(() => localeStore.getCurrentLocaleName())

// 切换语言
const handleLanguageSwitch = () => {
  const success = localeStore.toggleLocale()
  if (success) {
    uni.showToast({
      title: t('common.language.switchSuccess'),
      icon: 'success'
    })
  }
}

const handleClick = () => {
  uni.showToast({
    title: t('home.welcomeMessage'),
    icon: 'success'
  })
}
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  padding: 40rpx;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.header {
  text-align: center;
  padding: 60rpx 0;
  position: relative;
  
  .language-switch {
    position: absolute;
    top: 20rpx;
    right: 20rpx;
    background: rgba(255, 255, 255, 0.2);
    padding: 12rpx 24rpx;
    border-radius: 30rpx;
    backdrop-filter: blur(10rpx);
    border: 1rpx solid rgba(255, 255, 255, 0.3);
    
    .language-text {
      font-size: 24rpx;
      color: #ffffff;
      font-weight: 500;
    }
  }
  
  .title {
    display: block;
    font-size: 48rpx;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 20rpx;
  }
  
  .subtitle {
    display: block;
    font-size: 28rpx;
    color: rgba(255, 255, 255, 0.8);
  }
}

.content {
  .card {
    background: #ffffff;
    border-radius: 20rpx;
    padding: 40rpx;
    margin-bottom: 40rpx;
    box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
    
    .card-title {
      display: block;
      font-size: 32rpx;
      font-weight: bold;
      color: #333333;
      margin-bottom: 30rpx;
    }
    
    .info-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20rpx 0;
      border-bottom: 1rpx solid #f0f0f0;
      
      &:last-child {
        border-bottom: none;
      }
      
      .label {
        font-size: 28rpx;
        color: #666666;
      }
      
      .value {
        font-size: 28rpx;
        color: #333333;
        font-weight: 500;
      }
    }
  }
  
  .action-section {
    padding: 20rpx 0;
    
    button {
      width: 100%;
      height: 88rpx;
      line-height: 88rpx;
      border-radius: 44rpx;
      font-size: 32rpx;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
  }
}
</style>
