/* ================================
   小艺老师全局帮助入口 — TeacherHelper
   Batch ⑥ 声印页独立子游戏改造
   右下角常驻头像，全局 AI 帮助入口
   ================================ */

/* ── 容器：固定右下角 ── */
.teacher-helper {
  position: fixed;
  bottom: calc(var(--footer-height, 64px) + 16px);
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

/* ── 气泡 ── */
.teacher-helper__bubble {
  background: var(--color-surface);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  max-width: 200px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.teacher-helper__bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.teacher-helper__bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: var(--color-surface);
  border-bottom: 0;
}

/* ── 帮助入口（头像 + 名字，常驻无底板） ── */
.teacher-helper__launcher {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s ease;
  font-family: inherit;
  overflow: visible;
  position: relative;
}

.teacher-helper__launcher:active {
  transform: scale(0.97);
}

/* ── 名字标签（常驻显示，白色药丸底保证可读） ── */
.teacher-helper__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary, #F18D24);
  letter-spacing: 0.5px;
  white-space: nowrap;
  user-select: none;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

/* ── 头像按钮（胶囊内的圆形） ── */
.teacher-helper__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(241, 141, 36, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(241, 141, 36, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.teacher-helper__avatar:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(241, 141, 36, 0.45);
}

/* 头像图片 */
.teacher-helper__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ── 音符徽章（头像右上角，独立 HTML 元素） ── */
.teacher-helper__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  color: #f18d24;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  z-index: 2;
  pointer-events: none;
}

/* ── 浮动对话框（独立组件，靠近右下角弹出，不遮挡核心内容） ── */
.teacher-helper__dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
}

.teacher-helper__dialog.show {
  display: block;
}

.teacher-helper__dialog-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.28);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.teacher-helper__dialog.show .teacher-helper__dialog-scrim {
  opacity: 1;
}

.teacher-helper__dialog-panel {
  position: absolute;
  right: 16px;
  bottom: calc(var(--footer-height, 64px) + 88px);
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - var(--footer-height, 64px) - 112px);
  background: var(--color-surface, #fff);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.teacher-helper__dialog.show .teacher-helper__dialog-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.teacher-helper__dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  color: var(--color-text, #333);
  border-bottom: 1px solid #f0ede8;
}

.teacher-helper__dialog-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary, #F18D24);
}

.teacher-helper__header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.teacher-helper__dialog-close {
  flex: none;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: #666;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.teacher-helper__dialog-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #555;
}

.teacher-helper__dialog-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
}

.teacher-helper__tts-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}
.teacher-helper__tts-toggle:hover {
  background: rgba(0, 0, 0, 0.12);
}
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text, #333);
}

.teacher-helper__dialog-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teacher-helper__dialog-list li {
  position: relative;
  padding: 10px 12px 10px 34px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--color-text, #333);
  background: rgba(241, 141, 36, 0.07);
  border-radius: 10px;
}

.teacher-helper__dialog-list li::before {
  content: '♪';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-primary, #F18D24);
  font-size: 14px;
  font-weight: bold;
}

/* ── 说话脉冲动画 ── */
.teacher-helper__avatar.speaking {
  animation: teacherHelperPulse 1s ease-in-out infinite;
}

@keyframes teacherHelperPulse {
  0%, 100% {
    box-shadow: 0 3px 12px rgba(241, 141, 36, 0.3);
  }
  50% {
    box-shadow: 0 3px 24px rgba(241, 141, 36, 0.6);
  }
}

/* ── 首访招手动画（第一次见到用户） ── */
.teacher-helper__avatar.waving {
  animation: teacherHelperWave 0.6s ease-in-out 4;
}

@keyframes teacherHelperWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

/* ── 响应式 ── */
@media (max-width: 767px) {
  .teacher-helper {
    bottom: calc(var(--footer-height, 64px) + 12px);
    right: 12px;
  }
  .teacher-helper__launcher {
    padding: 5px 5px 5px 14px;
    gap: 6px;
  }
  .teacher-helper__label {
    font-size: 13px;
  }
  .teacher-helper__avatar {
    width: 40px;
    height: 40px;
  }
  .teacher-helper__svg {
    width: 27px;
    height: 27px;
  }
  .teacher-helper__bubble {
    max-width: 170px;
    font-size: var(--text-xs);
    padding: 8px 12px;
  }
  .teacher-helper__dialog-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(var(--footer-height, 64px) + 76px);
  }
}

