<template>
  <div class="go-scene-distribution">
    <div class="header">
      <div class="title">
        <svg-icon icon-class="rocket" class="title-icon"></svg-icon>
        <span :style="{ color: option.titleColor, fontSize: option.titleSize + 'px' }">{{ option.title }}</span>
      </div>
      <a class="link" :style="{ color: option.linkColor }">{{ option.linkText }}</a>
    </div>
    <div class="content">
      <div v-for="(item, index) in option.dataset" :key="index" class="scene-item">
        <div class="item-label" :style="{ color: option.labelColor, fontSize: option.labelSize + 'px' }">{{ item.label }}</div>
        <div class="cube-container">
          <img :src="getImageUrl(item.image)" class="cube-image" />
        </div>
        <div class="value-container">
          <span class="item-value" :style="{ color: option.valueColor, fontSize: option.valueSize + 'px' }">{{ item.value }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType, computed } from 'vue'
import { option as configOption } from './config'

const props = defineProps({
  chartConfig: {
    type: Object as PropType<{ option: typeof configOption }>,
    required: true
  }
})

const option = computed(() => props.chartConfig.option)

const getImageUrl = (name: string) => {
  return new URL(`./assets/${name}`, import.meta.url).href
}
</script>

<style lang="scss" scoped>
.go-scene-distribution {
  width: 100%;
  height: 100%;
  background-color: #020C22;
  padding: 15px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(21, 44, 78, 0.5);
    border-top: 2px solid #00AFFF;
    padding: 5px 15px;
    margin-bottom: 20px;

    .title {
      display: flex;
      align-items: center;
      .title-icon {
        font-size: 24px;
        margin-right: 10px;
        color: #00E5FF;
      }
    }

    .link {
      cursor: pointer;
      font-size: 14px;
    }
  }

  .content {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }

  .scene-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;

    .item-label {
      margin-bottom: 20px;
      font-family: 'Microsoft YaHei', 'Arial', sans-serif;
    }

    .cube-container {
      position: relative;
      width: 150px;
      height: 150px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 20px;

      .cube-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
      }
    }

    .value-container {
      background: linear-gradient(to bottom, #1E3A5E, #0F1C3D);
      border: 1px solid #2A588A;
      border-radius: 10px;
      padding: 5px 30px;
      box-shadow: 0 0 10px rgba(0, 229, 255, 0.5) inset;
      border-bottom: 3px solid #00E5FF;
    }

    .item-value {
      font-weight: bold;
      font-family: 'DS-Digital', 'Arial', sans-serif;
      text-shadow: 0 0 10px #00E5FF;
    }
  }
}
</style>
