<template>
  <div
    class="p-4 rounded-lg border transition-all"
    :class="[variantClasses, props.class]"
  >
    <div class="flex flex-col">
      <span class="text-xs uppercase tracking-wide opacity-80 mb-1">{{ label }}</span>
      <div class="flex items-baseline gap-2">
        <span class="text-2xl font-bold">{{ value }}</span>
        <span v-if="unit" class="text-sm font-bold opacity-70">{{ unit }}</span>
      </div>
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  label: string
  value: string | number
  unit?: string
  variant?: 'default' | 'primary' | 'success' | 'danger' | 'warning' | 'info'
  class?: string
}

const props = withDefaults(defineProps<Props>(), {
  variant: 'default'
})

const variantClasses = computed(() => {
  const variants = {
    default: 'bg-[var(--brand-surface)] border-[var(--brand-border)] text-[var(--brand-text)]',
    primary: 'bg-[var(--brand-surface)] border-[var(--brand-primary-strong)] text-[var(--brand-primary)]',
    success: 'bg-[var(--brand-surface)] border-[color:color-mix(in_srgb,var(--brand-success),transparent_70%)] text-[var(--brand-success)]',
    danger: 'bg-[var(--brand-surface)] border-[color:color-mix(in_srgb,var(--coffee-uva),transparent_70%)] text-[var(--coffee-uva)]',
    warning: 'bg-[var(--brand-surface)] border-[color:color-mix(in_srgb,var(--coffee-oreado),transparent_70%)] text-[var(--coffee-oreado)]',
    info: 'bg-[var(--brand-surface)] border-[color:color-mix(in_srgb,var(--coffee-mojado),transparent_70%)] text-[var(--coffee-mojado)]'
  }
  return variants[props.variant]
})
</script>