<template>
  <el-dialog
    v-model="visible"
    :title="title"
    width="500px"
    class="payment-modal"
    :modal="true"
    :close-on-click-modal="false"
    :close-on-press-escape="true"
    @close="handleClose"
    :show-close="true"
    custom-class="payment-modal-dialog"
    :modal-class="'payment-modal-overlay'"
  >
    <div class="payment-content">
      <!-- 支付方式选择 -->
      <div class="payment-methods">
        <div 
          class="payment-method" 
          :class="{ active: selectedMethod === 'alipay' }"
          @click="selectMethod('alipay')"
        >
          <div class="method-icon alipay-icon">
            <el-icon><CreditCard /></el-icon>
          </div>
          <span>Alipay扫码支付</span>
        </div>
      </div>

      <!-- 金额显示 -->
      <div class="amount-section">
        <div class="amount-label">金额</div>
        <div class="amount-value">${{ amount }}</div>
      </div>

      <!-- 二维码区域 -->
      <div class="qr-section">
        <div class="qr-code">
          <img id="qr-code-img" style="display: none; width: 200px; height: 200px; margin: 0; padding: 0; border: none; object-fit: contain; background: #1a1a1a;" alt="支付二维码" />
          <div ref="qrPlaceholder" class="qr-placeholder">
            <div class="qr-grid">
              <div class="qr-dot" v-for="i in 64" :key="i"></div>
            </div>
          </div>
        </div>
        <div class="qr-tip">支付前请阅读《Vionow支付服务条款》</div>
      </div>

      <!-- 支付提示 -->
      <div class="action-section">
        <div class="pay-tip">
          <p>请使用支付宝扫描上方二维码完成支付</p>
          <p class="tip-small">支付完成后页面将自动更新</p>
        </div>
        <!-- 模拟支付完成按钮（仅用于测试） -->
        <div class="test-payment-section" style="margin-top: 16px; text-align: center;">
          <button 
            class="test-payment-btn" 
            @click="handleTestPaymentComplete"
            :disabled="!currentPaymentId || loading"
            style="
              padding: 8px 16px;
              background: #ff9800;
              color: white;
              border: none;
              border-radius: 4px;
              cursor: pointer;
              font-size: 12px;
              opacity: 0.8;
            "
          >
            🧪 模拟支付完成（测试用）
          </button>
        </div>
      </div>

      <!-- 底部链接 -->
      <div class="footer-link">
        <a href="#" @click.prevent="showAgreement">《Vionow支付服务条款》</a>
      </div>
    </div>
  </el-dialog>
</template>

<script setup>
import { ref, watch, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { CreditCard } from '@element-plus/icons-vue'
import { createPayment, createAlipayPayment, getPaymentById, testPaymentComplete } from '@/api/payments'

const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    default: '标准版会员'
  },
  amount: {
    type: [String, Number],
    default: '32.00'
  },
  orderId: {
    type: String,
    default: ''
  }
})

const emit = defineEmits(['update:modelValue', 'pay-success', 'pay-error'])

const router = useRouter()
const visible = ref(false)
const selectedMethod = ref('alipay')
const loading = ref(false)
const currentPaymentId = ref(null)
let paymentPollingTimer = null

// 监听 modelValue 变化
watch(() => props.modelValue, (newVal) => {
  visible.value = newVal
  // 当模态框打开时，自动开始支付流程
  if (newVal) {
    handlePay()
  }
})

// 监听 visible 变化
watch(visible, (newVal) => {
  emit('update:modelValue', newVal)
  // 如果模态框关闭，停止轮询
  if (!newVal) {
    stopPaymentPolling()
  }
})

// 选择支付方式
const selectMethod = (method) => {
  selectedMethod.value = method
}

