/* ===== 大厅陪伴宠物 agent-pet 网页版挂件 ===== */
.apet {
  position: fixed;
  right: 150px; /* 左移：避开底部右侧的喇叭发送按钮（约 120px 宽） */
  bottom: 56px; /* 上移：避开底部 30px 高的喇叭滚动条 */
  z-index: 40;
  width: 84px;
  height: 96px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.apet.dragging {
  cursor: grabbing;
}

.apet-sprite {
  width: 100%;
  height: 100%;
  animation: apetBob 3.2s ease-in-out infinite;
  /* 事件透传给宠物容器，避免命中 img 触发原生拖拽/选中 */
  pointer-events: none;
}

.apet-sprite svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
}

/* 自定义精灵图：等比放入，透明背景 PNG/GIF 最佳 */
.apet-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
  -webkit-user-drag: none;
  user-drag: none;
}

/* 待机上下轻晃 */
@keyframes apetBob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* 点击蹦跳（容器级动画，与待机不冲突） */
.apet-jump .apet-sprite {
  animation: apetHop .6s ease;
}

@keyframes apetHop {
  0% {
    transform: translateY(0);
  }

  25% {
    transform: translateY(-22px) scale(1.05);
  }

  45% {
    transform: translateY(0) scale(.94, 1.06);
  }

  62% {
    transform: translateY(-9px);
  }

  100% {
    transform: translateY(0);
  }
}

/* SVG 部位样式 */
.apet .apet-head,
.apet .apet-body {
  fill: #1c1c50;
  stroke: #42e2f5;
  stroke-width: 3;
}

.apet .apet-ear {
  fill: #1c1c50;
  stroke: #42e2f5;
  stroke-width: 3;
  stroke-linejoin: round;
}

/* 眨眼 */
.apet .apet-eyes {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: apetBlink 4.6s infinite;
}

@keyframes apetBlink {
  0%,
  90%,
  100% {
    transform: scaleY(1);
  }

  93%,
  96% {
    transform: scaleY(.12);
  }
}

/* 天线灯闪烁 */
.apet .apet-bulb {
  animation: apetBulb 1.8s ease-in-out infinite;
}

@keyframes apetBulb {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .25;
  }
}

.apet .apet-blush {
  opacity: .65;
}

/* 气泡 */
.apet-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  max-width: 240px;
  width: max-content;
  background: #1e1e52;
  border: 3px solid #0d0d2b;
  border-radius: 12px;
  color: #e8e8ff;
  font-size: 12px;
  line-height: 1.5;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 1px;
  padding: 7px 12px;
  box-shadow: 0 4px 0 #0d0d2b, 0 0 14px rgba(66, 226, 245, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.apet-bubble.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.apet-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0d0d2b;
}

/* 隐藏按钮：悬停宠物时出现 */
.apet-close {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  border: 2px solid #0d0d2b;
  border-radius: 7px;
  background: linear-gradient(180deg, #ff8f8f 0%, #e74c3c 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, transform .06s, box-shadow .06s;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), inset 2px 2px 0 rgba(255, 255, 255, .3), 0 3px 0 #7b1d12;
}

.apet:hover .apet-close,
.apet:focus-within .apet-close {
  opacity: 1;
}

.apet-close:active {
  transform: translateY(2px);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), inset 2px 2px 0 rgba(255, 255, 255, .3), 0 1px 0 #7b1d12;
}

/* 隐藏后：还原小按钮（与宠物同位置规则，避开喇叭条/按钮） */
.apet-restore {
  position: fixed;
  right: 150px;
  bottom: 56px;
  z-index: 40;
  width: 46px;
  height: 46px;
  border: 3px solid #0d0d2b;
  border-radius: 50%;
  background: linear-gradient(180deg, #8ff5ff 0%, #42e2f5 55%, #1594b8 100%);
  color: #0d2b2b;
  font-size: 20px;
  line-height: 40px;
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, .2), inset 3px 3px 0 rgba(255, 255, 255, .4), 0 4px 0 #0b5a70, 0 0 14px rgba(66, 226, 245, .5);
  animation: apetRestorePulse 2s ease-in-out infinite;
}

@keyframes apetRestorePulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

/* 减少动效偏好：关掉待机动画 */
@media (prefers-reduced-motion: reduce) {
  .apet-sprite,
  .apet .apet-eyes,
  .apet .apet-bulb,
  .apet-restore {
    animation: none !important;
  }
}

/* 窄屏：缩小挂件，避开喇叭条/按钮 */
@media (max-width: 640px) {
  .apet {
    right: 100px;
    bottom: 46px;
    width: 64px;
    height: 74px;
  }

  .apet-bubble {
    max-width: 150px;
    font-size: 11px;
  }

  .apet-restore {
    right: 100px;
    bottom: 46px;
    width: 40px;
    height: 40px;
    line-height: 34px;
    font-size: 17px;
  }
}

/* ===== 桌宠聊天窗口（点击宠物，页面正中间弹出） ===== */
.apet-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 5, 20, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: apetChatFade .18s ease;
}

