<template>
  <SmallBorder>
    <div class="go-workshop-scene">
      <div class="header">
        <div class="title">
          <div class="title-text">
            <span :style="{
              color: option.titleColor,
              fontSize: option.titleSize + 'px',
              fontWeight: option.fontWeight,
              fontStyle: option.fontStyle,
              marginLeft: option.paddingX + 'px',
              marginTop: option.paddingY + 'px',
              letterSpacing: option.letterSpacing + 'px'
            }">{{ option.title }}</span>
          </div>
        </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>
  </SmallBorder>
</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'
import SmallBorder from '../SmallBorder/index.vue'

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 {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 12px;
  padding-top: 0; // Let the header handle top padding
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px; // More space
    margin-top: 5px;

    .title {
      display: flex;
      align-items: center;
      margin-top: -5px;

      .title-text {
        height: 35px;
        display: flex;
        align-items: center;
        padding: 0 20px 0 20px;
      }
    }

    .link {
      cursor: pointer;
      font-size: 16px; // Bigger link text
      margin-right: 20px;
    }
  }

  .content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; // Center the rows vertically
    gap: 20px; // Space between rows
  }

  .scene-row {
    display: flex;
    align-items: center;
    padding: 0 25px;
    height: 100px; // Taller rows
    background-size: 100% 100%;
    background-repeat: no-repeat;

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

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

  .scene-icon-container {
    position: relative;
    width: 72px; // Bigger icon container
    height: 72px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.5) 0%, rgba(15, 28, 61, 0) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    .yellow-dot {
      position: absolute;
      top: 8px;
      left: 8px; // Positioned differently in 1.png
      width: 12px;
      height: 12px;
      background-color: #FFD700;
      border-radius: 50%;
    }

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

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

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

    .separator {
      width: 1px;
      height: 50px;
      background-color: #00E5FF;
      margin: 0 30px;
      position: relative;

      &::before, &::after {
        content: '';
        position: absolute;
        left: -2px;
        width: 5px;
        height: 5px;
        background-color: #00E5FF;
        border-radius: 50%;
      }
      &::before {
        top: -1px;
      }
      &::after {
        bottom: -1px;
      }
    }
  }

  .metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    
    .metric-label {
      display: flex;
      align-items: center;
      margin-bottom: 10px; // More space
      .point {
        width: 10px; // Bigger point
        height: 10px;
        border-radius: 50%;
        margin-right: 10px;
      }
    }
    .metric-value {
      font-weight: bold;
      margin-left: 20px; // Align with label text
    }
  }
}
</style>