// 处理支付
const handlePay = async () => {
  try {
    loading.value = true
    ElMessage.info('正在创建支付订单...')
    
    // 创建支付订单数据
    const paymentData = {
      orderId: props.orderId,
      amount: props.amount.toString(),
      method: 'ALIPAY',
      description: `${props.title} - 支付宝支付`
    }

    console.log('=== 开始支付流程 ===')
    console.log('支付数据：', paymentData)
    
    // 先创建支付记录
    console.log('1. 创建支付订单...')
    const createResponse = await createPayment(paymentData)
    console.log('创建支付订单响应：', createResponse)
    
        if (createResponse.data && createResponse.data.success) {
      const paymentId = createResponse.data.data.id
      currentPaymentId.value = paymentId
      console.log('2. 支付订单创建成功，ID：', paymentId)
      
      ElMessage.info('正在生成支付宝二维码...')
      
      console.log('3. 创建支付宝支付...')
      // 创建支付宝支付
      const alipayResponse = await createAlipayPayment({ paymentId })
      console.log('支付宝支付响应：', alipayResponse)
      console.log('支付宝支付响应数据：', alipayResponse.data)
      console.log('支付宝支付响应数据详情：', JSON.stringify(alipayResponse.data, null, 2))
      
      if (alipayResponse.data && alipayResponse.data.success) {
        // 显示二维码
        const qrCode = alipayResponse.data.data.qrCode
        console.log('4. 支付宝二维码：', qrCode)
        
        // 使用在线API生成二维码图片（直接使用支付宝返回的URL生成二维码）
        try {
          console.log('开始生成二维码，内容:', qrCode)
          
          // 使用QuickChart API生成二维码，完全去除白边
          // 直接使用支付宝返回的URL作为二维码内容
          const qrCodeUrl = `https://quickchart.io/qr?text=${encodeURIComponent(qrCode)}&size=200&margin=0&dark=ffffff&light=1a1a1a`
          
          console.log('5. 二维码图片URL已生成')
          
          // 更新二维码显示
          const qrCodeElement = document.querySelector('#qr-code-img')
          if (qrCodeElement) {
            qrCodeElement.src = qrCodeUrl
            qrCodeElement.style.display = 'block'
            console.log('6. 二维码图片已设置')
          }
          
          // 隐藏模拟二维码
          const qrPlaceholder = document.querySelector('.qr-placeholder')
          if (qrPlaceholder) {
            qrPlaceholder.style.display = 'none'
            console.log('7. 模拟二维码已隐藏')
          }
          
          ElMessage.success('二维码已生成，请使用支付宝扫码支付')
          console.log('=== 支付流程完成，开始轮询支付状态 ===')
          
          // 开始轮询支付状态
          startPaymentPolling(paymentId)
        } catch (error) {
          console.error('生成二维码失败：', error)
          ElMessage.error('生成二维码失败，请重试')
        }
        
      } else {
        console.error('支付宝响应失败：', alipayResponse)
        ElMessage.error(alipayResponse.data?.message || '生成二维码失败')
        emit('pay-error', new Error(alipayResponse.data?.message || '生成二维码失败'))
      }
      
    } else {
      console.error('创建支付订单失败：', createResponse)
      ElMessage.error(createResponse.data?.message || '创建支付订单失败')
      emit('pay-error', new Error(createResponse.data?.message || '创建支付订单失败'))
    }
    
  } catch (error) {
    console.error('=== 支付流程出错 ===')
    console.error('错误详情：', error)
    console.error('错误响应：', error.response)
    console.error('错误状态：', error.response?.status)
    console.error('错误数据：', error.response?.data)
    
    ElMessage.error(`支付失败：${error.message || '请重试'}`)
    emit('pay-error', error)
  } finally {
    loading.value = false
  }
}

// 轮询支付状态
const startPaymentPolling = (paymentId) => {
  // 清除之前的轮询
  stopPaymentPolling()
  
  let pollCount = 0
  const maxPolls = 60 // 最多轮询60次（10分钟，每10秒一次）
  
  const poll = async () => {
    if (pollCount >= maxPolls) {
      console.log('轮询达到最大次数，停止轮询')
      stopPaymentPolling()
      return
    }
    
    try {
      console.log(`轮询支付状态 (${pollCount + 1}/${maxPolls})，支付ID:`, paymentId)
      const response = await getPaymentById(paymentId)
      
      if (response.data && response.data.success) {
        const payment = response.data.data
        const status = payment.status
        console.log('支付状态:', status, '状态说明:', getStatusDescription(status))
        
        if (status === 'SUCCESS' || status === 'COMPLETED') {
          console.log('✅ 支付成功！支付数据:', payment)
          stopPaymentPolling()
          ElMessage.success('支付成功！')
          emit('pay-success', payment)
          // 延迟关闭模态框
          setTimeout(() => {
            visible.value = false
          }, 2000)
          return
        } else if (status === 'FAILED' || status === 'CANCELLED') {
          console.log('支付失败或取消')
          stopPaymentPolling()
          ElMessage.warning('支付已取消或失败')
          emit('pay-error', new Error('支付已取消或失败'))
          return
        } else if (status === 'PROCESSING') {
          console.log('支付处理中...')
          // PROCESSING 状态继续轮询，但可以给用户提示
          if (pollCount % 6 === 0) { // 每60秒提示一次
            ElMessage.info('支付处理中，请稍候...')
          }
        } else if (status === 'PENDING') {
          console.log('支付待处理中（等待支付宝回调）...')
          // PENDING 状态继续轮询
          if (pollCount % 6 === 0) { // 每60秒提示一次
            ElMessage.info('等待支付确认，请确保已完成支付...')
          }
        }
      }
      
      // 继续轮询
      pollCount++
      paymentPollingTimer = setTimeout(poll, 10000) // 每10秒轮询一次
    } catch (error) {
      console.error('轮询支付状态失败:', error)
      // 错误时也继续轮询，直到达到最大次数
      pollCount++
      if (pollCount < maxPolls) {
        paymentPollingTimer = setTimeout(poll, 10000)
      }
    }
  }
  
  // 开始轮询（等待5秒后开始第一次轮询）
  setTimeout(() => {
    poll()
  }, 5000)
}