@media (max-width: 359px) {
  .teacher-helper {
    bottom: 16px;
    right: 8px;
  }
  .teacher-helper__label {
    font-size: 12px;
  }
  .teacher-helper__avatar {
    width: 36px;
    height: 36px;
  }
  .teacher-helper__svg {
    width: 24px;
    height: 24px;
  }
}

/* ================================
   AI 聊天对话 UI 样式（v2 改造）
   ================================ */

/* ── 聊天消息列表容器 ── */
.teacher-helper__dialog-body {
  display: flex;
  flex-direction: column;
  height: 380px;
  padding: 0;
  overflow: hidden;
}

.teacher-helper__chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── 消息气泡（通用） ── */
.teacher-helper__msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

/* ── 用户消息（右对齐，橙色） ── */
.teacher-helper__msg--user {
  background: rgba(241, 141, 36, 0.15);
  color: #d07b1a;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ── AI 消息（左对齐，暖灰） ── */
.teacher-helper__msg--assistant {
  background: #f7f5f2;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* 对话段落间距 */
.teacher-helper__msg p {
  margin: 0 0 6px;
  line-height: 1.6;
}
.teacher-helper__msg p:last-child {
  margin-bottom: 0;
}

/* 标题：加粗放大、间距突出（如"四、xxx" / "总结"） */
.teacher-helper__msg .msg-heading {
  font-size: 15.5px;
  font-weight: 700;
  color: #2a1e15;
  margin: 8px 0 6px;
  line-height: 1.45;
  letter-spacing: 0.2px;
}
.teacher-helper__msg .msg-heading:first-child {
  margin-top: 0;
}

/* 有序列表：数字编号 */
.teacher-helper__msg ol {
  margin: 0 0 6px;
  padding: 0 0 0 22px;
  list-style-type: decimal;
}
.teacher-helper__msg ol li {
  margin-bottom: 5px;
  padding-left: 2px;
  line-height: 1.6;
}
.teacher-helper__msg ol li:last-child {
  margin-bottom: 0;
}

/* 无序列表：圆点 */
.teacher-helper__msg ul {
  margin: 0 0 6px;
  padding: 0 0 0 20px;
  list-style-type: disc;
}
.teacher-helper__msg ul li {
  margin-bottom: 5px;
  line-height: 1.6;
}
.teacher-helper__msg ul li:last-child {
  margin-bottom: 0;
}

/* 列表嵌套在消息气泡中的整体间距 */
.teacher-helper__msg ol:last-child,
.teacher-helper__msg ul:last-child,
.teacher-helper__msg p:last-child {
  margin-bottom: 0;
}

/* ── Loading 指示器消息 ── */
.teacher-helper__msg--loading {
  background: transparent;
  box-shadow: none;
  font-size: 20px;
}

/* ── 三点脉冲动画 ── */
.teacher-helper__dot-pulse span {
  animation: dotPulse 1.4s ease-in-out infinite both;
}
.teacher-helper__dot-pulse span:nth-child(1) { animation-delay: 0s; }
.teacher-helper__dot-pulse span:nth-child(2) { animation-delay: 0.16s; }
.teacher-helper__dot-pulse span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ── 输入区域 ── */
.teacher-helper__chat-input-area {
  padding: 10px 14px 12px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
}

.teacher-helper__chat-input {
  flex: 1;
  border: 1px solid #d9d9d9;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.teacher-helper__chat-input:focus {
  border-color: var(--color-primary, #F18D24);
}

.teacher-helper__chat-send {
  flex: none;
  padding: 8px 18px;
  border-radius: 20px;
  background: rgba(241, 141, 36, 0.12);
  color: var(--color-primary, #F18D24);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.teacher-helper__chat-send:hover {
  background: rgba(241, 141, 36, 0.22);
}

.teacher-helper__chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── 快捷提问按钮区 ── */
.teacher-helper__quick-reply-area {
  padding: 4px 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.teacher-helper__quick-reply-btn {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid #e0d6c8;
  background: #faf8f5;
  color: #5a4a3a;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.teacher-helper__quick-reply-btn:hover {
  background: #f5f0e8;
  border-color: var(--color-primary, #F18D24);
  color: var(--color-primary);
}

/* ── 响应式：移动端聊天布局适配 ── */
@media (max-width: 767px) {
  .teacher-helper__dialog-body {
    height: calc(100vh - var(--footer-height, 64px) - 190px);
  }
  .teacher-helper__chat-input {
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }
}
