<template>
  <view class="popup-mask" v-if="visible" @click="handleClose">
    <view class="popup-content" @click.stop>
      <!-- 标题栏 -->
      <view class="popup-header">
        <text class="popup-title">{{ t('home.guide') }}</text>
        <view class="close-btn" @click="handleClose">
          <image class="close-icon" src="/static/ic_close.png" mode="aspectFit" />
        </view>
      </view>
      <!-- 内容区域 -->
      <scroll-view class="popup-body" scroll-y>
        <rich-text :nodes="content" />
      </scroll-view>
    </view>
  </view>
</template>

<script setup>
import { useI18n } from 'vue-i18n'

const { t } = useI18n()

defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  content: {
    type: String,
    default: ''
  }
})

const emit = defineEmits(['close'])

function handleClose() {
  emit('close')
}
</script>

<style scoped>
.popup-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.popup-content {
  width: 650rpx;
  max-height: 70vh;
  background-color: #ffffff;
  border-radius: 24rpx;
  padding: 40rpx;
  display: flex;
  flex-direction: column;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 36rpx;
}

.popup-title {
  font-size: 34rpx;
  font-weight: 600;
  color: #333;
}

.close-btn {
  width: 48rpx;
  height: 48rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0;
}

.close-icon {
  width: 36rpx;
  height: 36rpx;
}

.popup-body {
  flex: 1;
  max-height: 55vh;
  padding-bottom: 40rpx;
}
</style>