// 停止轮询支付状态
const stopPaymentPolling = () => {
  if (paymentPollingTimer) {
    clearTimeout(paymentPollingTimer)
    paymentPollingTimer = null
    console.log('已停止轮询支付状态')
  }
}

// 关闭模态框
const handleClose = () => {
  stopPaymentPolling()
  visible.value = false
}

// 组件卸载时清理轮询
onUnmounted(() => {
  stopPaymentPolling()
})

// 获取支付状态描述
const getStatusDescription = (status) => {
  const statusMap = {
    'PENDING': '待支付 - 等待用户扫码支付',
    'PROCESSING': '处理中 - 支付宝正在处理支付',
    'SUCCESS': '支付成功',
    'COMPLETED': '支付完成',
    'FAILED': '支付失败',
    'CANCELLED': '已取消',
    'REFUNDED': '已退款'
  }
  return statusMap[status] || '未知状态'
}

// 模拟支付完成（用于测试）
const handleTestPaymentComplete = async () => {
  if (!currentPaymentId.value) {
    ElMessage.warning('支付订单尚未创建，请稍候...')
    return
  }
  
  try {
    loading.value = true
    ElMessage.info('正在模拟支付完成...')
    
    console.log('模拟支付完成，支付ID:', currentPaymentId.value)
    const response = await testPaymentComplete(currentPaymentId.value)
    
    console.log('✅ 模拟支付完成响应:', response)
    console.log('✅ 响应数据:', response.data)
    
    if (response.data && response.data.success) {
      console.log('✅ 模拟支付完成成功，支付数据:', response.data.data)
      ElMessage.success('支付完成！')
      stopPaymentPolling()
      emit('pay-success', response.data.data)
      // 延迟关闭模态框
      setTimeout(() => {
        visible.value = false
      }, 2000)
    } else {
      console.error('❌ 模拟支付完成失败，响应:', response)
      ElMessage.error(response.data?.message || '模拟支付完成失败')
    }
  } catch (error) {
    console.error('模拟支付完成失败:', error)
    ElMessage.error(`模拟支付完成失败：${error.message || '请重试'}`)
  } finally {
    loading.value = false
  }
}

// 显示协议
const showAgreement = () => {
  router.push('/terms-of-service')
}
</script>

<style scoped>
.payment-modal {
  background: #000000 !important;
}

/* 移除所有可能的白边和边框 */
.payment-modal :deep(.el-dialog),
.payment-modal-dialog,
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog.el-dialog--center),
.payment-modal.el-dialog.el-dialog--center.payment-modal,
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog.el-dialog--center.payment-modal) {
  background: #000000 !important;
  background-color: #000000 !important;
  background-image: none !important;
  border-radius: 12px !important;
  border: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-style: none !important;
  outline-color: transparent !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  /* 移除所有可能的白色边框 */
  -webkit-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
  -moz-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 0 transparent !important;
}

/* 移除所有伪元素可能产生的边框 */
.payment-modal :deep(.el-dialog::before),
.payment-modal :deep(.el-dialog::after),
.payment-modal :deep(.el-dialog__wrapper::before),
.payment-modal :deep(.el-dialog__wrapper::after),
.payment-modal :deep(.el-dialog__body::before),
.payment-modal :deep(.el-dialog__body::after) {
  display: none !important;
  content: none !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* 移除所有可能的白色边框 - 使用更具体的选择器 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog *) {
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
}

