<template>
  <div class="go-device-status">
    <div class="title" :style="{ color: option.titleColor, fontSize: option.titleSize + 'px' }">{{ option.title }}</div>
    <div class="status-grid">
      <div v-for="(item, index) in option.dataset" :key="index" class="status-item" :style="{ borderColor: option.borderColor }">
        <div class="item-icon-wrapper">
          <svg-icon :icon-class="item.icon" class="item-icon"></svg-icon>
        </div>
        <div class="item-details">
          <div class="item-label" :style="{ color: option.labelColor, fontSize: option.labelSize + 'px' }">{{ item.label }}</div>
          <div class="item-value">
            <span :style="{ color: option.valueColor, fontSize: option.valueSize + 'px' }">{{ item.value }}</span>
            <span :style="{ color: option.unitColor, fontSize: option.unitSize + 'px' }">{{ item.unit }}</span>
          </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-device-status {
  width: 100%;
  height: 100%;
  background-color: #0F1C3D;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;

  .title {
    font-weight: bold;
    margin-bottom: 20px;
  }

  .status-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 20px;
  }

  .status-item {
    display: flex;
    align-items: center;
    background-color: rgba(26, 56, 90, 0.5);
    border: 1px solid;
    padding: 15px;
    border-radius: 5px;
  }

  .item-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 229, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;

    .item-icon {
      font-size: 28px;
      color: #00E5FF;
    }
  }

  .item-details {
    .item-label {
      margin-bottom: 5px;
    }
    .item-value {
      span:first-child {
        font-weight: bold;
        margin-right: 5px;
      }
    }
  }
}
</style>
