<template>
  <div class="go-workshop-scene">
    <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="(scene, index) in option.dataset" 
        :key="index" 
        class="scene-row" 
        :class="{ reverse: index % 2 !== 0 }"
        :style="{ backgroundImage: `url(${backgrounds[index]})` }"
      >
        <div class="scene-icon-container">
          <div class="yellow-dot"></div>
          <svg-icon :icon-class="scene.icon" class="scene-icon"></svg-icon>
        </div>
        <div class="scene-name" :style="{ color: option.sceneNameColor, fontSize: option.sceneNameSize + 'px' }">{{ scene.name }}</div>
        <div class="metrics-container">
          <template v-for="(metric, mIndex) in scene.metrics" :key="mIndex">
            <div class="metric">
              <div class="metric-label">
                <span class="point" :style="{ backgroundColor: mIndex === 0 ? option.pointColor1 : option.pointColor2 }"></span>
                <span :style="{ color: option.labelColor, fontSize: option.labelSize + 'px' }">{{ metric.label }}</span>
              </div>
              <div class="metric-value" :style="{ color: option.valueColor, fontSize: option.valueSize + 'px' }">{{ metric.value }}</div>
            </div>
            <div class="separator" v-if="mIndex < scene.metrics.length - 1"></div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType, computed } from 'vue'
import { option as configOption } from './config'
import bg1 from './assets/6.png'
import bg2 from './assets/04.png'

const backgrounds = [bg1, bg2]

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

const option = computed(() => props.chartConfig.option)
</script>

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

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1A385A;
    padding: 5px 15px;
    border-radius: 5px;
    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;
    flex-direction: column;
    justify-content: space-around;
  }

  .scene-row {
    display: flex;
    align-items: center;
    padding: 0 30px;
    margin: 10px 0;
    height: 90px;
    background-size: 100% 100%;
    background-repeat: no-repeat;

    &.reverse {
      flex-direction: row-reverse;

      .scene-name {
        margin-right: 0;
        margin-left: 20px;
      }
      
      .metrics-container {
        margin-right: auto;
        margin-left: 0;
      }
    }
  }

  .scene-icon-container {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, #00E5FF 0%, rgba(15, 28, 61, 0) 70%);
    display: flex;
    align-items: center;
    justify-content: center;

    .yellow-dot {
      position: absolute;
      top: 5px;
      right: 5px;
      width: 10px;
      height: 10px;
      background-color: #FFD700;
      border-radius: 50%;
    }

    .scene-icon {
      font-size: 32px;
      color: #ffffff;
    }
  }

  .scene-name {
    font-weight: bold;
    margin-left: 20px;
  }

  .metrics-container {
    display: flex;
    align-items: center;
    margin-left: auto;

    .separator {
      width: 1px;
      height: 40px;
      background-color: #00E5FF;
      margin: 0 20px;
    }
  }

  .metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    
    .metric-label {
      display: flex;
      align-items: center;
      margin-bottom: 5px;
      .point {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-right: 8px;
      }
    }
    .metric-value {
      font-weight: bold;
      margin-left: 16px;
    }
  }
}
</style>