.payment-modal :deep(.el-dialog__body) {
  padding: 0 !important;
  margin: 0 !important;
  background: #000000 !important;
  background-color: #000000 !important;
  border: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-style: none !important;
  outline-color: transparent !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* 移除对话框内部的所有边框和间隙 */
.payment-modal :deep(.el-dialog) * {
  border-color: transparent !important;
}

/* 确保对话框本身没有任何白色背景或边框 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog.el-dialog--center),
.payment-modal :deep(.payment-modal-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog),
.payment-modal :deep(.payment-modal-dialog.el-dialog--center),
.payment-modal :deep(.payment-modal-dialog.el-dialog--center.payment-modal) {
  background-color: #000000 !important;
  background: #000000 !important;
  background-image: none !important;
}

/* 移除所有可能的白色边框 */
.payment-modal :deep(.el-dialog),
.payment-modal :deep(.el-dialog__body) {
  border: 0 !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
}

.payment-modal :deep(.el-dialog__header),
.payment-modal :deep(.el-dialog__header.show-close) {
  background: #000000 !important;
  background-color: #000000 !important;
  border: none !important;
  border-bottom: 1px solid #1a1a1a !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-width: 0 !important;
  border-bottom-width: 1px !important;
  border-bottom-style: solid !important;
  border-bottom-color: #1a1a1a !important;
  padding: 20px 24px !important;
  margin: 0 !important;
  color: white !important;
  text-align: left !important;
}

/* 确保 header.show-close 内的所有文字都是白色 */
.payment-modal :deep(.el-dialog__header.show-close),
.payment-modal :deep(.el-dialog__header.show-close *),
.payment-modal :deep(.el-dialog__header.show-close .el-dialog__title),
.payment-modal :deep(.el-dialog__header.show-close .el-dialog__headerbtn) {
  color: white !important;
}

/* 确保关闭按钮区域背景也与模态框一致 */
.payment-modal :deep(.el-dialog__headerbtn),
.payment-modal :deep(.el-dialog__headerbtn.is-close),
.payment-modal :deep(.el-dialog__header .el-dialog__headerbtn) {
  background: transparent !important;
  background-color: transparent !important;
}

.payment-modal :deep(.el-dialog__headerbtn:hover) {
  background: rgba(255, 255, 255, 0.1) !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.payment-modal :deep(.el-dialog__wrapper) {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-width: 0 !important;
  border-style: none !important;
  border-color: transparent !important;
  outline: none !important;
  outline-width: 0 !important;
  outline-style: none !important;
  outline-color: transparent !important;
  background: transparent !important;
}

/* 确保 wrapper 内的所有对话框元素背景为黑色 */
.payment-modal :deep(.el-dialog__wrapper .el-dialog),
.payment-modal :deep(.el-dialog__wrapper .el-dialog.el-dialog--center),
.payment-modal :deep(.el-dialog__wrapper .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-dialog__wrapper .payment-modal-dialog) {
  background: #000000 !important;
  background-color: #000000 !important;
}

.payment-modal :deep(.el-overlay),
.payment-modal :deep(.payment-modal-overlay),
.payment-modal :deep(.el-overlay.payment-modal-overlay),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog) {
  background: rgba(0, 0, 0, 0.5) !important;
  border: none !important;
  outline: none !important;
}

/* 确保 el-overlay.payment-modal-overlay.el-modal-dialog 内的对话框背景为黑色 */
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog.el-dialog--center),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog__body),
.payment-modal :deep(.el-overlay.payment-modal-overlay.el-modal-dialog .el-dialog__header) {
  background: #000000 !important;
  background-color: #000000 !important;
}

.payment-modal :deep(.el-overlay-dialog) {
  background: rgba(0, 0, 0, 0.5) !important;
  border: none !important;
  outline: none !important;
}

/* 确保 el-overlay-dialog 内的对话框背景为黑色 */
.payment-modal :deep(.el-overlay-dialog .el-dialog),
.payment-modal :deep(.el-overlay-dialog .el-dialog.el-dialog--center),
.payment-modal :deep(.el-overlay-dialog .el-dialog.el-dialog--center.payment-modal),
.payment-modal :deep(.el-overlay-dialog .el-dialog__body),
.payment-modal :deep(.el-overlay-dialog .el-dialog__header) {
  background: #000000 !important;
  background-color: #000000 !important;
}

/* 确保遮罩层没有白边 */
.payment-modal :deep(.el-overlay.is-message-box) {
  background: rgba(0, 0, 0, 0.5) !important;
}

.payment-modal :deep(.el-dialog__title) {
  color: #ffffff !important;
  font-size: 18px !important;
  font-weight: bold !important;
  font-family: "SimSun", "宋体", serif !important;
  text-align: left !important;
  line-height: 1.5 !important;
  letter-spacing: 0.5px !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.3) !important;
  filter: brightness(1.1) contrast(1.2) !important;
}