@keyframes apetChatFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.apet-chat-win {
  width: min(420px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #23236b 0%, #16163f 100%);
  border: 3px solid #0d0d2b;
  border-radius: 16px;
  box-shadow: 0 0 0 3px #42e2f5, 0 0 30px rgba(66, 226, 245, .35), 0 12px 0 #0d0d2b;
  overflow: hidden;
  animation: apetChatPop .2s ease;
}

@keyframes apetChatPop {
  from { transform: scale(.9) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.apet-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #42e2f5 0%, #1594b8 100%);
  border-bottom: 3px solid #0d0d2b;
}

.apet-chat-title {
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0d2b2b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .3);
}

.apet-chat-close {
  width: 28px;
  height: 28px;
  border: 2px solid #0d0d2b;
  border-radius: 7px;
  background: linear-gradient(180deg, #ff8f8f 0%, #e74c3c 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), inset 2px 2px 0 rgba(255, 255, 255, .3), 0 3px 0 #7b1d12;
}

.apet-chat-close:active {
  transform: translateY(2px);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), inset 2px 2px 0 rgba(255, 255, 255, .3), 0 1px 0 #7b1d12;
}

.apet-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 30vh;
}

.apet-chat-msg {
  display: flex;
}

.apet-chat-msg.user {
  justify-content: flex-end;
}

.apet-chat-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: .5px;
  word-break: break-word;
  white-space: pre-wrap;
}

.apet-chat-msg.bot .apet-chat-bubble {
  background: #1e1e52;
  border: 2px solid #0d0d2b;
  color: #e8e8ff;
  border-bottom-left-radius: 3px;
  box-shadow: 0 3px 0 #0d0d2b;
}

.apet-chat-msg.user .apet-chat-bubble {
  background: linear-gradient(180deg, #42e2f5 0%, #1594b8 100%);
  border: 2px solid #0d0d2b;
  color: #0d2b2b;
  font-weight: 700;
  border-bottom-right-radius: 3px;
  box-shadow: 0 3px 0 #0d0d2b;
}

.apet-chat-foot {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 3px solid #0d0d2b;
  background: #12123a;
}

.apet-chat-foot input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid #0d0d2b;
  border-radius: 9px;
  background: #1e1e52;
  color: #e8e8ff;
  font-size: 13px;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  outline: none;
}

.apet-chat-foot input:focus {
  border-color: #42e2f5;
  box-shadow: 0 0 0 2px rgba(66, 226, 245, .3);
}

.apet-chat-foot input::placeholder {
  color: #7a7ab0;
}

.apet-chat-send {
  padding: 0 18px;
  border: 2px solid #0d0d2b;
  border-radius: 9px;
  background: linear-gradient(180deg, #8ff5ff 0%, #42e2f5 55%, #1594b8 100%);
  color: #0d2b2b;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .2), inset 2px 2px 0 rgba(255, 255, 255, .4), 0 3px 0 #0b5a70;
}

.apet-chat-send:active {
  transform: translateY(2px);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .2), inset 2px 2px 0 rgba(255, 255, 255, .4), 0 1px 0 #0b5a70;
}

/* ===== 弹窗双 tab：消息通知 / 智能聊天 ===== */
.apet-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px 0;
  background: #12123a;
}

.apet-tab {
  flex: 1;
  padding: 8px 0;
  border: 2px solid #0d0d2b;
  border-radius: 9px;
  background: #1e1e52;
  color: #8a92c9;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  cursor: pointer;
}

.apet-tab.active {
  background: linear-gradient(180deg, #42e2f5 0%, #1594b8 100%);
  color: #0d2b2b;
  box-shadow: 0 3px 0 #0b5a70;
}

.apet-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===== 消息通知列表 ===== */
.apet-nt-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 30vh;
}

.apet-nt-item {
  padding: 10px 12px;
  border: 2px solid #0d0d2b;
  border-radius: 10px;
  background: #1e1e52;
  box-shadow: 0 3px 0 #0d0d2b;
}

.apet-nt-item.unread {
  border-color: #42e2f5;
  box-shadow: 0 0 0 2px rgba(66, 226, 245, .25), 0 3px 0 #0d0d2b;
}

.apet-nt-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.apet-nt-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffe66d;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 1px;
}

.apet-nt-item.unread .apet-nt-title::before {
  content: '●';
  color: #ff8f8f;
  margin-right: 5px;
  font-size: 10px;
  vertical-align: 1px;
}

.apet-nt-time {
  font-size: 11px;
  color: #7a7ab0;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  white-space: nowrap;
}

.apet-nt-body {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #e8e8ff;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  word-break: break-word;
}

.apet-nt-from {
  margin-top: 6px;
  font-size: 11px;
  color: #7a7ab0;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
}

/* 全服通知置顶徽标（标题右侧） */
.apet-nt-pin {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 230, 109, .18);
  border: 1px solid rgba(255, 230, 109, .55);
  color: #ffe66d;
  font-size: 10px;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* 全服通知置顶项操作行：清除置顶（本用户不再显示该通知） */
.apet-nt-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.apet-nt-clearpin {
  padding: 3px 12px;
  border: 1px solid rgba(122, 122, 176, .6);
  border-radius: 8px;
  background: rgba(18, 18, 58, .8);
  color: #8a92c9;
  font-size: 11px;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 1px;
  cursor: pointer;
}

.apet-nt-clearpin:hover {
  border-color: #42e2f5;
  color: #42e2f5;
}

.apet-nt-clearpin:disabled {
  opacity: .5;
  cursor: default;
}

.apet-nt-empty {
  padding: 30px 0;
  text-align: center;
  font-size: 13px;
  color: #7a7ab0;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 1px;
}

.apet-nt-foot {
  padding: 8px 12px;
  border-top: 3px solid #0d0d2b;
  background: #12123a;
  font-size: 11px;
  color: #7a7ab0;
  text-align: center;
  font-family: "Courier New", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 1px;
}
