:root {
  --custom-toast-primary: #ce0002;
  --custom-toast-primary-soft: rgba(206, 0, 2, 0.12);

  --custom-toast-text: #111827;
  --custom-toast-muted: #6b7280;

  --custom-toast-border: rgba(17, 24, 39, 0.12);
  --custom-toast-border-strong: rgba(17, 24, 39, 0.14);

  --custom-toast-shadow: 0 12px 28px rgba(17, 24, 39, 0.16);
  --custom-toast-shadow-strong: 0 14px 34px rgba(17, 24, 39, 0.18);
}

/* stack */
.custom-toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

/* card */
.custom-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 360px;
  border-radius: 14px;

  color: var(--custom-toast-text);

  background: #f3f4f6; /* ขาวอมเทา */
  border: 1.5px solid rgba(17, 24, 39, 0.16);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12),
    0 1px 0 rgba(255, 255, 255, 0.75) inset;

  overflow: hidden;
  position: relative;

  transform: translateY(-10px);
  opacity: 0;
  animation: customToastIn 0.18s ease-out forwards;
}

/* left accent stripe */
.custom-toast::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--custom-toast-primary);
}

.custom-toast.custom-toast-out {
  animation: customToastOut 0.18s ease-in forwards;
}

@keyframes customToastIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes customToastOut {
  to {
    transform: translateY(-10px);
    opacity: 0;
  }
}

/* progress bar */
.custom-toast__bar {
  height: 4px;
  background: rgba(206, 0, 2, 0.08);
  position: relative;
}

.custom-toast__bar > span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: linear-gradient(
    90deg,
    var(--custom-toast-primary) 0%,
    #ff3b3f 100%
  );
  animation: customToastProgress linear forwards;
}

@keyframes customToastProgress {
  to {
    transform: scaleX(0);
  }
}

/* body */
.custom-toast__body {
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* avatar */
.custom-toast__avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  overflow: hidden;
  flex: 0 0 auto;

  background: rgba(206, 0, 2, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;

  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.1);
  border: 1px solid rgba(206, 0, 2, 0.22);
}

.custom-toast__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.custom-toast__avatar .custom-toast__initial {
  font-weight: 900;
  font-size: 14px;
  color: var(--custom-toast-text);
}

/* content */
.custom-toast__content {
  min-width: 0;
  flex: 1 1 auto;
}

.custom-toast__title {
  font-weight: 900;
  font-size: 14px;
  line-height: 1.15;
  margin: 0;
  letter-spacing: 0.1px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--custom-toast-text);
}

.custom-toast__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  min-width: 0;
}

.custom-toast__desc {
  margin-top: 4px;
  font-size: 13px;
  color: rgba(17, 24, 39, 0.72);
  line-height: 1.25;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

/* pill */
.custom-toast__pill {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;

  background: rgba(206, 0, 2, 0.08);
  border: 1px solid rgba(206, 0, 2, 0.28);
  color: var(--custom-toast-primary);

  white-space: nowrap;
  font-weight: 800;
  flex: 0 0 auto;
}

/* close */
.custom-toast__close {
  border: 0;
  background: transparent;
  color: rgba(17, 24, 39, 0.55);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  margin-left: 8px;
  cursor: pointer;
}

.custom-toast__close:hover {
  color: rgba(17, 24, 39, 0.85);
}

/* =========================
  Custom Toast Variants (PATCH)
  ใช้กับโค้ดเดิมของคุณได้เลย
========================= */

/* ตั้งค่า default accent (ถ้าไม่ใส่ variant จะเป็น lead/แดง) */
.custom-toast {
  --custom-toast-accent: var(--custom-toast-primary);
  --custom-toast-accent-soft: rgba(206, 0, 2, 0.08);
  --custom-toast-accent-border: rgba(206, 0, 2, 0.28);
  --custom-toast-accent-grad: #ff3b3f; /* สีปลาย gradient */
}

/* stripe ซ้าย: เปลี่ยนจาก primary -> accent */
.custom-toast::before {
  background: var(--custom-toast-accent);
}

/* progress bar: เปลี่ยนเป็น accent */
.custom-toast__bar {
  background: var(--custom-toast-accent-soft);
}

.custom-toast__bar > span {
  background: linear-gradient(
    90deg,
    var(--custom-toast-accent) 0%,
    var(--custom-toast-accent-grad) 100%
  );
}

/* pill: เปลี่ยนเป็น accent */
.custom-toast__pill {
  background: var(--custom-toast-accent-soft);
  border: 1px solid var(--custom-toast-accent-border);
  color: var(--custom-toast-accent);
}

/* avatar: เปลี่ยนเป็น accent (เบาๆ) */
.custom-toast__avatar {
  background: rgba(0, 0, 0, 0); /* reset กันซ้อน */
  background: color-mix(in srgb, var(--custom-toast-accent) 6%, transparent);
  border: 1px solid
    color-mix(in srgb, var(--custom-toast-accent) 22%, transparent);
}

/* ---------- Variants ---------- */
/* lead (นำอยู่) = แดงแบรนด์ */
.custom-toast.v-lead {
  --custom-toast-accent: #ce0002;
  --custom-toast-accent-soft: rgba(206, 0, 2, 0.08);
  --custom-toast-accent-border: rgba(206, 0, 2, 0.28);
  --custom-toast-accent-grad: #ff3b3f;
}

.custom-toast.v-success {
  --custom-toast-accent: #16a34a; /* green-600 */
  --custom-toast-accent-soft: rgba(22, 163, 74, 0.12);
  --custom-toast-accent-border: rgba(22, 163, 74, 0.3);
  --custom-toast-accent-grad: #86efac; /* green-300 */
}

.custom-toast.v-info {
  --custom-toast-accent: #3b82f6;
  --custom-toast-accent-soft: rgba(59, 130, 246, 0.12);
  --custom-toast-accent-border: rgba(59, 130, 246, 0.3);
  --custom-toast-accent-grad: #93c5fd;
}

/* error = แดงเข้ม */
.custom-toast.v-error {
  --custom-toast-accent: #ef4444;
  --custom-toast-accent-soft: rgba(239, 68, 68, 0.12);
  --custom-toast-accent-border: rgba(239, 68, 68, 0.3);
  --custom-toast-accent-grad: #fca5a5;
}

.custom-toast.v-leading {
  --custom-toast-accent: #7c3aed; /* violet-600 */
  --custom-toast-accent-soft: rgba(124, 58, 237, 0.12);
  --custom-toast-accent-border: rgba(124, 58, 237, 0.3);
  --custom-toast-accent-grad: #c4b5fd; /* violet-300 */
}

/* ===== fallback ถ้า browser ไม่รองรับ color-mix ===== */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .custom-toast__avatar {
    background: rgba(17, 24, 39, 0.04);
    border: 1px solid rgba(17, 24, 39, 0.14);
  }
  .custom-toast.v-lead .custom-toast__avatar {
    background: rgba(206, 0, 2, 0.04);
    border-color: rgba(206, 0, 2, 0.22);
  }
  .custom-toast.v-early .custom-toast__avatar {
    background: rgba(34, 197, 94, 0.06);
    border-color: rgba(34, 197, 94, 0.22);
  }
  .custom-toast.v-auto .custom-toast__avatar {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.22);
  }
  .custom-toast.v-error .custom-toast__avatar {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.22);
  }
}

/* mobile */
@media (max-width: 575.98px) {
  .custom-toast-stack {
    left: 12px;
    right: 12px;
  }
  .custom-toast {
    max-width: none;
    width: 100%;
  }
}
