/* ============================================================
   牛博士 · 全站 AI 答疑助手（悬浮组件）
   注入点：view/public/footer.html；所有页面生效
   ============================================================ */

/* ---------------- 悬浮按钮 ---------------- */
.adoctor-fab {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff7ea, #ffe8cc);
  border: 2px solid #ffb26b;
  box-shadow: 0 8px 24px rgba(255, 0, 110, .28);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.adoctor-fab:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 12px 30px rgba(255, 0, 110, .38); }
.adoctor-fab .adoctor-ox { display: block; }
.adoctor-online {
  position: absolute;
  right: 2px;
  bottom: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #34c77b;
  border: 2.5px solid #fff;
}
.adoctor-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(255, 122, 60, .45);
  animation: adoctorPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes adoctorPulse {
  0% { transform: scale(.92); opacity: .9; }
  70%, 100% { transform: scale(1.22); opacity: 0; }
}

/* ---------------- 打招呼气泡 ---------------- */
.adoctor-bubble {
  position: fixed;
  right: 94px;
  bottom: 36px;
  z-index: 9990;
  max-width: 240px;
  background: #fff;
  border: 1.5px solid #ffd9b8;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 26px 10px 13px;
  font-size: 13px;
  color: #7c4a1e;
  box-shadow: 0 6px 20px rgba(255, 0, 110, .16);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  cursor: pointer;
}
.adoctor-bubble.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.adoctor-bubble-x {
  position: absolute;
  right: 7px;
  top: 5px;
  color: #c98b52;
  font-style: normal;
  font-size: 15px;
  line-height: 1;
}
.adoctor-bubble-x:hover { color: #ff006e; }

/* ---------------- 面板 ---------------- */
.adoctor-panel {
  position: fixed;
  right: 22px;
  bottom: 98px;
  z-index: 9991;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: min(72vh, 640px);
  background: #fffdf9;
  border: 1.5px solid #ffd9b8;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(90, 40, 0, .22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.adoctor-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* 头部 */
.adoctor-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(120deg, #ff006e, #ff006e);
  color: #fff;
}
.adoctor-head-ava {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff7ea;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.adoctor-head-txt { flex: 1; min-width: 0; line-height: 1.3; }
.adoctor-head-txt b { display: block; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adoctor-head-txt span { font-size: 11.5px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.adoctor-head-txt span::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #58e69b;
  margin-right: 4px;
  vertical-align: 1px;
}
.adoctor-head-clear,
.adoctor-head-x {
  flex: none;
  background: rgba(255, 255, 255, .18);
  border: 0;
  color: #fff;
  border-radius: 8px;
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.adoctor-head-x { font-size: 18px; padding: 0 4px 2px; }
.adoctor-head-clear:hover,
.adoctor-head-x:hover { background: rgba(255, 255, 255, .32); }
/* v7.1 主页链接（a 标签与按钮对齐）+ 最大化面板 */
a.adoctor-head-clear { display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; color: #fff; padding: 0 10px; }
a.adoctor-head-clear:hover { color: #fff; }
.adoctor-panel.adoctor-max {
  width: min(960px, calc(100vw - 32px));
  height: min(82vh, 780px);
  right: 16px;
  bottom: 16px;
}
@media (max-width: 600px) {
  .adoctor-panel.adoctor-max { height: 82vh; }
}

/* 消息区 */
.adoctor-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.adoctor-msg { display: flex; gap: 8px; align-items: flex-end; }
.adoctor-msg.user { justify-content: flex-end; }
.adoctor-msg-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff2df;
  border: 1px solid #ffdfba;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.adoctor-msg-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.62;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.adoctor-msg.ai .adoctor-msg-bubble {
  background: #fff;
  border: 1px solid #ffe3c8;
  color: #4a3421;
  border-bottom-left-radius: 4px;
}
.adoctor-msg.user .adoctor-msg-bubble {
  background: linear-gradient(130deg, #ff006e, #ff006e);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.adoctor-fadein { animation: adoctorIn .25s ease; }
@keyframes adoctorIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* markdown 元素 */
.adoctor-h { font-weight: 700; font-size: 14px; margin: 6px 0 2px; color: #c2410c; }
.adoctor-inline-code {
  background: #fff1e0;
  border: 1px solid #ffdcb8;
  border-radius: 5px;
  padding: 1px 5px;
  font-family: Consolas, Menlo, monospace;
  font-size: 12.5px;
  color: #b3441a;
}
.adoctor-codewrap { position: relative; margin: 7px 0; }
.adoctor-code {
  background: #2b2b38;
  color: #e8e6f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
}
.adoctor-code code { font-family: Consolas, 'Courier New', monospace; white-space: pre; }
/* v7 代码高亮 + 复制按钮 */
.adoctor-code .ad-kw { color: #ff79c6; font-weight: 700; }
.adoctor-code .ad-str { color: #f1fa8c; }
.adoctor-code .ad-cm { color: #6272a4; font-style: italic; }
.adoctor-code .ad-inc { color: #8be9fd; }
.adoctor-copy {
  position: absolute; top: 8px; right: 8px;
  border: none; cursor: pointer; z-index: 2;
  font-size: 10.5px; font-weight: 800; color: #e8e6f0;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px; padding: 4px 9px; transition: .15s;
}
.adoctor-copy:hover { background: rgba(255,255,255,.26); }

/* 思考动画 */
.adoctor-thinking .adoctor-msg-bubble { color: #b3763d; }
.adoctor-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ff9a62;
  margin-right: 3px;
  animation: adoctorBlink 1.1s infinite;
}
.adoctor-dot:nth-child(2) { animation-delay: .18s; }
.adoctor-dot:nth-child(3) { animation-delay: .36s; }
@keyframes adoctorBlink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* 快捷提问 */
.adoctor-quicks {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 2px;
}
.adoctor-chip {
  background: #fff;
  border: 1px solid #ffd0a6;
  color: #c2591f;
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.5;
}
.adoctor-chip:hover { background: #ff006e; border-color: #ff006e; color: #fff; }

/* 输入区 */
.adoctor-inputrow {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 10px;
}
.adoctor-inputrow textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid #ffd9b8;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  font-family: inherit;
  background: #fff;
  color: #4a3421;
  outline: none;
  max-height: 96px;
  transition: border-color .15s;
}
.adoctor-inputrow textarea:focus { border-color: #ff006e; box-shadow: 0 0 0 3px rgba(255, 122, 60, .12); }
.adoctor-send {
  flex: none;
  width: 42px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(130deg, #ff006e, #ff006e);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: transform .15s, opacity .15s;
}
.adoctor-send:hover { transform: scale(1.06); }
.adoctor-send.busy { opacity: .55; pointer-events: none; }

/* 底部说明 */
.adoctor-foot {
  flex: none;
  text-align: center;
  font-size: 11px;
  color: #c39a72;
  padding: 0 12px 9px;
}
#adoctorQuota { color: #e0703a; font-weight: 600; margin-right: 4px; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 600px) {
  .adoctor-fab { right: 14px; bottom: 18px; width: 54px; height: 54px; }
  .adoctor-fab .adoctor-ox { width: 40px; height: 40px; }
  .adoctor-bubble { right: 78px; bottom: 26px; }
  .adoctor-panel {
    right: 8px;
    left: 8px;
    bottom: 84px;
    width: auto;
    height: 68vh;
  }
}

/* 打印/低版本降级 */
@media print { .adoctor-fab, .adoctor-panel, .adoctor-bubble { display: none !important; } }
