/* ================================================
   智能客服「糖宝小助手」—— 右下角悬浮组件
   全站通用（除 chat.html 外）
   ================================================ */

/* -------- 悬浮按钮（未展开时） -------- */
.tb-assist {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
}
.tb-assist__fab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 0;
  border-radius: 30px;
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 138, 61, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tb-assist__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(255, 138, 61, 0.5);
}
.tb-assist__fab .tb-assist__fab-icon {
  font-size: 18px;
  animation: tb-assist-wave 3s ease-in-out infinite;
  transform-origin: 70% 70%;
}
@keyframes tb-assist-wave {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-12deg); }
  80% { transform: rotate(12deg); }
  90% { transform: rotate(-6deg); }
}

/* 展开态：隐藏悬浮按钮 */
.tb-assist.is-open .tb-assist__fab { display: none; }

/* -------- 展开面板 -------- */
.tb-assist__panel {
  display: none;
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 380px;
  height: min(600px, 80vh);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  flex-direction: column;
  z-index: 9990;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.tb-assist.is-open .tb-assist__panel { display: flex; }

/* Header */
.tb-assist__header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.tb-assist__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.tb-assist__title {
  flex: 1 1 auto;
  min-width: 0;
}
.tb-assist__title h4 { margin: 0; font-size: 14px; font-weight: 600; }
.tb-assist__title p { margin: 2px 0 0; font-size: 12px; opacity: 0.85; }
.tb-assist__close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s ease;
}
.tb-assist__close:hover { background: rgba(255, 255, 255, 0.35); }

/* 快速导览区（消息区上方，永久显示） */
.tb-assist__quick {
  padding: 12px 14px;
  background: #fff8ef;
  border-bottom: 1px solid #f0e5d0;
  flex-shrink: 0;
}
.tb-assist__quick-title {
  font-size: 12px;
  color: #7a5a2a;
  margin: 0 0 8px;
  font-weight: 600;
}
.tb-assist__quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.tb-assist__quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #f0d59a;
  border-radius: 10px;
  background: #fff;
  color: #5d3a0e;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  line-height: 1.2;
}
.tb-assist__quick-btn:hover {
  border-color: #ff8a3d;
  background: #fff2e0;
  transform: translateY(-1px);
}
.tb-assist__quick-btn__ic { font-size: 16px; flex-shrink: 0; }

/* 消息区 */
.tb-assist__body {
  flex: 1 1 auto;
  padding: 12px 14px;
  overflow-y: auto;
  background: #fafafa;
}
.tb-assist__msg {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  max-width: 100%;
}
.tb-assist__msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.tb-assist__msg--bot .tb-assist__msg-avatar { background: linear-gradient(135deg, #ffb74d, #ff8a3d); color: #fff; }
.tb-assist__msg--user { flex-direction: row-reverse; }
.tb-assist__msg--user .tb-assist__msg-avatar { background: #e0e6ee; color: #333; }
.tb-assist__msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 78%;
  word-wrap: break-word;
}
.tb-assist__msg--bot .tb-assist__msg-bubble {
  background: #fff;
  border: 1px solid #e0e6ee;
  color: #333;
  border-top-left-radius: 4px;
}
.tb-assist__msg--user .tb-assist__msg-bubble {
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  color: #fff;
  border-top-right-radius: 4px;
}
.tb-assist__msg-bubble p { margin: 0 0 6px; }
.tb-assist__msg-bubble p:last-child { margin-bottom: 0; }
.tb-assist__msg-bubble ol, .tb-assist__msg-bubble ul { padding-left: 1.4em; margin: 4px 0; }
.tb-assist__msg-bubble li { margin-bottom: 3px; }
.tb-assist__msg-bubble strong { font-weight: 600; }
.tb-assist__msg-bubble a { color: #ff8a3d; text-decoration: underline; }
.tb-assist__msg--user .tb-assist__msg-bubble a { color: #fff; }
.tb-assist__msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: Menlo, Consolas, monospace;
}

/* 打字气泡（loading 动画） */
.tb-assist__typing { display: inline-flex; gap: 3px; padding: 4px 0; }
.tb-assist__typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #b0b7c1;
  animation: tb-assist-blink 1.2s infinite;
}
.tb-assist__typing span:nth-child(2) { animation-delay: 0.2s; }
.tb-assist__typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tb-assist-blink {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

/* 输入区 */
.tb-assist__footer {
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.tb-assist__input {
  flex: 1 1 auto;
  min-height: 34px;
  max-height: 100px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}
.tb-assist__input:focus { border-color: #ff8a3d; }
.tb-assist__send {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}
.tb-assist__send:hover:not(:disabled) { transform: scale(1.05); }
.tb-assist__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* -------- 引导教程（Tour） -------- */
.tb-tour-mask {
  position: fixed;
  inset: 0;
  z-index: 9995;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  transition: background 0.2s ease;
}
.tb-tour-hole {
  position: absolute;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55), 0 0 0 3px #ff8a3d, 0 0 20px 4px rgba(255, 138, 61, 0.6);
  pointer-events: none;
  transition: all 0.3s ease;
}
.tb-tour-tip {
  position: absolute;
  z-index: 9996;
  width: 300px;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border: 2px solid #ff8a3d;
}
.tb-tour-tip__step {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  color: #fff;
  font-size: 11px;
  margin-bottom: 6px;
}
.tb-tour-tip__title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}
.tb-tour-tip__desc {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #666;
}
.tb-tour-tip__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.tb-tour-tip__skip {
  border: 0;
  background: transparent;
  color: #999;
  font-size: 12px;
  cursor: pointer;
}
.tb-tour-tip__skip:hover { color: #666; }
.tb-tour-tip__nav { display: flex; gap: 6px; }
.tb-tour-tip__btn {
  padding: 5px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 12px;
  cursor: pointer;
}
.tb-tour-tip__btn:hover { border-color: #ff8a3d; color: #ff8a3d; }
.tb-tour-tip__btn--primary {
  background: linear-gradient(135deg, #ffb74d, #ff8a3d);
  border-color: transparent !important;
  color: #fff !important;
}

/* -------- 窄屏适配 -------- */
@media (max-width: 640px) {
  .tb-assist { right: 12px; bottom: 12px; }
  .tb-assist__fab { padding: 10px 16px; font-size: 13px; }
  .tb-assist__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    right: 12px;
    bottom: 12px;
    border-radius: 12px;
  }
  .tb-tour-tip { width: calc(100vw - 40px); }
}