.payment-modal :deep(.el-dialog__headerbtn) {
  color: white !important;
}

.payment-modal :deep(.el-dialog__headerbtn:hover) {
  color: white !important;
}

.payment-modal :deep(.el-dialog__headerbtn svg) {
  color: white !important;
  fill: white !important;
}

.payment-content {
  padding: 24px;
  background: #000000 !important;
  background-color: #000000 !important;
  color: white !important;
  margin: 0 !important;
  border: none !important;
  border-width: 0 !important;
  box-sizing: border-box !important;
}

/* 确保 payment-content 内的所有文字都是白色（链接除外） */
.payment-content,
.payment-content *:not(a),
.payment-content p,
.payment-content span,
.payment-content div {
  color: white !important;
}

/* 支付方式选择 */
.payment-methods {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.payment-method {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #1a1a1a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  color: white;
}

.payment-method:hover {
  background: #2a2a2a;
  box-shadow: 0 4px 16px rgba(74, 158, 255, 0.2);
}

.payment-method.active {
  background: linear-gradient(135deg, #4a9eff 0%, #3a8bdf 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(74, 158, 255, 0.3);
}

.method-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1677FF;
}

.payment-method.active .method-icon {
  color: white;
}

.payment-method span {
  font-size: 14px !important;
  font-weight: 500 !important;
  color: white !important;
  line-height: 1.5 !important;
  letter-spacing: 0.3px !important;
}

/* 金额显示 */
.amount-section {
  text-align: center;
  margin-bottom: 24px;
}

.amount-label {
  font-size: 14px !important;
  color: white !important;
  margin-bottom: 8px !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
  letter-spacing: 0.3px !important;
}

.amount-value {
  font-size: 32px !important;
  font-weight: 700 !important;
  color: white !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
  line-height: 1.2 !important;
  letter-spacing: 0.5px !important;
}

/* 二维码区域 */
.qr-section {
  text-align: center;
  margin-bottom: 24px;
}

.qr-code {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  padding: 0;
  background: #1a1a1a;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  line-height: 0;
}

.qr-code img {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  display: block;
  object-fit: contain;
  object-position: center;
  background: #1a1a1a;
  box-sizing: border-box;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.qr-placeholder {
  width: 180px;
  height: 180px;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.qr-placeholder::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  border: 3px solid #4a9eff;
  border-radius: 8px;
  transform: translate(-50%, -50%);
  opacity: 0.6;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.qr-placeholder::after {
  content: '扫码支付';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 40px));
  color: white !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  opacity: 0.8 !important;
  line-height: 1.5 !important;
  letter-spacing: 0.3px !important;
}

.qr-tip {
  font-size: 12px !important;
  color: white !important;
  line-height: 1.5 !important;
  letter-spacing: 0.2px !important;
  font-weight: 400 !important;
}

/* 操作按钮 */
.action-section {
  margin-bottom: 16px;
}

.pay-button {
  width: 100%;
  padding: 14px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pay-button:hover {
  background: #3a8bdf;
  transform: translateY(-1px);
}

.pay-button:active {
  transform: translateY(0);
}

.pay-button:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
}

.pay-button:disabled:hover {
  background: #666;
  transform: none;
}

/* 支付提示 */
.pay-tip {
  text-align: center;
  padding: 20px;
  background: #1a1a1a;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pay-tip p {
  margin: 8px 0 !important;
  color: white !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  letter-spacing: 0.3px !important;
  font-weight: 400 !important;
}

.tip-small {
  color: white !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
  letter-spacing: 0.2px !important;
  font-weight: 400 !important;
  opacity: 0.8 !important;
}

/* 底部链接 */
.footer-link {
  text-align: center;
}

.footer-link a {
  color: #4a9eff !important;
  text-decoration: none !important;
  font-size: 12px !important;
  transition: color 0.3s ease !important;
  line-height: 1.5 !important;
  letter-spacing: 0.2px !important;
  font-weight: 400 !important;
}

.footer-link a:hover {
  color: #3a8bdf !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .payment-modal :deep(.el-dialog) {
    width: 90%;
    margin: 0 auto;
  }
  
  .payment-methods {
    flex-direction: column;
  }
  
  .qr-code {
    width: 160px;
    height: 160px;
  }
  
  .qr-placeholder {
    width: 140px;
    height: 140px;
  }
  
  .amount-value {
    font-size: 28px;
  }
}
</style>
