/* 悬浮按钮 */
.fab {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 998;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #466aff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(70, 106, 255, 0.4);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  background: #3651d9;
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(70, 106, 255, 0.5);
}

html[data-theme='dark'] .fab {
  background: #5b7aff;
  box-shadow: 0 2px 12px rgba(91, 122, 255, 0.3);
}

html[data-theme='dark'] .fab:hover {
  background: #7b9aff;
}

/* 聊天面板 */
.panel {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  z-index: 999;
  width: 360px;
  height: 480px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html[data-theme='dark'] .panel {
  background: #1e1e2e;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* 头部 */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #466aff;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.closeBtn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.closeBtn:hover {
  opacity: 1;
}

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.userMsg {
  align-self: flex-end;
  background: #466aff;
  color: #fff;
  border-bottom-right-radius: 2px;
}

.aiMsg {
  align-self: flex-start;
  background: #f0f2f5;
  color: #333;
  border-bottom-left-radius: 2px;
}

html[data-theme='dark'] .aiMsg {
  background: #2a2a3e;
  color: #ddd;
}

/* 打字动画 */
.typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #999;
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* 输入区 */
.inputArea {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

html[data-theme='dark'] .inputArea {
  border-top-color: #333;
  background: #1a1a2e;
}

.inputArea input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  color: #333;
}

html[data-theme='dark'] .inputArea input {
  background: #2a2a3e;
  border-color: #444;
  color: #ddd;
}

.inputArea input:focus {
  border-color: #466aff;
}

.sendBtn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: #466aff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sendBtn:not(:disabled):hover {
  background: #3651d9;
}

/* 移动端适配 */
@media (max-width: 480px) {
  .panel {
    left: 0;
    bottom: 0;
    width: 100%;
    height: 70vh;
    border-radius: 12px 12px 0 0;
  }

  .fab {
    left: 1.2rem;
    bottom: 1.2rem;
    width: 44px;
    height: 44px;
  }
}
