<template>
  <Teleport to="body">
    <transition name="fade">
      <div v-if="visible" class="modal-mask" @click="close">

        <div class="modal-container" @click.stop>

          <div class="modal-title">资金费率</div>

          <div class="modal-text">
                  费率为正，做多仓位支付做空仓位
                  费率为负，做空仓位支付做多仓位
          </div>

          <button class="main-btn" @click="close">
            我知道了
          </button>

        </div>
      </div>
    </transition>
  </Teleport>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';

defineProps({
  visible: Boolean
});

const emit = defineEmits(['update:visible']);

const close = () => {
  emit('update:visible', false);
};
</script>

<style scoped>
/* --- 布局与遮罩 --- */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6); /* 深色遮罩 */
  display: flex;
  align-items: center; /* 垂直居中 */
  justify-content: center; /* 水平居中 */
  z-index: 2000;
}

/* --- 弹窗卡片 --- */
.modal-container {
  width: 310px; /* 稍微宽一点，适配文字换行 */
  background: #fff;
  border-radius: 16px; /* 大圆角 */
  padding: 24px 24px;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* --- 标题 --- */
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  margin-bottom: 16px;
}

/* --- 正文 --- */
.modal-text {
  font-size: 15px;
  color: #555; /* 稍微柔和的深灰色 */
  line-height: 1.6; /* 增加行高，易读 */
  text-align: justify; /* 两端对齐，像报纸一样整齐 */
  max-width: 226px;
  margin: 24px auto;
}

/* --- 红色按钮 --- */
.main-btn {
  width: 100%;
  height: 46px;
  background: #DE3545; /* 截图里的标准红 */
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: 23px; /* 高度的一半，形成胶囊形状 */
  cursor: pointer;
}
.main-btn:active {
  opacity: 0.8; /* 点击反馈 */
}

/* --- 动画效果: 缩放弹入 --- */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.2s ease;
}
.fade-enter-active .modal-container {
  animation: pop-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); /* 弹性动画 */
}
.fade-leave-active .modal-container {
  animation: pop-in 0.3s reverse;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}

@keyframes pop-in {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
</style>