<template>
  <transition name="fade">
    <div v-if="visible" class="success-overlay">
      <div class="success-content">
        <div class="success-close" @click="$emit('close')">×</div>
        <div class="success-icon">
          <svg viewBox="0 0 24 24" class="checkmark">
            <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z" />
          </svg>
        </div>
        <div class="success-title">
          <!-- 打卡成功 -->
          {{ $t("checkin.punch.status.success") }}
        </div>
        <div class="success-info">
          <div class="info-item">
            <span class="label">
              <!-- 打卡时间 -->
              {{ $t("checkin.punch.status.clockInTime") }}
            </span>
            <span class="value">{{ punchTime }}</span>
          </div>
          <div class="info-item">
            <span class="label">
              <!-- 打卡地点 -->
              {{ $t("checkin.punch.status.clockInLocation") }}
            </span>
            <span class="value">{{ location }}</span>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'SuccessDialog',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    punchTime: {
      type: String,
      default: ''
    },
    location: {
      type: String,
      default: ''
    }
  },
  emits: ['close']
}
</script>

<style lang="scss" scoped>
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.success-content {
  background: white;
  border-radius: 20px;
  padding: 30px;
  width: 80%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: popIn 0.3s ease-out;
  position: relative;
}

.success-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s ease;

  &:hover {
    background: #f5f5f5;
    color: #666;
  }

  &:active {
    transform: scale(0.95);
  }
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: #4caf50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkmark {
  width: 40px;
  height: 40px;
  fill: white;
}

.success-title {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
}

.success-info {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 15px;
}

.info-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  text-align: left;
  
  &:last-child {
    margin-bottom: 0;
  }
}

.label {
  color: #666;
  font-size: 14px;
}

.value {
  color: #333;
  font-size: 14px;
  font-weight: 500;
}

@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style> 