/* Thông báo hệ thống (staff .toast + đáp viên .ptoast): thẻ sáng góc dưới phải, trượt từ dưới lên.
   Cấu trúc do showToast()/toast() dựng: icon · chữ · nút đóng · thanh thời gian. */
.toast,
.ptoast {
  --tone: #1F5FBF;
  --tone-soft: #EAF1FB;
  position: fixed !important;
  left: auto !important;
  top: auto !important;
  right: calc(24px + env(safe-area-inset-right, 0px)) !important;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 1000 !important;
  display: grid !important;
  grid-template-columns: 32px 1fr 28px;
  align-items: center;
  column-gap: 12px;
  box-sizing: border-box;
  width: 380px;
  max-width: calc(100vw - 48px);
  min-height: 56px;
  padding: 12px 10px 12px 12px !important;
  overflow: hidden;
  background: #FFFFFF !important;
  color: #0F172A !important;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px !important;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  border: 1px solid #E2E8F0 !important;
  border-radius: 0 !important;
  box-shadow: 0 18px 40px -12px rgba(15, 23, 42, .28), 0 4px 10px -4px rgba(15, 23, 42, .12) !important;
  opacity: 0 !important;
  transform: translateY(24px) !important;
  transition: opacity .18s ease-out, transform .38s cubic-bezier(.16, 1, .3, 1) !important;
  pointer-events: none;
}
.toast.is-success, .ptoast.is-success { --tone: #067647; --tone-soft: #E7F6EE; }
.toast.is-error,   .ptoast.is-error   { --tone: #B42318; --tone-soft: #FDECEA; }

.toast.show,
.ptoast.show {
  opacity: 1 !important;
  transform: translateY(0) !important;
  pointer-events: auto;
}

.toast .toast-icon,
.ptoast .toast-icon {
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: var(--tone-soft);
  border-radius: 6px !important;
  fill: none;
  stroke: var(--tone);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast .toast-text,
.ptoast .toast-text {
  margin: 0;
  color: #0F172A;
  overflow-wrap: anywhere;
}

.toast .toast-close,
.ptoast .toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px !important;
  color: #64748B;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.toast .toast-close:hover,
.ptoast .toast-close:hover { background: #F1F5F9; color: #0F172A; }
.toast .toast-close:focus-visible,
.ptoast .toast-close:focus-visible { outline: 2px solid #1F5FBF; outline-offset: 1px; }
.toast .toast-close svg,
.ptoast .toast-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Thanh thời gian còn lại: dừng khi rê chuột */
.toast .toast-bar,
.ptoast .toast-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--tone);
  opacity: .85;
  transform-origin: left center;
  transform: scaleX(0);
}
.toast.show .toast-bar,
.ptoast.show .toast-bar {
  animation: ir-toast-countdown var(--toast-duration, 3600ms) linear forwards;
}
.toast:hover .toast-bar,
.ptoast:hover .toast-bar { animation-play-state: paused; }
@keyframes ir-toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (max-width: 600px) {
  .toast,
  .ptoast {
    left: calc(12px + env(safe-area-inset-left, 0px)) !important;
    right: calc(12px + env(safe-area-inset-right, 0px)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .ptoast {
    transform: none !important;
    transition: opacity .15s linear !important;
  }
  .toast.show .toast-bar,
  .ptoast.show .toast-bar { animation: none; transform: scaleX(0); }
}
