<template>
  <view class="popup-mask" v-if="visible" @click="handleClose">
    <view class="popup-content" @click.stop>
      <text class="popup-title">{{ t('home.guide') }}</text>
      <scroll-view class="popup-body" scroll-y>
        <rich-text :nodes="content" />
      </scroll-view>
      <view class="close-btn" @click="handleClose">
        <text class="close-btn-text">{{ t('common.confirm') }}</text>
      </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.5);
  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-title {
  font-size: 34rpx;
  font-weight: 600;
  color: #333;
  text-align: center;
  display: block;
  margin-bottom: 30rpx;
}

.popup-body {
  flex: 1;
  max-height: 50vh;
  margin-bottom: 30rpx;
}

.close-btn {
  height: 80rpx;
  background-color: #007aff;
  border-radius: 40rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn-text {
  font-size: 28rpx;
  color: #ffffff;
}
</style>
