/* ===== Oboeshop 智能客服 ===== */
#chatbotToggleBtn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6900, #ff9a3d);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 6px 20px rgba(255, 105, 0, .45);
  transition: all .25s;
  position: relative;
}
#chatbotToggleBtn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 26px rgba(255, 105, 0, .55);
}
#chatbotToggleBtn .chatbot-unread-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: #ff3b30;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: chatbotPulse 1.2s infinite;
}
@keyframes chatbotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: .7; }
}

/* 聊天主窗口 */
#chatbotPanel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-size: 14px;
  animation: chatbotSlideIn .25s ease-out;
}
#chatbotPanel.open { display: flex; }
@keyframes chatbotSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 头部 */
#chatbotPanel .chatbot-header {
  background: linear-gradient(135deg, #FF6900, #ff9a3d);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#chatbotPanel .chatbot-header .chatbot-h-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
#chatbotPanel .chatbot-header .chatbot-h-title {
  flex: 1;
}
#chatbotPanel .chatbot-header .chatbot-h-title b {
  display: block;
  font-size: 15px;
  line-height: 1.3;
}
#chatbotPanel .chatbot-header .chatbot-h-title span {
  display: block;
  font-size: 11px;
  opacity: .85;
  line-height: 1.3;
}
#chatbotPanel .chatbot-header .chatbot-h-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
}
#chatbotPanel .chatbot-header .chatbot-h-btn:hover { background: rgba(255,255,255,.35); }
#chatbotPanel .chatbot-header .chatbot-h-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: .85;
}
#chatbotPanel .chatbot-header .chatbot-h-close:hover { opacity: 1; }

/* 配额条 */
#chatbotPanel .chatbot-quota {
  background: #fff8f2;
  color: #b45309;
  font-size: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid #ffe8d6;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#chatbotPanel .chatbot-quota b { color: #FF6900; }

/* 消息区 */
#chatbotPanel .chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#chatbotPanel .chatbot-body::-webkit-scrollbar { width: 4px; }
#chatbotPanel .chatbot-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

#chatbotPanel .chatbot-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}
#chatbotPanel .chatbot-msg.chatbot-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #FF6900, #ff8c30);
  color: #fff;
  border-bottom-right-radius: 4px;
}
#chatbotPanel .chatbot-msg.chatbot-msg-ai {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
#chatbotPanel .chatbot-msg.chatbot-msg-sys {
  align-self: center;
  background: #f0f0f0;
  color: #888;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  max-width: 90%;
}
#chatbotPanel .chatbot-msg.chatbot-msg-err {
  align-self: center;
  background: #fdecec;
  color: #d4380d;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  max-width: 90%;
  text-align: center;
  font-weight: 500;
  border: 1px solid #ffd6d0;
  box-shadow: 0 2px 8px rgba(212,56,13,.1);
}
/* AI 正在输入… */
#chatbotPanel .chatbot-msg.chatbot-msg-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 15px 16px;
}
#chatbotPanel .chatbot-msg-typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c4c4c4;
  animation: chatbotBlink 1.2s infinite both;
}
#chatbotPanel .chatbot-msg-typing .dot:nth-child(2) { animation-delay: .2s; }
#chatbotPanel .chatbot-msg-typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes chatbotBlink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* 快捷购买/联系通道 */
#chatbotPanel .chatbot-quickbar {
  padding: 10px 14px 0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
#chatbotPanel .chatbot-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 0;
  border-radius: 8px;
  font-size: 12px;
  color: #333;
  text-decoration: none;
  background: #f6f6f6;
  border: 1px solid #eee;
  transition: all .2s;
  white-space: nowrap;
  overflow: hidden;
}
#chatbotPanel .chatbot-quick-btn i { font-size: 13px; }
#chatbotPanel .chatbot-quick-btn:hover { border-color: #FF6900; color: #FF6900; background: #fff7f0; }
/* 淘宝店按钮高亮 */
#chatbotPanel .chatbot-quick-btn:first-child {
  background: linear-gradient(135deg, #FF6900, #ff9a3d);
  color: #fff;
  border-color: transparent;
  font-weight: 500;
}
#chatbotPanel .chatbot-quick-btn:first-child:hover { opacity: .9; color: #fff; }
/* 登录/注册面板打开时隐藏快捷栏，避免挤压 */
#chatbotPanel .chatbot-auth.open + .chatbot-quickbar { display: none; }

