"use client"

import { useTheme } from "next-themes"
import { Toaster as Sonner, ToasterProps } from "sonner"

const Toaster = ({ ...props }: ToasterProps) => {
  const { theme = "system" } = useTheme()

  return (
    <Sonner
      theme={theme as ToasterProps["theme"]}
      position="top-center"
      expand
      richColors
      closeButton
      className="toaster group"
      toastOptions={{
        classNames: {
          toast:
            "group toast rounded-xl border border-border/40 bg-background/60 backdrop-blur-xl shadow-lg flex items-center gap-3 p-4",
          title: "text-sm font-medium text-foreground",
          description: "text-xs text-muted-foreground",
          actionButton:
            "bg-primary text-primary-foreground hover:opacity-90 rounded-md px-3 py-1 text-xs",
          cancelButton:
            "bg-muted text-muted-foreground hover:bg-muted/80 rounded-md px-3 py-1 text-xs",

          success:
            "border-primary/30 bg-primary/10 text-primary",

          error:
            "border-destructive/40 bg-destructive/10 text-destructive",

          warning:
            "border-yellow-500/40 bg-yellow-500/10 text-yellow-600",

          info:
            "border-accent/40 bg-accent/10 text-accent-foreground",
        },
      }}
      {...props}
    />
  )
}

export { Toaster }
