<template>
  <q-card class="q-pa-lg mini-card card-ring">
    <div class="column no-wrap full-width">
      <div class="flex justify-between items-center no-wrap">
        <span class="text-h5">{{ title }}</span>
        <div class="round">
          <q-icon :name="icon" size="24px" :color="color" />
        </div>
      </div>
      <div class="flex no-wrap full-width justify-between q-pa-sm">
        <div class="column flex-center">
          <span :class="numberCard.length >= 7 ? 'text-h4' : 'text-h3'">
            {{ numberCard }}
          </span>
          <div
            v-if="numberPorcent !== null"
            class="flex no-wrap text-subtitle2"
            :class="numberPorcent > 0 ? 'text-positive' : 'text-negative'"
          >
            <q-icon
              :name="numberPorcent > 0 ? 'mdi-arrow-up' : 'mdi-arrow-down'"
              size="18px"
              class="q-mr-xs"
            />
            {{ numberPorcent + "%" }}
          </div>
        </div>
        <div class="flex justify-end" style="max-width: 120px; height: 80px">
          <slot name="chart" :color="color" :chart-data="chartData" />
        </div>
      </div>
    </div>
  </q-card>
</template>

<script setup>
const { color, title, icon, chartData, numberCard, numberPorcent } =
  defineProps({
    color: {
      type: String,
      default: "primary",
    },
    title: {
      type: String,
      default: "Usuários",
    },
    icon: {
      type: String,
      default: "mdi-account",
    },
    chartData: {
      type: Array,
      default: () =>
        Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
    },
    numberCard: {
      type: String,
      default: () => Math.floor(Math.random() * 100),
    },
    numberPorcent: {
      type: Number,
      default: null,
    },
  });
</script>
<style lang="scss" scoped>
@use "sass:map";
@use "src/css/quasar.variables.scss";

.background {
  background: rgba(map.get($colors, "primary"), 0.2) !important;
}

.mini-card {
  height: 100%;
  min-width: 305px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #c0c0c0c0 !important;
}
</style>
