<script setup>
import { computed } from 'vue'

const props = defineProps({
  score: {
    type: Number,
    default: 0,
  },
  visible: {
    type: Boolean,
    default: true,
  },
})

const scoreData = computed(() => {
  if (props.score >= 10) {
    return {
      color: 'green',
      bgClass: 'bg-green-500',
      textClass: 'text-green-500',
      label: 'GO',
    }
  } else if (props.score >= 5) {
    return {
      color: 'amber',
      bgClass: 'bg-amber-500',
      textClass: 'text-amber-500',
      label: 'Consult Leadership',
    }
  } else if (props.score >= 1) {
    return {
      color: 'red',
      bgClass: 'bg-red-500',
      textClass: 'text-red-500',
      label: 'NO GO',
    }
  } else {
    return {
      color: 'gray',
      bgClass: 'bg-gray-500',
      textClass: 'text-gray-400',
      label: 'No Score',
    }
  }
})

const panelBorderClass = computed(() => {
  if (props.score >= 10) return 'border-green-500/20'
  if (props.score >= 5) return 'border-amber-500/20'
  if (props.score >= 1) return 'border-red-500/20'
  return 'border-white/10'
})
</script>

<template>
  <div
    v-if="visible"
    class="inline-flex items-center gap-3 bg-white/5 backdrop-blur-sm border rounded-xl px-5 py-3 transition-all duration-500"
    :class="panelBorderClass"
  >
    <div class="flex items-baseline gap-2">
      <span class="text-3xl font-bold" :class="scoreData.textClass">
        {{ score }}
      </span>
      <span class="text-xs uppercase tracking-wider text-gray-500">
        points
      </span>
    </div>
    <div
      :class="[
        scoreData.bgClass,
        'px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider text-white shadow-sm',
      ]"
    >
      {{ scoreData.label }}
    </div>
  </div>
</template>
