<template>
  <div class="vm-form-hint" :class="[`is-${variant}`]" role="note">
    <span v-if="icon" class="vm-form-hint__icon" aria-hidden="true">
      <i :class="icon" />
    </span>
    <span class="vm-form-hint__text">
      <slot>{{ text }}</slot>
    </span>
  </div>
</template>

<script setup lang="ts">
defineOptions({ name: 'vm-form-hint' })

withDefaults(
  defineProps<{
    text?: string
    variant?: 'info' | 'warn' | 'success'
    icon?: string
  }>(),
  {
    text: '',
    variant: 'info',
    icon: 'ri-information-line',
  },
)
</script>

<style lang="scss" scoped>
.vm-form-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--brand) 8%, var(--card));
  align-self: start;
}

.vm-form-hint__icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--brand);

  i {
    display: block;
    font-size: 16px;
  }
}

.vm-form-hint__text {
  flex: 1;
  min-width: 0;
}

.vm-form-hint.is-warn {
  background: color-mix(in srgb, #f59e0b 10%, var(--card));
  color: color-mix(in srgb, var(--foreground) 72%, #d97706);

  .vm-form-hint__icon {
    color: #d97706;
  }
}

.vm-form-hint.is-success {
  background: var(--success-soft);
  color: var(--success);

  .vm-form-hint__icon {
    color: var(--success);
  }
}
</style>
