<script setup lang="ts">
withDefaults(
  defineProps<{
    variant?: 'primary' | 'dark' | 'ghost'
    fullWidth?: boolean
    type?: 'button' | 'submit'
    disabled?: boolean
  }>(),
  {
    variant: 'primary',
    fullWidth: true,
    type: 'button',
    disabled: false,
  },
)
</script>

<template>
  <button
    :type="type"
    :disabled="disabled"
    :data-variant="variant"
    :data-full-width="fullWidth ? '' : null"
  >
    <slot name="leading" />
    <slot />
  </button>
</template>

<style scoped>
button {
  height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 120ms ease, transform 60ms ease;
}

button[data-full-width] {
  width: 100%;
}

button[data-variant='primary'] {
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
}

button[data-variant='dark'] {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
}

button[data-variant='ghost'] {
  background: transparent;
  color: inherit;
  border: 1px solid var(--border);
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
</style>
