/* =============================================
   智慧基层 · 智能宠物伙伴 样式表
   ============================================= */

/* ---------- 全局动画关键帧 ---------- */
@keyframes pet-idle {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
@keyframes pet-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30%       { transform: translateY(-18px) scale(1.05); }
  50%       { transform: translateY(-12px) scale(0.97); }
  70%       { transform: translateY(-6px); }
}
@keyframes pet-tail-wag {
  0%, 100% { transform: rotate(-15deg); }
  50%       { transform: rotate(20deg); }
}
@keyframes pet-ear-flick {
  0%, 90%, 100% { transform: rotate(0deg); }
  95%             { transform: rotate(-10deg); }
}
@keyframes pet-hungry-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-3px); }
  75%       { transform: translateX(3px); }
}
@keyframes pet-bubble-pop {
  0%   { opacity: 0; transform: scale(0.6) translateY(8px); }
  60%  { opacity: 1; transform: scale(1.05) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pet-walk {
  0%   { transform: translateX(0) scaleX(1); }
  25%  { transform: translateX(4px) scaleX(1); }
  50%  { transform: translateX(0) scaleX(-1); }  /* 左右摇头 */
  75%  { transform: translateX(-4px) scaleX(1); }
  100% { transform: translateX(0) scaleX(1); }
}
@keyframes chat-msg-in {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(7, 193, 96, 0); }
}
@keyframes typing-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1); opacity: 1; }
}
@keyframes hunger-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes float-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(7,193,96,0.2); }
  50%       { box-shadow: 0 4px 30px rgba(7,193,96,0.45); }
}

/* ---------- 宠物浮窗主体 ---------- */
.dom-pet-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
}

/* 收起时：只显示宠物头像 */
.dom-pet-float.compact .pet-chat-panel { display: none; }
.dom-pet-float.compact .pet-status-bar { display: none; }

/* 头像按钮 */
.pet-avatar-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float-glow 3s ease-in-out infinite;
  transition: transform 0.2s, border-color 0.3s;
  position: relative;
  overflow: visible;
}
.pet-avatar-btn:hover { transform: scale(1.08); border-color: var(--primary-dark); }
.pet-avatar-btn:active { transform: scale(0.96); }

/* 头像内部（SVG宠物）*/
.pet-avatar-svg {
  width: 58px;
  height: 58px;
  border-radius: 50%;
}

