<template>
  <div class="measurement-panel">
    <div class="measurement-content">
      <h5>测量结果</h5>
      <div class="measurement-item" v-if="result.distance">
        <span>长度：</span>
        <strong>{{ result.distance.toFixed(2) }} 米</strong>
      </div>
      <div class="measurement-item" v-if="result.area">
        <span>面积：</span>
        <strong>{{ (result.area / 1000000).toFixed(2) }} 平方千米</strong>
      </div>
      <div class="measurement-item" v-if="result.radius">
        <span>半径：</span>
        <strong>{{ result.radius.toFixed(2) }} 米</strong>
      </div>
      <button @click="handleClose" class="close-btn">关闭</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MeasurementPanel',
  props: {
    result: {
      type: Object,
      default: null
    }
  },
  methods: {
    handleClose() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.measurement-panel {
  position: absolute;
  bottom: 20px;
  right: 80px;
  z-index: 85;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 20px;
  min-width: 250px;
}

.measurement-content h5 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #409EFF;
  padding-bottom: 8px;
}

.measurement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #666;
}

.measurement-item strong {
  color: #409EFF;
  font-weight: 600;
}

.close-btn {
  width: 100%;
  padding: 10px;
  background: #409EFF;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  margin-top: 15px;
}

.close-btn:hover {
  background: #66b1ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}

@media (max-width: 768px) {
  .measurement-panel {
    bottom: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
  }
}
</style>
