/* Toast Minimal Style (Sonner / shadcn) - Thamai Hospital */
:root {
  --toast-success: #0d9488;
  --toast-success-bg: rgba(13, 148, 136, 0.14);
  --toast-error: #e11d48;
  --toast-error-bg: rgba(225, 29, 72, 0.14);
  --toast-warning: #d97706;
  --toast-warning-bg: rgba(217, 119, 6, 0.14);
  --toast-info: #0284c7;
  --toast-info-bg: rgba(2, 132, 199, 0.14);
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  pointer-events: none;
  box-sizing: border-box;
}

.toast-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 10px 13px 13px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: auto;
  animation: toast-enter 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.toast-card.is-leaving {
  animation: toast-exit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.toast-icon-wrap {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-top: 1px;
}

.toast-icon-wrap svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  stroke: currentColor;
  fill: none;
}

.toast-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.toast-desc {
  font-size: 12.5px;
  font-weight: 400;
  color: #64748b;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin: -3px 0 0 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.toast-close:hover {
  background: #f1f5f9;
  color: #475569;
}

.toast-close svg {
  width: 14px;
  height: 14px;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  transform-origin: left center;
  opacity: 0.7;
}

.toast-card:hover .toast-progress {
  animation-play-state: paused;
}

/* Tone variants */
.toast-success {
  --toast-tone: var(--toast-success);
}

.toast-success .toast-icon-wrap {
  background: var(--toast-success-bg);
  color: var(--toast-success);
}

.toast-success .toast-progress {
  background-color: var(--toast-success);
}

.toast-error {
  --toast-tone: var(--toast-error);
}

.toast-error .toast-icon-wrap {
  background: var(--toast-error-bg);
  color: var(--toast-error);
}

.toast-error .toast-progress {
  background-color: var(--toast-error);
}

.toast-warning {
  --toast-tone: var(--toast-warning);
}

.toast-warning .toast-icon-wrap {
  background: var(--toast-warning-bg);
  color: var(--toast-warning);
}

.toast-warning .toast-progress {
  background-color: var(--toast-warning);
}

.toast-info {
  --toast-tone: var(--toast-info);
}

.toast-info .toast-icon-wrap {
  background: var(--toast-info-bg);
  color: var(--toast-info);
}

.toast-info .toast-progress {
  background-color: var(--toast-info);
}

.toast-loading {
  --toast-tone: var(--toast-success);
}

.toast-loading .toast-icon-wrap {
  background: var(--toast-success-bg);
  color: var(--toast-success);
}

.toast-loading .toast-progress {
  display: none;
}

/* Stroke draw animation */
.toast-path {
  animation: toast-draw 0.5s ease-out forwards;
}

.toast-path-check {
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}

.toast-path-cross {
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
}

.toast-path-dot {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}

.toast-spinner {
  animation: toast-spin 0.8s linear infinite;
  transform-origin: center;
}

/* Keyframe Animations */
@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translate3d(28px, 0, 0) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    max-height: 140px;
    margin-bottom: 0;
  }

  to {
    opacity: 0;
    transform: translate3d(28px, 0, 0) scale(0.96);
    max-height: 0;
    margin-bottom: -12px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@keyframes toast-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes toast-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toast-progress-anim {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

/* Mobile: ไม่เกิน 520px */
@media (max-width: 520px) {
  .toast-container {
    top: 16px;
    left: 16px;
    right: 16px;
    width: calc(100vw - 32px);
    max-width: none;
  }

  @keyframes toast-enter {
    from {
      opacity: 0;
      transform: translate3d(0, -20px, 0) scale(0.94);
    }

    to {
      opacity: 1;
      transform: translate3d(0, 0, 0) scale(1);
    }
  }

  @keyframes toast-exit {
    from {
      opacity: 1;
      transform: translate3d(0, 0, 0);
      max-height: 140px;
    }

    to {
      opacity: 0;
      transform: translate3d(0, -16px, 0);
      max-height: 0;
    }
  }
}

@media (prefers-reduced-motion: reduce) {

  .toast-card,
  .toast-card.is-leaving,
  .toast-path,
  .toast-progress {
    animation: none !important;
  }

  .toast-spinner {
    animation-duration: 2s !important;
  }
}