// src/components/DealDetails/DealNotice.tsx
import type { DealNoticeSeverity } from "../../models/deal/DealDetail"

type DealNoticeProps = {
  title: string
  body?: string | null
  severity: DealNoticeSeverity
}

const styles: Record<
  DealNoticeSeverity,
  { wrap: string; dotVar: string; titleVar: string; bodyVar: string }
> = {
  INFO: {
    wrap:
      "border-[color-mix(in_srgb,var(--color-notice-info)_35%,transparent)] " +
      "bg-[linear-gradient(90deg,var(--color-notice-info-soft),var(--color-surface))] " +
      "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-notice-info)_18%,transparent)]",
    dotVar: "var(--color-notice-info)",
    titleVar: "var(--color-text)",
    bodyVar: "var(--color-text-muted)",
  },
  SUCCESS: {
    wrap:
      "border-[color-mix(in_srgb,var(--color-notice-success)_35%,transparent)] " +
      "bg-[linear-gradient(90deg,var(--color-notice-success-soft),var(--color-surface))] " +
      "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-notice-success)_18%,transparent)]",
    dotVar: "var(--color-notice-success)",
    titleVar: "var(--color-text)",
    bodyVar: "var(--color-text-muted)",
  },
  WARNING: {
    wrap:
      "border-[color-mix(in_srgb,var(--color-notice-warning)_35%,transparent)] " +
      "bg-[linear-gradient(90deg,var(--color-notice-warning-soft),var(--color-surface))] " +
      "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-notice-warning)_18%,transparent)]",
    dotVar: "var(--color-notice-warning)",
    titleVar: "var(--color-text)",
    bodyVar: "var(--color-text-muted)",
  },
  DANGER: {
    wrap:
      "border-[color-mix(in_srgb,var(--color-notice-danger)_35%,transparent)] " +
      "bg-[linear-gradient(90deg,var(--color-notice-danger-soft),var(--color-surface))] " +
      "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-notice-danger)_18%,transparent)]",
    dotVar: "var(--color-notice-danger)",
    titleVar: "var(--color-text)",
    bodyVar: "var(--color-text-muted)",
  },
}

export default function DealNotice({ title, body, severity }: DealNoticeProps) {
  const s = styles[severity] ?? styles.INFO

  return (
    <div className={`rounded-2xl border p-4 sm:p-5 ${s.wrap}`}>
      <div className="flex items-start gap-3">
        <span
          className="mt-1.5 h-2.5 w-2.5 rounded-full"
          style={{ backgroundColor: s.dotVar }}
        />
        <div className="min-w-0">
          <div
            className="text-sm sm:text-base font-semibold leading-snug"
            style={{ color: s.titleVar }}
          >
            {title}
          </div>
          {body ? (
            <div
              className="text-sm mt-1 whitespace-pre-wrap"
              style={{ color: s.bodyVar }}
            >
              {body}
            </div>
          ) : null}
        </div>
      </div>
    </div>
  )
}
