/* ============================================================
   EHS Copilot · RAG 对话助手 — #page-copilot
   强生红白品牌风 · 聊天工作台 · 流式打字机 · 引用溯源
   ============================================================ */

#page-copilot { padding-bottom: 20px; }

/* ================= 工作台骨架 ================= */
#page-copilot .cop-work {
  display: flex; flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 540px;
}

/* ================= 顶部：引擎徽章 + 预设问题 ================= */
#page-copilot .cop-top {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 12px 16px; margin-bottom: 12px;
}

#page-copilot .cop-engine {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff; padding: 7px 14px; border-radius: 20px;
  box-shadow: 0 2px 10px rgba(204,0,0,.28);
}
#page-copilot .cop-engine-ico { display: flex; }
#page-copilot .cop-engine-ico svg { width: 14px; height: 14px; }
#page-copilot .cop-engine-key {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px; opacity: .82;
}
#page-copilot .cop-engine-val {
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
  max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#page-copilot .cop-engine .dot {
  width: 6px; height: 6px; background: #8FE8C0;
  animation: copPulse 2s infinite;
}
@keyframes copPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); }
  50% { box-shadow: 0 0 0 4px rgba(255,255,255,0); }
}

#page-copilot .cop-presets {
  flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-left: 14px; border-left: 1px solid var(--line-2);
}
#page-copilot .cop-preset {
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: var(--bg); border: 1px solid var(--line);
  padding: 6px 13px; border-radius: 18px; cursor: pointer;
  transition: all .16s ease; white-space: nowrap;
}
#page-copilot .cop-preset:hover {
  color: var(--red); background: var(--red-soft); border-color: #EFC9C9;
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
#page-copilot .cop-preset:active { transform: translateY(0); }
#page-copilot .cop-work.is-streaming .cop-preset { opacity: .5; pointer-events: none; }

/* ================= 中部：消息区 ================= */
#page-copilot .cop-msgs {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  border-radius: var(--radius);
  padding: 4px 4px 6px;
}

#page-copilot .cop-msg-list {
  max-width: 900px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 8px 2px 12px;
}

/* ---- 空态 ---- */
#page-copilot .cop-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 20px;
}
#page-copilot .cop-empty-icon {
  width: 66px; height: 66px; border-radius: 19px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(204,0,0,.3);
  animation: copFloat 3.2s ease-in-out infinite;
}
#page-copilot .cop-empty-icon svg { width: 30px; height: 30px; }
@keyframes copFloat {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
#page-copilot .cop-empty-title {
  margin-top: 18px; font-size: 15px; font-weight: 800; color: var(--ink); letter-spacing: .2px;
}
#page-copilot .cop-empty-sub { margin-top: 8px; font-size: 12px; color: var(--ink-3); letter-spacing: .4px; }

/* ---- 消息行 ---- */
#page-copilot .msg { display: flex; animation: copIn .32s ease both; }
@keyframes copIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* 用户气泡：右对齐红底白字 */
#page-copilot .msg-user { justify-content: flex-end; }
#page-copilot .msg-user-bubble {
  max-width: 68%;
  background: linear-gradient(135deg, var(--red) 0%, #B30000 100%);
  color: #fff; font-size: 13.5px; line-height: 1.7; font-weight: 500;
  padding: 10px 15px; border-radius: 14px 14px 3px 14px;
  box-shadow: 0 3px 12px rgba(204,0,0,.22);
  word-break: break-word; white-space: pre-wrap;
}

/* AI 消息：头像 + 内容卡片 */
#page-copilot .msg-ai { gap: 11px; align-items: flex-start; }
#page-copilot .cop-avatar {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 9px rgba(23,26,31,.10);
}
#page-copilot .cop-avatar-script {
  font-family: 'Snell Roundhand', 'Savoye LET', 'Segoe Script', 'Brush Script MT', 'Kaiti SC', cursive;
  font-style: italic; font-weight: 700; font-size: 15px; color: var(--red);
  line-height: 1; transform: rotate(-2deg);
}
#page-copilot .cop-avatar { overflow: hidden; padding: 3px; }
#page-copilot .cop-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
#page-copilot .msg-card {
  flex: 1; min-width: 0; max-width: calc(100% - 45px);
  background: #fff; border: 1px solid var(--line);
  border-radius: 3px 14px 14px 14px;
  padding: 13px 16px 14px; box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
