<template>
  <div v-if="visible" class="success-dialog-overlay" @click.self="handleClose">
    <div class="success-dialog">
      <div class="success-dialog-content">
        <div class="success-icon">✓</div>
        <div class="success-message">{{ message }}</div>
      </div>
      <div class="success-dialog-footer">
        <button class="confirm-button" @click="handleClose">确定</button>
      </div>
    </div>
  </div>
</template>

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

const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  message: {
    type: String,
    required: true
  }
})

const emit = defineEmits(['close'])

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

<style scoped>
.success-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.success-dialog {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  animation: dialog-fade-in 0.3s ease;
}

.success-dialog-content {
  padding: 20px;
  text-align: center;
}

.success-icon {
  font-size: 48px;
  color: #67c23a;
  margin-bottom: 16px;
  font-weight: bold;
}

.success-message {
  color: #606266;
  font-size: 16px;
  line-height: 1.5;
}

.success-dialog-footer {
  padding: 10px 20px 20px;
  text-align: center;
}

.confirm-button {
  background-color: #67c23a;
  color: white;
  border: none;
  padding: 8px 24px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.confirm-button:hover {
  background-color: #85ce61;
}

@keyframes dialog-fade-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 移动端适配 */
@media screen and (max-width: 480px) {
  .success-dialog {
    width: 85%;
  }

  .success-icon {
    font-size: 40px;
  }

  .success-message {
    font-size: 14px;
    padding: 16px;
  }

  .confirm-button {
    padding: 6px 20px;
    font-size: 13px;
  }
}
</style> 