<script setup lang="ts">
import { Icon } from '@bagelink/vue'

interface Props {
	message: string
	type?: 'success' | 'error' | 'warning' | 'info'
	showIcon?: boolean
	showCloseButton?: boolean
	closeToast?: () => void
}

withDefaults(defineProps<Props>(), {
	type: 'info',
	showIcon: true,
	showCloseButton: true,
})
</script>

<template>
	<div class="custom-toast" :class="`custom-toast--${type}`">
		<div v-if="showIcon" class="custom-toast__icon">
			<Icon v-if="type === 'success'" icon="check_circle" />
			<Icon v-if="type === 'error'" icon="dangerous" />
			<Icon v-if="type === 'warning'" icon="report" />
			<Icon v-if="type === 'info'" icon="info" />
		</div>
		<div class="custom-toast__content">
			{{ message }}
		</div>
		<button v-if="showCloseButton" class="custom-toast__close" @click="closeToast">
			<Icon icon="close" />
		</button>
	</div>
</template>

<style>
.custom-toast {
  --toast-border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  padding-left: 20px;
  border-radius: var(--toast-border-radius);
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  min-width: 300px;
  font-family: system-ui, -apple-system, sans-serif;
  position: relative;
  overflow: hidden;
  outline: 1px solid var(--border-color);
    outline-offset: -1px !important;
}

.custom-toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: var(--toast-border-radius) 0 0 var(--toast-border-radius);
}

.custom-toast--success::before {
  background: #10b981;
}

.custom-toast--success .custom-toast__icon {
  color: #10b981;
}

.custom-toast--error::before {
  background: #ef4444;
}

.custom-toast--error .custom-toast__icon {
  color: #ef4444;
}

.custom-toast--warning::before {
  background: #f59e0b;
}

.custom-toast--warning .custom-toast__icon {
  color: #f59e0b;
}

.custom-toast--info::before {
  background: #3b82f6;
}

.custom-toast--info .custom-toast__icon {
  color: #3b82f6;
}

.custom-toast__icon {
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.custom-toast__content {
  flex: 1;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.5;
}

.custom-toast__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #6b7280;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.custom-toast__close:hover {
  color: #1f2937;
}
</style>