/* 状态指示点 */
.pet-avatar-dot {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pet-avatar-dot.happy  { background: #f59e0b; }
.pet-avatar-dot.normal { background: var(--primary); }
.pet-avatar-dot.hungry { background: #ef4444; animation: hunger-pulse 1.2s infinite; }

/* 悬浮状态条 */
.pet-status-bar {
  position: absolute;
  bottom: 80px;
  right: 0;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  width: 160px;
  display: none;
}
.dom-pet-float:not(.compact) .pet-status-bar { display: block; }

.pet-status-name {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  text-align: center;
  margin-bottom: 8px;
}

.pet-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 12px;
  color: #666;
}
.pet-status-row .bar-track {
  flex: 1;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}
.pet-status-row .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.pet-status-row.hunger .bar-fill { background: linear-gradient(90deg, #ef4444, #f59e0b); }
.pet-status-row.mood    .bar-fill { background: linear-gradient(90deg, #3b82f6, #8b5cf6); }

.pet-level-badge {
  text-align: center;
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* ---------- 聊天面板 ---------- */
.pet-chat-panel {
  position: absolute;
  bottom: 86px;
  right: 0;
  width: 320px;
  height: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pet-bubble-pop 0.3s ease-out;
}

.pet-chat-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.pet-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255,255,255,0.2);
}
.pet-chat-info { flex: 1; }
.pet-chat-name { font-size: 14px; font-weight: 600; }
.pet-chat-status-text { font-size: 11px; opacity: 0.85; }
.pet-chat-close {
  background: none; border: none; color: #fff;
  font-size: 20px; cursor: pointer; padding: 4px;
  line-height: 1; opacity: 0.7; transition: opacity 0.2s;
}
.pet-chat-close:hover { opacity: 1; }

/* 消息列表 */
.pet-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.pet-chat-msgs::-webkit-scrollbar { width: 4px; }
.pet-chat-msgs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.msg-row { display: flex; gap: 6px; align-items: flex-end; animation: chat-msg-in 0.25s ease-out; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar { width: 26px; height: 26px; border-radius: 50%; font-size: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.msg-bubble { max-width: 75%; padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-all; }
.msg-row.ai .msg-avatar { background: #e8f5e9; }
.msg-row.ai .msg-bubble { background: var(--primary-bg); color: #333; border-bottom-left-radius: 4px; }
.msg-row.user .msg-avatar { background: var(--primary); color: #fff; font-size: 12px; }
.msg-row.user .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }

/* typing 指示器 */
.msg-typing { display: flex; gap: 4px; padding: 4px 0; }
.msg-typing span { width: 7px; height: 7px; background: #aaa; border-radius: 50%; animation: typing-dot 1.2s infinite; }
.msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ---------- 输入区 ---------- */
.pet-chat-input-row {
  padding: 8px 10px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  background: #fafafa;
}
.pet-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}
.pet-chat-input:focus { border-color: var(--primary); }
.pet-mic-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: var(--primary-bg); color: var(--primary);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.pet-mic-btn:hover { background: #d4f0dc; }
.pet-mic-btn.recording { background: var(--primary); color: #fff; animation: mic-pulse 1s infinite; }
.pet-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: var(--primary); color: #fff;
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.pet-send-btn:hover { background: var(--primary-dark); }
.pet-send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* ---------- 快捷按钮 ---------- */
.pet-quick-btns {
  padding: 6px 10px 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  border-top: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
.pet-qbtn {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--primary);
  background: var(--primary-bg);
  color: var(--primary-dark);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.pet-qbtn:hover { background: #d4f0dc; }

/* ---------- 宠物气泡提示（跑过去指一指）---------- */
.pet-pointer-bubble {
  position: fixed;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: #333;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 9998;
  pointer-events: none;
  max-width: 180px;
  animation: pet-bubble-pop 0.3s ease-out;
}
.pet-pointer-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--primary);
}
.pet-pointer-bubble::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #fff;
}

/* ---------- 食物按钮（头像旁边）---------- */
.pet-food-btn {
  position: absolute;
  bottom: 0;
  left: -16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #f59e0b;
  color: #f59e0b;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(245,158,11,0.3);
  transition: transform 0.2s;
  animation: pet-idle 3s ease-in-out infinite;
}
.pet-food-btn:hover { transform: scale(1.15); }
.pet-food-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ---------- 宠物选择弹窗（在注册流程中） ---------- */
.pet-select-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99990;
  display: flex; align-items: center; justify-content: center;
}
.pet-select-modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  width: 380px;
  max-width: 90vw;
  text-align: center;
  animation: pet-bubble-pop 0.35s ease-out;
}
.pet-select-title { font-size: 18px; font-weight: 700; color: #333; margin-bottom: 6px; }
.pet-select-sub { font-size: 13px; color: #888; margin-bottom: 20px; }
.pet-options { display: flex; gap: 16px; justify-content: center; margin-bottom: 20px; }
.pet-option {
  flex: 1;
  max-width: 140px;
  border: 3px solid #eee;
  border-radius: 16px;
  padding: 16px 8px;
  cursor: pointer;
  transition: border-color 0.25s, transform 0.2s;
}
.pet-option:hover { border-color: var(--primary); transform: translateY(-2px); }
.pet-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.pet-option-emoji { font-size: 52px; display: block; margin-bottom: 8px; }
.pet-option-name { font-size: 15px; font-weight: 600; color: #333; }
.pet-option-desc { font-size: 11px; color: #888; margin-top: 4px; }
.pet-name-row { margin-bottom: 20px; }
.pet-name-row label { font-size: 13px; color: #666; }
.pet-name-input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  margin-top: 8px;
  box-sizing: border-box;
  text-align: center;
  transition: border-color 0.2s;
}
.pet-name-input:focus { border-color: var(--primary); }
.pet-select-confirm {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.pet-select-confirm:hover { background: var(--primary-dark); }
.pet-select-confirm:disabled { background: #ccc; cursor: not-allowed; }

/* ---------- 喂养商城弹窗 ---------- */
.pet-shop-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99991;
  display: flex; align-items: center; justify-content: center;
}
.pet-shop-modal {
  background: #fff;
  border-radius: 20px;
  width: 360px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: pet-bubble-pop 0.3s ease-out;
}
.pet-shop-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.pet-shop-title { font-size: 16px; font-weight: 700; color: #333; }
.pet-shop-close { background: none; border: none; font-size: 22px; color: #999; cursor: pointer; }
.pet-shop-items { padding: 12px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.pet-shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #eee;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pet-shop-item:hover { border-color: var(--primary); background: #f8fff9; }
.pet-shop-item.owned { border-color: #ccc; background: #fafafa; cursor: default; }
.pet-shop-emoji { font-size: 28px; }
.pet-shop-info { flex: 1; }
.pet-shop-item-name { font-size: 14px; font-weight: 600; color: #333; }
.pet-shop-item-effect { font-size: 11px; color: #888; margin-top: 2px; }
.pet-shop-item-price { font-size: 13px; color: #f59e0b; font-weight: 600; white-space: nowrap; }
.pet-shop-item-price.owned { color: #999; }
.pet-inventory {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #666;
  text-align: center;
  flex-shrink: 0;
  background: #fafafa;
}

/* ---------- 宠物死亡/假死状态 ---------- */
.dom-pet-float.dead .pet-avatar-btn { filter: grayscale(1); opacity: 0.5; border-color: #ccc; animation: none; }
.dom-pet-float.dead .pet-avatar-dot { background: #ccc; }
.dead-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 99995;
  display: flex; align-items: center; justify-content: center;
}
.dead-modal {
  background: #fff; border-radius: 20px;
  padding: 28px 24px; width: 320px;
  text-align: center;
  animation: pet-bubble-pop 0.4s ease-out;
}
.dead-modal h3 { font-size: 20px; color: #ef4444; margin-bottom: 10px; }
.dead-modal p { font-size: 14px; color: #666; margin-bottom: 18px; line-height: 1.6; }
.dead-modal button {
  width: 100%; padding: 12px;
  border-radius: 12px; border: none;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  .dom-pet-float { bottom: 16px; right: 16px; }
  .pet-chat-panel { width: calc(100vw - 32px); right: -16px; height: 55vh; }
  .pet-avatar-btn { width: 60px; height: 60px; }
}

/* ---------- 宠物动画状态类 ---------- */
.pet-sprite { display: inline-block; transition: transform 0.3s; }
.pet-sprite.idle    { animation: pet-idle 3s ease-in-out infinite; }
.pet-sprite.bounce  { animation: pet-bounce 0.8s ease; }
.pet-sprite.hungry  { animation: pet-hungry-shake 0.6s ease-in-out infinite; }
.pet-sprite.walking { animation: pet-walk 0.6s ease-in-out infinite; }
.pet-sprite.sad     { opacity: 0.7; filter: saturate(0.5); }
