<template>
  <UCard class="brand-card border border-transparent">
    <template #header>
      <h2 class="text-xl font-bold brand-section-title">Totales Netos de Verde</h2>
    </template>

    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-green-700/40 text-green-300">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Total Lb Neto de Verde</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatNumber(metrics.totalLbNetoVerde.value) }}</span>
            <span class="text-sm font-bold opacity-70">lb</span>
          </div>
        </div>
      </div>
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-green-600/40 text-green-400">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Precio Promedio Ponderado Pagado</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatNumber(metrics.precioPromedioVerdePagado.value) }}</span>
            <span class="text-sm font-bold opacity-70">L./lb</span>
          </div>
        </div>
      </div>
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-green-500/40 text-green-500">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Total Lb Neto de Verde en Depósito</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatNumber(metrics.totalLbNetoVerdeDeposito.value) }}</span>
            <span class="text-sm font-bold opacity-70">lb</span>
          </div>
        </div>
      </div>
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-emerald-600/40 text-emerald-400">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Inversión en Verde Hasta la Fecha</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatCurrency(metrics.inversionVerdeHastaFecha.value) }}</span>
          </div>
        </div>
      </div>
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-lime-600/40 text-lime-400">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Inversión Restante a Realizar en Verde</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatCurrency(metrics.inversionRestanteVerde.value) }}</span>
          </div>
        </div>
      </div>
      <div class="p-4 rounded-lg border transition-all bg-[#1c140c] border-teal-600/40 text-teal-400">
        <div class="flex flex-col">
          <span class="text-xs uppercase tracking-wide opacity-80 mb-1">Total Lb Neto Comprado de Verde</span>
          <div class="flex items-baseline gap-2">
            <span class="text-2xl font-bold">{{ formatNumber(metrics.totalLbNetoCompradoVerde.value) }}</span>
            <span class="text-sm font-bold opacity-70">lb</span>
          </div>
        </div>
      </div>
    </div>
  </UCard>
</template>

<script setup lang="ts">
import type { IngresosMetrics } from '~/composables/useIngresosMetrics'

defineProps<{
  metrics: IngresosMetrics
}>()

const formatNumber = (value: number) => {
  return value.toLocaleString('en-US', {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  })
}

const formatCurrency = (value: number) => {
  return new Intl.NumberFormat('es-HN', {
    style: 'currency',
    currency: 'HNL',
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  }).format(value).replace('HNL', 'L')
}
</script>