<template>
  <div class="go-storage-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-item">
        <div class="scene-header">
          <span class="dots">···</span>
          <span class="scene-name" :style="{ color: option.sceneNameColor, fontSize: option.sceneNameSize + 'px' }">{{ scene.name }}</span>
        </div>
        <div class="metrics-wrapper">
          <div v-for="(metric, mIndex) in scene.metrics" :key="mIndex" class="metric-box" :style="{ borderColor: option.borderColor }">
            <div class="metric-icon-container">
              <svg-icon :icon-class="metric.icon" class="metric-icon"></svg-icon>
            </div>
            <div class="metric-details">
              <span class="metric-label" :style="{ color: option.labelColor, fontSize: option.labelSize + 'px' }">{{ metric.label }}</span>
              <span class="metric-value" :style="{ color: option.valueColor, fontSize: option.valueSize + 'px' }">{{ metric.value }}</span>
            </div>
          </div>
        </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)
</script>

<style lang="scss" scoped>
.go-storage-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-item {
    margin-bottom: 15px;
  }

  .scene-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    .dots {
      color: #4A90E2;
      font-weight: bold;
      margin-right: 10px;
    }
    .scene-name {
      font-weight: bold;
    }
  }

  .metrics-wrapper {
    display: flex;
    justify-content: space-between;
  }

  .metric-box {
    display: flex;
    align-items: center;
    background-color: rgba(26, 56, 90, 0.5);
    border-bottom: 2px solid;
    padding: 10px;
    width: 48%;
    box-sizing: border-box;
  }

  .metric-icon-container {
    width: 40px;
    height: 40px;
    background-color: rgba(0, 229, 255, 0.2);
    border: 1px solid #00E5FF;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;

    .metric-icon {
      font-size: 24px;
      color: #00E5FF;
    }
  }

  .metric-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    .metric-value {
      font-weight: bold;
    }
  }
}
</style>
