/* ============================================================
 * Aidama校园墙 - AI宠物模块 前端样式
 * 文件: assets/css/pet.css  (由 templates/footer.php 全站引入)
 * 包含: 聊天弹窗 / 右键菜单 / 状态面板 / 隐藏后显示按钮 / 睡眠动效
 * ============================================================ */

/* ---------- 聊天弹窗 ---------- */
.pet-chat-panel {
  position: fixed;
  right: 16px;
  bottom: 140px;              /* 悬浮在宠物上方 */
  width: 330px;
  max-width: calc(100vw - 32px);
  height: 460px;              /* 固定高度：聊天时宠物让位到面板上方 */
  background: #fff;
  border: 2.5px solid #2D2D2D;
  border-radius: 18px;
  box-shadow: 6px 6px 0 rgba(45,45,45,.25);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.pet-chat-panel.show { display: flex; }

.pet-chat-head {
  background: linear-gradient(135deg, #FF9A5A, #FF6B35);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 2.5px solid #2D2D2D;
}
.pet-chat-head .pet-chat-title {
  font-weight: 800;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.pet-chat-head .pet-chat-title .pet-tag {
  font-size: .72rem;
  background: rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pet-chat-close {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.pet-chat-close:hover { background: rgba(255,255,255,.35); }

/* 精力/积分条 */
.pet-chat-assets {
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  background: #FFF8F0;
  border-bottom: 2px dashed #FFD9B3;
  font-size: .78rem;
}
.pet-asset {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pet-asset .pet-asset-label { color: #718096; font-weight: 600; }
.pet-asset .pet-asset-bar {
  height: 7px;
  background: #eee;
  border-radius: 20px;
  overflow: hidden;
}
.pet-asset .pet-asset-bar > i {
  display: block;
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, #FFB03A, #FF6B35);
  transition: width .4s ease;
}
.pet-asset.asset-point .pet-asset-bar > i { background: linear-gradient(90deg, #48bb78, #38a169); }

.pet-chat-body {
  flex: 1 1 auto;          /* 随面板高度弹性伸缩：软键盘弹出面板被压缩时消息区自动变小，输入框始终可见 */
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FFFDF8;
}
.pet-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: .86rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.pet-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #FF9A5A, #FF6B35);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pet-msg.ai {
  align-self: flex-start;
  background: #fff;
  border: 1.5px solid #2D2D2D;
  border-bottom-left-radius: 4px;
  box-shadow: 2px 2px 0 rgba(45,45,45,.12);
}
.pet-msg.ai.blocked { background: #FFF0F0; border-color: #E86A5E; }
.pet-msg .pet-msg-meta {
  display: block;
  margin-top: 4px;
  font-size: .7rem;
  color: #B8A9A0;
}
.pet-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid #2D2D2D;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.pet-chat-typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #FF9A5A;
  animation: petDot 1.2s infinite ease-in-out;
}
.pet-chat-typing i:nth-child(2) { animation-delay: .2s; }
.pet-chat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes petDot { 0%,80%,100% { transform: translateY(0); opacity:.5 } 40% { transform: translateY(-5px); opacity:1 } }

/* 多轮记忆提示条（聊天框输入区上方） */
.pet-chat-memory-tip {
  font-size: .72rem;
  color: #92600a;
  background: #fff7e0;
  border-top: 1px solid #ffe9b8;
  padding: 6px 12px;
  line-height: 1.45;
}

/* 我的宠物面板：模式开关 */
.petModeToggle {
  flex: 1;
  display: block;
  background: rgba(255,255,255,.65);
  border: 1.5px solid rgba(90,58,0,.15);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 700;
  color: #7c4a03;
  transition: background .2s, border-color .2s;
}
.petModeToggle input { display: none; }
.petModeToggle .petModeDesc {
  display: block;
  font-size: .72rem;
  font-weight: 400;
  opacity: .7;
  margin-top: 2px;
}
.petModeToggle:has(input:checked) {
  background: #fff;
  border-color: #7c4a03;
  box-shadow: 0 2px 8px rgba(124,74,3,.15);
}
.petModeToggle:has(input:checked)::after {
  content: ' ✓';
  color: #7c4a03;
}

/* 挂件右键菜单：模式开关 */
.pet-mode-switch {
  float: right;
  font-size: .72rem;
  font-weight: 700;
  background: #eee;
  color: #888;
  border-radius: 10px;
  padding: 1px 8px;
  margin-top: 1px;
}
.pet-mode-switch.on {
  background: #FF6B35;
  color: #fff;
}

.pet-chat-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 2.5px solid #2D2D2D;
  background: #fff;
}

/* 校园墙文案快捷指令（写投稿/寻物/卖二手/找跑腿） */
.pet-chat-quick {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  background: #fff;
  flex-wrap: wrap;
}
.pet-chat-quick button {
  border: 2px solid #FFE0C7;
  background: #FFF8F0;
  color: #E86A3D;
  font-size: .74rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.pet-chat-quick button:active { background: #FFE9D8; }

.pet-chat-input {
  flex: 1;
  border: 2px solid #eee;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: .86rem;
  outline: none;
  font-family: inherit;
}
.pet-chat-input:focus { border-color: #FF9A5A; }
.pet-chat-send {
  border: none;
  background: linear-gradient(135deg, #FF9A5A, #FF6B35);
  color: #fff;
  font-weight: 800;
  border-radius: 12px;
  padding: 0 18px;
  cursor: pointer;
  border: 2px solid #2D2D2D;
}
.pet-chat-send:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 右键菜单 ---------- */
.pet-menu {
  position: fixed;
  z-index: 99999;
  min-width: 168px;
  background: #fff;
  border: 2px solid #2D2D2D;
  border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(45,45,45,.2);
  padding: 6px;
  display: none;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.pet-menu.show { display: block; }
.pet-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: #2D2D2D;
  cursor: pointer;
  text-align: left;
}
.pet-menu-item:hover { background: #FFF3E4; }
.pet-menu-item.danger { color: #E86A5E; }
.pet-menu-item .pet-menu-arrow { margin-left: auto; color: #BBB; }
.pet-menu-sub { /* 投喂子菜单(食物列表) */
  display: none;
  position: absolute;
  left: calc(100% - 4px);
  top: -8px;
  min-width: 172px;
  background: #fff;
  border: 2px solid #2D2D2D;
  border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(45,45,45,.2);
  padding: 6px;
}
.pet-menu-item:hover > .pet-menu-sub { display: block; }
.pet-menu-food {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: #718096;
  white-space: nowrap;
}
.pet-menu-food b { color: #E86A5E; }

/* ---------- 状态面板 ---------- */
.pet-status-panel {
  position: fixed;
  right: 20px;
  bottom: 210px;
  width: 250px;
  background: #fff;
  border: 2.5px solid #2D2D2D;
  border-radius: 16px;
  box-shadow: 6px 6px 0 rgba(45,45,45,.25);
  z-index: 99999;
  padding: 14px;
  display: none;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}
.pet-status-panel.show { display: block; }
.pet-status-panel h6 {
  margin: 0 0 10px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pet-status-panel .pet-status-close {
  border: none; background: #f0f0f0;
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: .8rem; line-height: 1;
}
.pet-stat-row { margin-bottom: 9px; }
.pet-stat-row .pet-stat-label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 3px;
}
.pet-stat-row .pet-stat-label b { color: #2D2D2D; }
.pet-stat-bar { height: 8px; background: #f0f0f0; border-radius: 20px; overflow: hidden; }
.pet-stat-bar > i {
  display: block; height: 100%; border-radius: 20px;
  background: linear-gradient(90deg, #FFB03A, #FF6B35);
  transition: width .4s ease;
}
.pet-stat-bar.hunger > i { background: linear-gradient(90deg, #FFB03A, #FF6B35); }
.pet-stat-bar.mood > i   { background: linear-gradient(90deg, #F472B6, #FF2D78); }
.pet-stat-bar.exp > i    { background: linear-gradient(90deg, #48bb78, #38a169); }
.pet-stat-bar.energy > i { background: linear-gradient(90deg, #5a6fd6, #2D3A8C); }
.pet-stat-bar.point > i  { background: linear-gradient(90deg, #FBBF24, #D97706); }
.pet-stat-note {
  font-size: .75rem;
  color: #718096;
  margin-top: 4px;
  text-align: center;
}

/* ---------- 睡眠/饥饿状态：覆盖 sprite 的表现 ---------- */
.pet-sprite-sleeping {
  opacity: .82;
  filter: grayscale(.25);
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .pet-chat-panel { right: 10px; width: calc(100vw - 20px); bottom: 130px; height: min(52vh, 440px); }
  .pet-status-panel { right: 10px; width: calc(100vw - 20px); }
}

/* 软键盘弹出（kb-open）时：隐藏精力/积分条与记忆提示，空间让给聊天记录，保证能看到最新消息 */
.pet-chat-panel.kb-open .pet-chat-assets,
.pet-chat-panel.kb-open .pet-chat-memory-tip,
.pet-chat-panel.kb-open .pet-chat-quick { display: none; }
.pet-chat-panel.kb-open .pet-chat-body { min-height: 70px; }

/* 自定义"叫醒 mino"小圆点（隐藏宠物后显示；放左下角，避开右下角联系管理/加号悬浮按钮） */
#petRestoreBtn {
  position: fixed; left: 16px; bottom: 24px; z-index: 10000;
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #2D2D2D; background: linear-gradient(135deg, #FFB84D, #FF8A3D);
  font-size: 21px; line-height: 1; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.28); cursor: pointer;
  padding: 0; transition: transform .15s;
}
#petRestoreBtn:active { transform: scale(.9); }
