/**
 * assets/css/ai-consult.css —— AI 咨询悬浮窗 + 后台 AI 管理页样式。
 *
 * 仅新增样式类（ai-*），不改动 base.css / admin.css / front.css。
 * 移动端优先：悬浮窗在窄屏全宽抽屉式。
 */

/* ============ 前台悬浮窗 ============ */
.ai-fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--brand, #2563EB);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  z-index: 99990;
  transition: transform .15s ease;
}
.ai-fab:hover { transform: scale(1.06); }
.ai-fab--active { transform: rotate(0); background: #1e40af; }

.ai-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99991;
  font-size: 14px;
  color: #1f2937;
}

/* 关键修复：面板靠 hidden 属性控制显隐。.ai-panel 的 display:flex 是作者样式，
   会盖过浏览器默认的 [hidden]{display:none}，导致面板一直显示、X 关不掉。
   这里用更高优先级的 .ai-panel[hidden] 还原隐藏行为。 */
.ai-panel[hidden] { display: none; }

.ai-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--brand, #2563EB);
  color: #fff;
}
.ai-panel__title { font-weight: 600; }
.ai-panel__close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.ai-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
}

.ai-msg {
  margin-bottom: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-msg--bot { background: #fff; border: 1px solid #e5e7eb; }
.ai-msg--user { background: var(--brand, #2563EB); color: #fff; align-self: flex-end; margin-left: 28px; }

.ai-cites {
  margin: 4px 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ai-cites__label { color: #6b7280; font-size: 12px; }
.ai-chip {
  border: 1px solid var(--brand, #2563EB);
  background: #eff6ff;
  color: var(--brand, #2563EB);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ai-chip:hover { background: #dbeafe; }

.ai-sources {
  margin: 4px 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ai-sources__label { color: #6b7280; font-size: 12px; }
.ai-source {
  color: #2563EB;
  font-size: 12px;
  text-decoration: underline;
}

.ai-panel__input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.ai-input {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  max-height: 80px;
}
.ai-send {
  border: none;
  background: var(--brand, #2563EB);
  color: #fff;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
}
.ai-send:hover { background: #1e40af; }

.ai-mic {
  border: none;
  background: #e5e7eb;
  color: #374151;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.ai-mic:hover { background: #d1d5db; }
.ai-mic--rec {
  background: #fee2e2;
  color: #991b1b;
  animation: ai-mic-pulse 1s infinite;
}
@keyframes ai-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* 语音录音状态提示条（点击话筒后立刻显示"正在启动/录音中"） */
.ai-rec-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}
.ai-rec-hint[hidden] { display: none; }

/* 平板/手机避让课程目录悬浮按钮（.toc-fab）：
   .toc-fab 在 ≤1024px 显示于右下角（right:16px; bottom:20px; 高约 44px），
   桌面（≥1025px）才隐藏。原本 .ai-fab 的避让规则只写在 ≤480px，导致 481–1024px
   平板区间两个悬浮按钮在右下角重叠挡操作。这里把避让上移到 ≤1024px 全覆盖。 */
@media (max-width: 1024px) {
  .ai-fab { right: 14px; bottom: 84px; }
}

/* 窄屏：全宽抽屉 */
@media (max-width: 480px) {
  .ai-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 70vh;
    max-height: 70vh;
    border-radius: 14px 14px 0 0;
  }
}

/* ============ 后台 AI 管理页 ============ */
.ai-chapter { margin-bottom: 16px; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
.ai-chapter__title { background: #f1f5f9; padding: 8px 12px; font-weight: 600; }
.ai-lesson { padding: 8px 12px; border-top: 1px solid #eef2f7; }
.ai-lesson__title { color: #475569; margin-bottom: 6px; font-size: 13px; }
.ai-video {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  flex-wrap: wrap;
}
.ai-video__name { min-width: 120px; flex: 1; }
.ai-video--empty { color: #9ca3af; font-size: 12px; }

.ai-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ai-badge--done { background: #dcfce7; color: #166534; }
.ai-badge--processing { background: #fef9c3; color: #854d0e; }
.ai-badge--failed { background: #fee2e2; color: #991b1b; }
.ai-badge--pending, .ai-badge--none { background: #e5e7eb; color: #374151; }

.ai-line-edit { width: 100%; }

/* ============ 后台：诊断结果输出区（ffmpeg / AI 配置自检） ============ */
.ai-diag {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
  color: #1f2937;
  font-family: inherit;
}
.ai-diag[hidden] { display: none; }
.ai-diag--ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.ai-diag--error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ============ 后台：字幕弹窗（lic-modal 仅 front.css 有，后台页未加载，这里补齐） ============ */
/* 修复「手动粘贴 / 句子」点击没反应：按钮其实已把 modal.hidden=false，但后台页没引 front.css，
   弹窗缺少 position:fixed 遮罩与 [hidden] 还原规则，导致它是一块看不见/不居中的裸 div。 */
.lic-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lic-modal[hidden] { display: none; }
.lic-modal__mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, .55);
  backdrop-filter: blur(2px);
}
.lic-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
  padding: 24px 22px 18px;
  color: #1f2937;
}
.lic-modal__close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 6px;
}
.lic-modal__close:hover { color: #111827; }
.lic-modal__title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}
.lic-modal__desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.6;
}
@media (max-width: 480px) {
  .lic-modal { padding: 10px; align-items: flex-end; }
  .lic-modal__panel { max-width: none; border-radius: 16px 16px 0 0; padding: 20px 16px 16px; }
}
