/* ---------- 全局顶部弹窗提示 (Toast) ----------
 * 从登录页抽取，全局共用；配合 /res/js/toast.js 使用。
 * 支持类型：success / error / warning / info
 */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

/* 信息与其数量角标作为一组，整体居中；角标位于信息正后方 */
.toast-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#toast-badge {
  flex: 0 0 auto;
  min-width: 26px;
  height: 26px;
  box-sizing: border-box;
  padding: 0 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #2c2c33;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.6);
  transform-origin: center;
  animation: badge-pop 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes badge-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.toast {
  --toast-accent: #c9ccd4;
  position: relative;
  width: 360px;
  max-width: calc(100vw - 40px);
  border-radius: 10px;
  background: rgba(24, 26, 31, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  color: #f5f5f7;
  overflow: hidden;
  pointer-events: auto;
  white-space: nowrap;
  transform-origin: center;
}

/* 入场：从很小放大到正常 */
.toast.toast--show {
  animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

.toast--success { --toast-accent: #4ade80; }
.toast--error { --toast-accent: #f87171; }
.toast--warning { --toast-accent: #fbbf24; }
.toast--info { --toast-accent: #c9ccd4; }

.toast-body {
  display: flex;
  flex-direction: column;
  padding: 10px 14px 10px;
}

.toast-main {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.toast-title {
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 600;
}

/* 信息内容：嵌套一层，便于用 grid 行高做展开动画，文字始终存在可显示 */
.toast-info {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.toast-info-inner {
  min-height: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #d4d4d8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 默认：只显示最新一条（最后一组）；其余隐藏，但文字始终在 DOM 中 */
#toast-container .toast-group { display: none; }
#toast-container .toast-group:last-child { display: flex; }

/* 悬浮某条 toast 时：仅展开该条信息（grid 行高动画） */
.toast-group:hover .toast-info { grid-template-rows: 1fr; }
.toast-group:hover .toast-info-inner { opacity: 1; }

.toast-close {
  margin-left: auto;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #a1a1aa;
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* 底部倒计时条：颜色跟随类型 */
.toast-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.toast-progress {
  height: 100%;
  width: 100%;
  background: var(--toast-accent);
  transform-origin: left center;
  animation: toast-shrink linear forwards;
  animation-play-state: running;
}

@keyframes toast-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* 退场：整组（信息+角标）无限缩小直到完全看不到 */
.toast-group.toast-group--hide {
  animation: toast-out 0.28s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: scale(0); }
}