/* ═══════════════════════════════════════════════════════════════════
 * AI Panel CSS — ai-panel.css
 * 专门管理右侧 AI 对话面板的所有样式。
 * ⚠️ 所有 AI 面板样式只在这里定义，禁止在 index.html 中重复定义。
 * ═══════════════════════════════════════════════════════════════════ */

/* ── 面板容器 ─────────────────────────────────────────────────────── */
.ap { width: 390px; flex-shrink: 0; background: #fff; border-left: 1px solid #ebebeb; display: flex; flex-direction: column; transition: width .3s ease; }
.ap.closed { width: 0; overflow: hidden; }

/* ── 顶部 Tab 栏 ──────────────────────────────────────────────────── */
.ap-hdr { height: 48px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; padding: 0 12px 0 16px; gap: 7px; flex-shrink: 0; }
.ap-tab { font-size: 14px; font-weight: 600; color: #111; padding: 5px 0; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; }
.ap-tab.on { color: #111; border-bottom-color: #111; }
.ap-col { margin-left: auto; width: 24px; height: 24px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #bbb; cursor: pointer; transition: all .15s; }
.ap-col:hover { background: #f5f5f5; color: #666; }
/* 头部操作按钮组 */
.ap-hdr-acts { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.ap-hdr-btn { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #bbb; cursor: pointer; transition: all .15s; background: none; border: none; }
.ap-hdr-btn:hover { background: #f5f5f5; color: #555; }
.ap-hdr-btn svg { width: 15px; height: 15px; }
/* 切换按钮 */
.ap-sug-switch { text-align: center; font-size: 12px; color: #bbb; padding: 4px 0 8px; cursor: pointer; transition: color .15s; flex-shrink: 0; }
.ap-sug-switch:hover { color: #888; }

/* ── 消息列表 ─────────────────────────────────────────────────────── */
#ap-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  padding-bottom: 80px;
  display: flex;
  flex-direction: column;
  gap: 12px; /* 紧凑处理 */
  scroll-behavior: smooth;
}

/* ── 欢迎区块 ─────────────────────────────────────────────────────── */
.ap-welcome { padding: 4px 0 8px; flex-shrink: 0; }
.ap-w-icon { margin-bottom: 12px; }
.ap-w-icon svg { width: 28px; height: 28px; }
.ap-w-title { font-size: 20px; font-weight: 700; color: #111; margin-bottom: 5px; line-height: 1.3; }
.ap-w-sub { font-size: 13px; color: #aaa; }

/* ── 消息气泡 ─────────────────────────────────────────────────────── */
.msg-u {
  align-self: flex-end;
  max-width: 90%;
  background: #111;
  border-radius: 10px 10px 2px 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #fff;
  line-height: 1.55;
  margin-bottom: 6px; /* 紧凑处理 */
}
.msg-ai {
  align-self: flex-start;
  max-width: 100%;
  background: #f7f7f7;
  border-radius: 10px 10px 10px 2px;
  padding: 10px 14px;
  font-size: 13px;
  color: #333;
  line-height: 1.55;
  margin-bottom: 6px; /* 紧凑处理 */
}

/* ── AI 思考中状态 ────────────────────────────────────────────────── */
.msg-ai.stream {
  background: #f8f9ff;
  border: 1px solid #e8edff;
}
.msg-ai.stream::after {
  content: '●';
  animation: blink 1s infinite;
  margin-left: 4px;
  color: #aaa;
  font-size: 10px;
}

/* ── 模拟进度条 ───────────────────────────────────────────────────── */
.think-progress-container {
  width: 100%;
  height: 5px;
  background: #eee;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.think-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f46e5, #0ea5e9);
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

/* ── 反馈工具栏（每条 AI 消息底部） ──────────────────────────────── */
.msg-ai-tools {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  justify-content: flex-start;
}
.msg-ai-tool {
  cursor: pointer;
  font-size: 13px;
  color: #888;
  background: #f5f5f5;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #eee;
  transition: all 0.2s;
  user-select: none;
}
.msg-ai-tool:hover {
  color: #4f46e5;
  border-color: #4f46e5;
  background: #eef2ff;
}
.msg-ai-tool.on {
  color: #4f46e5;
  border-color: #4f46e5;
  background: #eef2ff;
  font-weight: 600;
}

/* ── 快捷选项按钮 ─────────────────────────────────────────────────── */
.chat-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.choice-btn {
  padding: 6px 14px;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
  font-size: 12px;
  color: #4a7eff;
  background: #fff;
  cursor: pointer;
  transition: all .15s;
}
.choice-btn:hover { background: #f0f7ff; border-color: #c5d8fc; transform: translateY(-1px); }
.choice-btn.on { background: #111; color: #fff; border-color: #111; }

/* ── 问卷引导样式 (V4 极简紧凑版) ────────────────────────────────────────── */
.ap-question-block {
  margin: 4px 0; /* 极简 */
  padding: 0;
  border-bottom: 1px solid #f8f8f8;
  padding-bottom: 4px; /* 极简 */
}
.ap-question-block:last-child { border-bottom: none; }

.ap-question-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px; /* 极简 */
  color: #111;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.ap-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px; /* 极简 */
  margin-bottom: 4px;
}

.ap-option-btn {
  border: 1px solid #e2e2e2;
  background: #fff;
  padding: 8px 2px;
  font-size: 11px;
  text-align: center;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-option-btn:hover {
  border-color: #4a7eff;
  color: #4a7eff;
  background: #f0f7ff;
}
.ap-option-btn.on {
  border-color: #111;
  background: #111;
  color: #fff;
}

.ap-question-input-wrap {
  position: relative;
  margin-top: 4px;
  display: none;
}
.ap-question-input-wrap.show {
  display: block;
}
.ap-question-input {
  width: 100%;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #333;
  outline: none;
  background: #fafafa;
  transition: all 0.2s;
}
.ap-question-input:focus {
  border-color: #4a7eff;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(74,126,255,0.1);
}
.ap-question-input::placeholder { color: #ccc; }

/* 批量提交按钮 */
.ap-survey-submit-wrap {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}
.ap-survey-submit {
  background: #111;
  color: #fff;
  padding: 10px 32px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.ap-survey-submit:hover {
  background: #333;
  transform: translateY(-1px);
}

/* 跳过按钮 */
.ap-skip-btn {
  font-size: 11px;
  color: #999;
  cursor: pointer;
  text-decoration: underline;
  margin-left: auto;
  font-weight: normal;
}
.ap-skip-btn:hover { color: #666; }

/* 选中状态 */
.ap-option-btn.selected {
  background: #111 !important;
  color: #fff !important;
  border-color: #111 !important;
}

/* ── 模型偏好弹窗 (图 2 样式) ─────────────────────────────────────── */
.ap-model-pop {
  position: fixed;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 10px 48px rgba(0,0,0,0.12);
  width: 330px;
  padding: 20px;
  z-index: 1000;
  display: none;
  border: 1px solid #f0f0f0;
  animation: popIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ap-model-pop.show { display: block; }

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ap-model-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.ap-model-title { font-size: 16px; font-weight: 700; color: #111; }
.ap-model-auto-wrap { display: flex; align-items: center; gap: 10px; }
.ap-model-auto-lbl { font-size: 14px; color: #666; }

.ap-model-toggle {
  width: 36px; height: 20px; background: #e2e8f0; border-radius: 10px;
  position: relative; cursor: pointer; transition: all 0.2s;
}
.ap-model-toggle.on { background: #1e293b; }
.ap-model-toggle-dot {
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px; transition: all 0.2s cubic-bezier(0.18, 0.89, 0.35, 1.15);
}
.ap-model-toggle.on .ap-model-toggle-dot { left: 18px; }

.ap-model-tabs {
  background: #f1f5f9; border-radius: 12px; display: flex; padding: 4px; margin-bottom: 20px;
}
.ap-model-tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 14px; font-weight: 600;
  color: #64748b; cursor: pointer; border-radius: 9px; transition: all 0.2s;
}
.ap-model-tab.on { background: #fff; color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.ap-model-list { display: flex; flex-direction: column; gap: 4px; }
.ap-model-card {
  display: flex; gap: 14px; padding: 14px; border-radius: 16px;
  cursor: pointer; transition: all 0.2s; position: relative;
  background: transparent; border: 1.5px solid transparent;
}
.ap-model-card:hover { background: #f8fafc; }
.ap-model-card.on { background: #f8fafc; border-color: transparent; }

.ap-model-ico {
  width: 36px; height: 36px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.ap-model-ico svg { width: 20px; height: 20px; }

.ap-model-info { flex: 1; min-width: 0; }
.ap-model-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.ap-model-name { font-size: 14px; font-weight: 700; color: #1e293b; }
.ap-model-tag {
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.ap-model-tag.default { background: #dbeafe; color: #2563eb; }

.ap-model-desc { font-size: 12px; color: #64748b; margin-bottom: 6px; line-height: 1.4; }
.ap-model-time {
  display: inline-block; font-size: 11px; background: #f1f5f9; color: #64748b;
  padding: 2px 8px; border-radius: 6px; font-weight: 600;
}

.ap-model-check {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  color: #2563eb; opacity: 0; transition: all 0.2s;
}
.ap-model-card.on .ap-model-check { opacity: 1; }
.ap-model-check svg { width: 16px; height: 16px; stroke-width: 3; fill: none; stroke: currentColor; }

/* ── 推荐卡片 ─────────────────────────────────────────────────────── */
.ap-sug { background: #fff; border: 1px solid #ebebeb; border-radius: 12px; padding: 0; cursor: pointer; transition: all .15s; display: flex; align-items: center; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04); margin-bottom: 8px; flex-shrink: 0; }
.ap-sug:hover { border-color: #ddd; box-shadow: 0 4px 16px rgba(0,0,0,.08); background: #fcfcfc; }
.ap-sug-content { flex: 1; padding: 8px 12px; min-width: 0; }
.ap-sug-title { font-size: 13px; font-weight: 600; color: #111; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-sug-desc { font-size: 11px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-sug-more { font-size: 11px; color: #bbb; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.ap-sug-img { width: 50px; height: 50px; flex-shrink: 0; border-left: 1px solid #f0f0f0; }

/* ── 反馈弹窗 ─────────────────────────────────────────────────────── */
#feedback-modal .modal { width: 320px; }
.fb-ta { width: 100%; height: 80px; background: #2a2a2a; color: #fff; padding: 10px; border-radius: 8px; margin: 12px 0; font-size: 13px; }

/* ── 底部输入区域 ─────────────────────────────────────────────────── */
.ap-shorts { padding: 8px 16px; border-top: 1px solid #f0f0f0; display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.ap-short { padding: 5px 12px; border: 1px solid #e8e8e8; border-radius: 14px; font-size: 12px; color: #666; cursor: pointer; transition: all .15s; background: #fff; }
.ap-short:hover { border-color: #bbb; color: #111; background: #fafafa; }

.ap-inp-area { padding: 8px 16px 16px; border-top: 1px solid #f0f0f0; flex-shrink: 0; background: #fff; }
.ap-inp-box { 
  background: #fff; 
  border: 1px solid #e5e5e5; 
  border-radius: 16px; 
  padding: 10px 12px; 
  transition: all .24s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
}
.ap-inp-box:focus-within { 
  border-color: #d0d0d0; 
  box-shadow: 0 4px 20px rgba(0,0,0,0.06); 
}

.ap-ta { 
  width: 100%; 
  background: transparent; 
  font-size: 14px; 
  color: #111; 
  resize: none; 
  min-height: 48px; 
  max-height: 160px; 
  line-height: 1.6; 
  display: block; 
  border: none;
  outline: none;
  padding: 4px 0;
  margin-bottom: 8px;
}
.ap-ta::placeholder { color: #bbb; font-weight: 400; }

.ap-inp-actions { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  padding-top: 4px;
}
.ap-tools, .ap-action-btns { display: flex; align-items: center; gap: 4px; }

.ap-tool-btn { 
  width: 32px; 
  height: 32px; 
  border-radius: 50%; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: #888; 
  cursor: pointer; 
  transition: all .15s; 
  background: none;
  border: 1px solid transparent;
}
.ap-tool-btn:hover { 
  background: #f5f5f5; 
  color: #333; 
}
.ap-tool-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.ap-send { 
  width: 32px; 
  height: 32px; 
  border-radius: 50%; 
  background: #334155; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: #fff; 
  cursor: pointer; 
  transition: all .2s; 
  border: none;
  margin-left: 4px;
}
.ap-send:hover { background: #0f172a; transform: scale(1.05); }
.ap-send svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.5; }

/* ── 附件预览区 (集成在盒子内) ───────────────────────────────────────── */
.ap-attach-preview { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  padding-bottom: 10px; 
  border-bottom: 1px solid #f8f8f8;
  margin-bottom: 8px;
}
.ap-attach-preview:empty { display: none; }
.ap-attach-chip { position: relative; width: 48px; height: 48px; border-radius: 10px; }
.ap-chip-name { display: none; }
.ap-attach-chip img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid #eee; }
.ap-attach-chip .ap-chip-rm { 
  position: absolute; top: -6px; right: -6px; 
  width: 18px; height: 18px; border-radius: 50%; 
  background: rgba(0,0,0,0.6); color: #fff; 
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; backdrop-filter: blur(4px);
}
