<template>
  <div v-if="visible" class="error-dialog-overlay" @click.self="handleClose">
    <div class="error-dialog">
      <div class="error-dialog-content">
        {{ message }}
      </div>
      <div class="error-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
  },
  title: {
    type: String,
    default: '错误提示'
  },
  message: {
    type: String,
    required: true
  }
})

const emit = defineEmits(['close'])

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

<style scoped>
.error-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: 2000;
}

.error-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;
}

.error-dialog-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.error-dialog-header h3 {
  margin: 0;
  color: #f56c6c;
  font-size: 18px;
  font-weight: 500;
}

.close-button {
  background: none;
  border: none;
  font-size: 24px;
  color: #909399;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-button:hover {
  color: #f56c6c;
}

.error-dialog-content {
  padding: 20px;
  color: #606266;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
}

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

.confirm-button {
  background-color: #f56c6c;
  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: #f78989;
}

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

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

  .error-dialog-header h3 {
    font-size: 16px;
  }

  .error-dialog-content {
    font-size: 14px;
    padding: 16px;
  }

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