<template>
  <div class="card-tab" :class="{'active': active}" v-on="$listeners">
    <div class="card-tab-title">
      {{title}}
    </div>
    <div class="card-tab-content">
      <div class="card-tab-item" v-for="(item, index) in data" :key="index">
        <div class="card-tab-item-label">{{item.label}}</div>
        <div class="card-tab-item-value">{{item.value}}</div>
      </div>
    </div>
  </div>  
</template>

<script>
export default {
  name: "CardTab",
  props: {
    title: {
      type: String,
      default: ""
    },
    data: {
      type: Array,
      default: () => []
    },
    active: {
      type: Boolean,
      default: false
    }
  },
}
</script>

<style lang="scss" scoped>
.card-tab {
  width: 100%;
  height: 100%;
  background-color: #e3ebfe;
  border-radius: 12px 12px 0 0;
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
  .card-tab-title {
    font-size: 14px;
    margin-bottom: 8px;
  }
  .card-tab-content {
    .card-tab-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .card-tab-item-label {
        font-size: 14px;
        color: #212121;
      }
      .card-tab-item-value {
        font-size: 14px;
        color: #999;
      }
    }
  } 
  &:hover {
    background-color: #ebf0ff;
    .card-tab-title {
      color: #007aff;
    }
  }
  &.active {
    background-color: #fff;
    .card-tab-title {
      color: #007aff;
    }
  }
}
</style>