/* ===== WWOEM Floating AI Customer Service Widget ===== */
:root {
  --ai-primary: #8B2942;
  --ai-primary-2: #a8345a;
  --ai-bg: #faf7f2;
  --ai-text: #2b2118;
  --ai-muted: #8a7d6d;
  --ai-border: #ece3d8;
  --ai-gold: #c9a24b;
}

.ai-chat-bubble {
  position: fixed;
  right: 16px;
  bottom: 0;
  width: auto;
  height: 112px;
  border-radius: 0;
  border: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: flex-end;
  overflow: visible;
  cursor: pointer;
  z-index: 99998;
  transition: transform .2s ease, opacity .2s ease;
}
.ai-chat-bubble img {
  width: auto;
  height: 100%;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(43, 33, 24, 0.28));
  animation: ai-pet-bob 3.2s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
  transition: opacity .06s linear;
}
.ai-chat-bubble .ai-pet-img-wave {
  position: absolute;
  right: 0;
  bottom: 0;
  opacity: 0;
}
.ai-chat-bubble.ai-waving .ai-pet-img-wave { opacity: 1; }
.ai-chat-bubble.ai-waving .ai-pet-img-rest { opacity: 0; }
.ai-chat-dot {
  position: absolute;
  top: 10px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e03131;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(224, 49, 49, 0.55);
  animation: ai-dot-pulse 1.8s ease-out infinite;
  pointer-events: none;
}
.ai-chat-bubble:hover { transform: scale(1.06); transform-origin: center bottom; }
.ai-chat-bubble-hidden { opacity: 0; transform: translateY(30%); pointer-events: none; }

@keyframes ai-pet-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes ai-dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 49, 49, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(224, 49, 49, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 49, 49, 0); }
}

/* 入场：从屏幕底缘弹上来 */
.ai-pet-start { transform: translateY(140%); }
.ai-pet-in { animation: ai-pet-in .7s cubic-bezier(.18, .9, .32, 1.35) forwards; }
@keyframes ai-pet-in {
  from { transform: translateY(140%); }
  to { transform: translateY(0); }
}

/* 问候气泡 */
.ai-chat-greet {
  position: fixed;
  right: 104px;
  bottom: 64px;
  max-width: 250px;
  background: #fff;
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
  border-left: 3px solid var(--ai-primary);
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  font-family: inherit;
  box-shadow: 0 14px 34px rgba(43, 33, 24, 0.20);
  z-index: 99997;
  opacity: 0;
  transform: translateY(10px) scale(.96);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.ai-chat-greet.ai-show { opacity: 1; transform: translateY(0) scale(1); }
.ai-chat-greet::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: 16px;
  width: 0; height: 0;
  border: 8px solid transparent;
  border-left-color: #fff;
  filter: drop-shadow(1px 1px 0 var(--ai-border));
}

.ai-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 122px;
  width: 380px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--ai-bg);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(43, 33, 24, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
}
.ai-chat-panel.ai-chat-open { display: flex; animation: ai-panel-in .22s ease; }

@keyframes ai-panel-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-header {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-2));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-chat-head-info { display: flex; align-items: center; gap: 10px; }
.ai-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
  overflow: hidden;
  flex: 0 0 auto;
}
.ai-chat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
  pointer-events: none;
  user-select: none;
}
.ai-chat-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.ai-chat-sub { font-size: 11.5px; opacity: .85; margin-top: 2px; }
.ai-chat-close {
  background: transparent; border: none; color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
  opacity: .9;
}
.ai-chat-close:hover { opacity: 1; }

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ai-bg);
}

.ai-msg { max-width: 86%; display: flex; flex-direction: column; }
.ai-msg-user { align-self: flex-end; align-items: flex-end; }
.ai-msg-bot { align-self: flex-start; align-items: flex-start; }
.ai-msg-text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.ai-msg-user .ai-msg-text {
  background: var(--ai-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-bot .ai-msg-text {
  background: #fff;
  color: var(--ai-text);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 4px;
}
.ai-msg-tag {
  font-size: 10px;
  color: var(--ai-muted);
  margin: 0 4px 3px;
  background: rgba(201,162,75,0.14);
  border-radius: 6px;
  padding: 1px 6px;
}

.ai-typing { padding: 10px 14px; background: #fff; border: 1px solid var(--ai-border); border-radius: 14px; border-bottom-left-radius: 4px; }
.ai-typing span {
  display: inline-block; width: 7px; height: 7px; margin: 0 2px;
  background: var(--ai-muted); border-radius: 50%;
  animation: ai-typing-bounce 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .18s; }
.ai-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.ai-chat-quick {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ai-chat-chip {
  background: #fff;
  border: 1px solid #d9c3a0;
  color: var(--ai-primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ai-chat-chip:hover { background: var(--ai-primary); color: #fff; border-color: var(--ai-primary); }

.ai-chat-inputrow {
  padding: 12px 14px;
  border-top: 1px solid var(--ai-border);
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  border: 1px solid #d9c3a0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 96px;
  line-height: 1.4;
  color: var(--ai-text);
}
.ai-chat-input:focus { border-color: var(--ai-primary); box-shadow: 0 0 0 2px rgba(139,41,66,0.12); }
.ai-chat-send {
  background: var(--ai-primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  height: 42px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  flex: 0 0 auto;
  transition: background .15s ease;
}
.ai-chat-send:hover { background: var(--ai-primary-2); }
.ai-chat-send:disabled { opacity: .55; cursor: default; }

/* RTL（阿拉伯语）调整 */
.ai-chat-panel[dir="rtl"] .ai-msg-user { align-self: flex-start; }
.ai-chat-panel[dir="rtl"] .ai-msg-bot { align-self: flex-end; }
.ai-chat-panel[dir="rtl"] .ai-msg-user .ai-msg-text { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
.ai-chat-panel[dir="rtl"] .ai-msg-bot .ai-msg-text { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }

/* 移动端：底部抽屉 */
@media (max-width: 600px) {
  .ai-chat-bubble { right: 8px; height: 92px; }
  .ai-chat-dot { top: 6px; right: 2px; }
  .ai-chat-greet { right: 70px; bottom: 100px; max-width: 200px; font-size: 12.5px; }
  .ai-chat-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%; max-width: 100%;
    height: auto; max-height: 85vh;
    border-radius: 18px 18px 0 0;
  }
}
