<template>
  <el-dialog
    :model-value="visible"
    title=""
    width="460px"
    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-header-top">
          <div class="delete-icon-wrapper">
            <el-icon size="26"><WarningFilled /></el-icon>
          </div>
          <div class="delete-kicker">Danger Zone</div>
        </div>
        <div class="delete-title-group">
          <h3>{{ title }}</h3>
          <p v-if="detailText" class="detail-text">{{ detailText }}</p>
        </div>
      </div>
    </template>
    <div class="delete-dialog-body">
      <div class="delete-target-card">
        <span class="target-label">目标对象</span>
        <strong class="target-name">{{ itemName }}</strong>
      </div>
      <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>
          {{ confirmText }}
        </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: '此操作不可恢复，所有相关数据将被永久删除'
  },
  detailText: {
    type: String,
    default: ''
  },
  confirmText: {
    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:
    radial-gradient(circle at top left, rgba(239, 68, 68, 0.14), transparent 24%),
    radial-gradient(circle at bottom right, rgba(251, 146, 60, 0.08), transparent 20%),
    linear-gradient(180deg, #11151d 0%, #0d1118 100%);
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

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

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

.delete-dialog-header {
  padding: 24px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.delete-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.delete-icon-wrapper {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(249, 115, 22, 0.08));
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 14px;
  color: #fb7185;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.delete-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(251, 113, 133, 0.72);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

.delete-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delete-dialog-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: -0.02em;
}

.detail-text {
  margin: 0;
  color: rgba(226, 232, 240, 0.72);
  font-size: 13px;
  line-height: 1.6;
}

.delete-dialog-body {
  padding: 22px 24px 24px;
}

.delete-target-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 14px;
}

.target-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.65);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
}

.target-name {
  color: #f8fafc;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

.warning-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: #fca5a5;
}

.delete-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 24px 24px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.14));
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.btn-cancel-delete {
  min-width: 108px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: rgba(226, 232, 240, 0.8);
  transition: all 0.2s ease;
}

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

.btn-delete {
  min-width: 128px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 55%, #b91c1c 100%);
  border: none;
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.25s ease;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.18);
}

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