#page-copilot .msg-ai.is-live .msg-card {
  border-color: #EFC9C9;
  box-shadow: 0 0 0 3px rgba(204,0,0,.05), var(--shadow-sm);
}

#page-copilot .cop-src-row[hidden],
#page-copilot .cop-actions[hidden] { display: none !important; }

/* 引用来源标签行 */
#page-copilot .cop-src-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
#page-copilot .cop-src-label {
  font-size: 11px; font-weight: 600; color: var(--ink-4); margin-right: 2px;
}
#page-copilot .cop-src-row .tag { border-radius: 6px; }

/* 正文 */
#page-copilot .cop-md { font-size: 13px; }
#page-copilot .cop-md > :first-child { margin-top: 0; }
#page-copilot .cop-md > :last-child { margin-bottom: 0; }
#page-copilot .cop-md table { display: table; table-layout: auto; }
#page-copilot .cop-md pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
#page-copilot .cop-md pre code { background: none; padding: 0; }

/* 检索中微动画 */
#page-copilot .cop-loading {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  padding: 3px 0;
}
#page-copilot .cop-loading-dots { display: inline-flex; gap: 4px; }
#page-copilot .cop-loading-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--red);
  animation: copBounce 1.05s infinite ease-in-out;
}
#page-copilot .cop-loading-dots i:nth-child(2) { animation-delay: .15s; }
#page-copilot .cop-loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes copBounce {
  0%,75%,100% { transform: translateY(0); opacity: .35; }
  35% { transform: translateY(-5px); opacity: 1; }
}

/* 错误 / 提示 */
#page-copilot .cop-error {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--red);
  background: var(--red-tint); border-radius: 9px; padding: 10px 13px;
  line-height: 1.6;
}
#page-copilot .cop-error svg { width: 15px; height: 15px; flex-shrink: 0; }
#page-copilot .cop-note {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  background: var(--bg); border-radius: 9px; padding: 10px 13px;
}
#page-copilot .cop-note svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-4); }

/* 底部操作行 */
#page-copilot .cop-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 11px; padding-top: 10px;
  border-top: 1px solid var(--line-2);
}
#page-copilot .cop-actions .cop-copy svg { width: 13px; height: 13px; }
#page-copilot .cop-engine-note {
  margin-left: auto; font-size: 11px; color: var(--ink-4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ================= 底部：输入区 ================= */
#page-copilot .cop-composer { flex-shrink: 0; margin-top: 12px; }

#page-copilot .cop-input-bar {
  display: flex; align-items: flex-end; gap: 12px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 11px 12px 11px 16px;
  transition: border-color .18s, box-shadow .18s;
}
#page-copilot .cop-input-bar:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(204,0,0,.08), var(--shadow-sm);
}
#page-copilot .cop-input {
  flex: 1; min-width: 0;
  border: none; outline: none; resize: none; background: transparent;
  font-family: inherit; font-size: 13.5px; line-height: 1.6; color: var(--ink);
  max-height: 128px; padding: 6px 0;
}
#page-copilot .cop-input::placeholder { color: var(--ink-4); }

#page-copilot .cop-send { min-width: 96px; padding: 9px 18px; }
#page-copilot .cop-send svg { width: 14px; height: 14px; flex-shrink: 0; }

#page-copilot .cop-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 8px; padding: 0 4px;
  font-size: 11px; color: var(--ink-4);
}

/* ================= 响应式兜底 ================= */
@media (max-width: 1100px) {
  #page-copilot .cop-top { flex-direction: column; align-items: flex-start; gap: 10px; }
  #page-copilot .cop-presets { border-left: none; padding-left: 0; border-top: 1px solid var(--line-2); padding-top: 10px; width: 100%; }
  #page-copilot .msg-user-bubble { max-width: 84%; }
}
