/**
 * robot-assistant.css
 * 卡通机器人聊天助手样式 · 可独立引入任意页面
 * 依赖宿主页面的 CSS 变量（--accent / --bg-card / --border 等），未定义时使用默认值
 */

/* ========== 浮动机器人按钮 ========== */
.robot-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  cursor: pointer;
  z-index: 10000;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s;
  animation: robotFloat 3s ease-in-out infinite;
}
@keyframes robotFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.robot-fab:hover { transform: scale(1.1) translateY(-3px); }
.robot-fab svg { width: 100%; height: 100%; display: block; }
.robot-fab .robot-bounce { animation: robotBounce 2s ease-in-out infinite; }
@keyframes robotBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.robot-fab .robot-antenna-tip {
  animation: antennaGlow 1.5s ease-in-out infinite;
  transform-origin: center;
}
@keyframes antennaGlow {
  0%, 100% { opacity: 1; r: 3; }
  50% { opacity: 0.5; r: 4; }
}
.robot-fab .robot-eye {
  animation: eyeBlink 4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes eyeBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  93%, 97% { transform: scaleY(0.1); }
}

/* ========== 聊天窗口 ========== */
.chat-window {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 94px;
  width: 380px;
  height: 520px;
  max-height: 80vh;
  background: var(--bg-card, #fdf6ec);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-bright, rgba(192, 57, 43, 0.5));
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  z-index: 10001;
  flex-direction: column;
  overflow: hidden;
  animation: chatOpen 0.35s ease;
}
.chat-window.show { display: flex; }
@keyframes chatOpen {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== 聊天头部 ========== */
.chat-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent, #c0392b), var(--accent-2, #d4af37));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.chat-header-avatar { width: 28px; height: 28px; flex-shrink: 0; }
.chat-header-title { flex: 1; }
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-btn {
  width: 28px; height: 28px;
  border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chat-header-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* ========== 消息列表 ========== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border, rgba(192, 57, 43, 0.25));
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-track { background: transparent; }

/* ========== 消息气泡 ========== */
.chat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent, #c0392b), var(--accent-deep, #8b2c1f));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, rgba(192, 57, 43, 0.25));
  color: var(--text-main, #3e2723);
  border-bottom-left-radius: 4px;
}
.chat-msg.system {
  align-self: center;
  font-size: 12px;
  color: var(--text-dim, #8d6e63);
  background: none;
  padding: 4px;
  text-align: center;
}
.chat-msg.error {
  align-self: center;
  font-size: 12px;
  color: #ff6ec7;
  background: rgba(255, 110, 199, 0.08);
  border: 1px solid rgba(255, 110, 199, 0.2);
  padding: 8px 14px;
  border-radius: 10px;
  text-align: center;
}

/* ========== 打字动画 ========== */
.chat-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, rgba(192, 57, 43, 0.25));
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}
.chat-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent, #c0392b);
  animation: typingDot 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-6px); }
}

/* ========== 输入区 ========== */
.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border, rgba(192, 57, 43, 0.25));
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.05);
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border, rgba(192, 57, 43, 0.25));
  border-radius: 22px;
  background: var(--bg-card, #fdf6ec);
  color: var(--text-main, #3e2723);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  max-height: 100px;
}
.chat-input:focus { border-color: var(--accent, #c0392b); }
.chat-input::placeholder { color: var(--text-dim, #8d6e63); }

.chat-send-btn {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent, #c0392b), var(--accent-deep, #8b2c1f));
  color: #fff;
  border-radius: 50%;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.chat-send-btn:hover { transform: scale(1.1); box-shadow: 0 0 12px rgba(0, 0, 0, 0.2); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ========== 设置面板 ========== */
.chat-settings {
  display: none;
  position: absolute;
  top: 48px; right: 0;
  width: 100%;
  background: var(--bg-card, #fdf6ec);
  border: 1px solid var(--border-bright, rgba(192, 57, 43, 0.5));
  border-radius: 12px;
  padding: 14px;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.chat-settings.show { display: block; }
.chat-settings-title {
  font-size: 13px; font-weight: 700;
  color: var(--accent-deep, #8b2c1f);
  margin-bottom: 10px;
}
.chat-settings-field { margin-bottom: 10px; }
.chat-settings-field label {
  display: block; font-size: 12px;
  color: var(--text-dim, #8d6e63);
  margin-bottom: 4px;
}
.chat-settings-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, rgba(192, 57, 43, 0.25));
  border-radius: 8px;
  background: var(--bg-base, #f5e6d3);
  color: var(--text-main, #3e2723);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.chat-settings-field input:focus { border-color: var(--accent, #c0392b); }
.chat-settings-hint {
  font-size: 11px;
  color: var(--text-dim, #8d6e63);
  margin-top: 6px;
  line-height: 1.5;
}
.chat-settings-save {
  width: 100%;
  padding: 8px;
  margin-top: 6px;
  background: var(--accent, #c0392b);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.chat-settings-save:hover { opacity: 0.85; }

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .chat-window {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }
  .robot-fab {
    right: 16px !important;
    bottom: 16px !important;
    width: 52px !important;
    height: 52px !important;
  }
}