/* 消息气泡内的可点击链接 */
#chatbotPanel .chatbot-msg a {
  color: #FF6900;
  text-decoration: underline;
  word-break: break-all;
}
#chatbotPanel .chatbot-msg-user a { color: #fff; }

/* 输入区 */
#chatbotPanel .chatbot-input-bar {
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#chatbotPanel .chatbot-input-bar textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  resize: none;
  height: 42px;
  max-height: 100px;
  line-height: 1.5;
  font-family: inherit;
}
#chatbotPanel .chatbot-input-bar textarea:focus {
  border-color: #FF6900;
  outline: none;
}
#chatbotPanel .chatbot-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #FF6900;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s;
  flex-shrink: 0;
}
#chatbotPanel .chatbot-send-btn:hover { opacity: .85; }
#chatbotPanel .chatbot-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 认证面板（注册/登录） */
#chatbotPanel .chatbot-auth {
  display: none;
  flex-direction: column;
  padding: 20px 20px 16px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  gap: 12px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 60%;
}
#chatbotPanel .chatbot-auth.open { display: flex; }
#chatbotPanel .chatbot-auth .chatbot-auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #f0f0f0;
}
#chatbotPanel .chatbot-auth .chatbot-auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
}
#chatbotPanel .chatbot-auth .chatbot-auth-tab.active {
  color: #FF6900;
  border-bottom-color: #FF6900;
}
#chatbotPanel .chatbot-auth .chatbot-auth-row { display: flex; flex-direction: column; gap: 6px; }
#chatbotPanel .chatbot-auth label { font-size: 12px; color: #666; }
#chatbotPanel .chatbot-auth input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  box-sizing: border-box;
}
#chatbotPanel .chatbot-auth input:focus { border-color: #FF6900; outline: none; }
#chatbotPanel .chatbot-auth .chatbot-auth-code-row { display: flex; gap: 8px; }
#chatbotPanel .chatbot-auth .chatbot-auth-code-row input { flex: 1; }
#chatbotPanel .chatbot-auth .chatbot-sendcode-btn {
  background: #fff3e8;
  color: #FF6900;
  border: 1px solid #ffd2ae;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
#chatbotPanel .chatbot-auth .chatbot-sendcode-btn:disabled { color: #bbb; background: #f5f5f5; border-color: #eee; }
#chatbotPanel .chatbot-auth .chatbot-auth-submit {
  background: #FF6900;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
#chatbotPanel .chatbot-auth .chatbot-auth-submit:hover { opacity: .9; }
#chatbotPanel .chatbot-auth .chatbot-auth-error {
  color: #d4380d;
  font-size: 12px;
  display: none;
}
#chatbotPanel .chatbot-auth .chatbot-auth-switch {
  text-align: center;
  font-size: 12px;
  color: #999;
}
#chatbotPanel .chatbot-auth .chatbot-auth-switch a {
  color: #FF6900;
  cursor: pointer;
  text-decoration: underline;
}

@media (max-width: 768px) {
  #chatbotToggleBtn {
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
  /* 打开聊天面板时隐藏整条底部浮动按钮栏，避免遮挡输入区 */
  body.chatbot-open .float-contact-bar {
    display: none !important;
  }
  #chatbotPanel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: none; /* 覆盖桌面 max-width: calc(100vw - 32px) */
    height: 100vh;
    height: 100dvh; /* iOS 地址栏折叠适配 */
    max-height: none;
    border-radius: 0;
  }
  /* 全屏时关闭按钮加大，方便点击 */
  #chatbotPanel .chatbot-header .chatbot-h-close {
    font-size: 30px;
    padding: 2px 12px;
  }
  /* 输入框字号不小于16px，避免 iOS 聚焦自动放大页面 */
  #chatbotPanel .chatbot-input-bar textarea {
    font-size: 16px;
  }
  /* 输入区适配 iPhone 底部安全区（Home 指示条） */
  #chatbotPanel .chatbot-input-bar {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
