<template>
  <el-dialog
    :model-value="visible"
    title=""
    width="420px"
    class="delete-dialog"
    :show-close="false"
    align-center
    :close-on-click-modal="false"
    @update:model-value="$emit('update:visible', $event)"
  >
    <template #header>
      <div class="delete-dialog-header">
        <div class="delete-icon-wrapper">
          <el-icon size="28"><WarningFilled /></el-icon>
        </div>
        <h3>{{ title }}</h3>
      </div>
    </template>
    <div class="delete-dialog-body">
      <p>
        确定要删除 <strong>{{ itemName }}</strong> 吗？
      </p>
      <p class="warning-text">{{ warningText }}</p>
    </div>
    <template #footer>
      <div class="delete-dialog-footer">
        <el-button
          @click="handleCancel"
          class="btn-cancel-delete"
        >
          取消
        </el-button>
        <el-button
          type="danger"
          :loading="loading"
          @click="handleConfirm"
          class="btn-delete"
        >
          <el-icon v-if="!loading"><Delete /></el-icon>
          确认删除
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    default: '删除项目'
  },
  itemName: {
    type: String,
    default: ''
  },
  warningText: {
    type: String,
    default: '此操作不可恢复，所有相关数据将被永久删除'
  },
  loading: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits(['update:visible', 'confirm', 'cancel'])

const handleConfirm = () => {
  emit('confirm')
}

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

<style scoped>
.delete-dialog :deep(.el-dialog) {
  background: linear-gradient(145deg, #1a1a2e 0%, #16162a 100%);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(239, 68, 68, 0.1);
}

.delete-dialog :deep(.el-dialog__header) {
  padding: 24px 24px 12px;
}

.delete-dialog :deep(.el-dialog__body) {
  padding: 0 24px 24px;
}

.delete-dialog :deep(.el-dialog__footer) {
  padding: 0;
}

.delete-dialog-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.delete-icon-wrapper {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50%;
  color: #ef4444;
}

.delete-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.delete-dialog-body {
  text-align: center;
  padding: 8px 0;
}

.delete-dialog-body p {
  margin: 0;
  color: #ccc;
  font-size: 14px;
}

.delete-dialog-body p strong {
  color: #fff;
}

.delete-dialog-body .warning-text {
  margin-top: 8px;
  color: #ef4444;
  font-size: 13px;
}

.delete-dialog-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-cancel-delete {
  padding: 10px 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #ccc;
  transition: all 0.2s ease;
}

.btn-cancel-delete:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-delete {
  padding: 10px 24px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.25s ease;
}

.btn-delete:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}
</style>
