<template>
  <view
    class="gradient-stat-card"
    :style="{ background: gradient }"
    hover-class="stat-hover"
    @click="$emit('click')"
  >
    <text class="stat-value">{{ displayValue }}</text>
    <text class="stat-label">{{ label }}</text>
  </view>
</template>

<script setup lang="ts">
import { computed } from 'vue'

const props = withDefaults(
  defineProps<{
    value: number | string
    label: string
    gradient?: string
  }>(),
  {
    gradient: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  }
)

defineEmits<{
  click: []
}>()

const displayValue = computed(() => {
  if (typeof props.value === 'number') return props.value
  return props.value ?? 0
})
</script>

<style scoped>
.gradient-stat-card {
  border-radius: 12px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-value {
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  margin-top: 6px;
}

.stat-hover {
  opacity: 0.88;
  transform: scale(0.98);
}
</style>
