/* ==================== 在线客服窗口样式 ==================== */
.chat-widget {
  position: fixed;
  right: 18px;
  bottom: 80px;
  z-index: 950;
  width: 340px;
  max-width: calc(100vw - 24px);
  height: 460px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-widget.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.chat-widget .chat-head {
  background: linear-gradient(135deg, #0a0e1a 0%, #1a2742 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-widget .chat-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}
.chat-widget .chat-head-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5a623 0%, #ffb74d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-widget .chat-head-avatar svg { width: 18px; height: 18px; }
.chat-widget .chat-head-status {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: #9ae6b4;
  margin-top: 1px;
}
.chat-widget .chat-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.chat-widget .chat-close:hover { background: rgba(255, 255, 255, 0.2); }

.chat-widget .chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f5f6f8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-widget .chat-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
  animation: chatIn 0.25s ease;
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-widget .chat-msg.system {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e8e8e8;
  border-top-left-radius: 4px;
}
.chat-widget .chat-msg.customer {
  align-self: flex-end;
  background: linear-gradient(135deg, #f5a623 0%, #ffb74d 100%);
  color: #0a0e1a;
  border-top-right-radius: 4px;
}
.chat-widget .chat-msg.agent {
  align-self: flex-start;
  background: #1a2742;
  color: #fff;
  border-top-left-radius: 4px;
}
.chat-widget .chat-msg-time {
  display: block;
  font-size: 0.68rem;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

.chat-widget .chat-foot {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.chat-widget .chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-widget .chat-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 0.88rem;
  outline: none;
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 80px;
  line-height: 1.4;
}
.chat-widget .chat-input:focus { border-color: #f5a623; box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.12); }
.chat-widget .chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f5a623 0%, #ffb74d 100%);
  color: #0a0e1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.chat-widget .chat-send:hover { transform: scale(1.05); }
.chat-widget .chat-send svg { width: 18px; height: 18px; }

.chat-widget .chat-leave-btn {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border: 1px dashed #f5a623;
  border-radius: 10px;
  background: #fffdf5;
  color: #c97f12;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
  font-family: inherit;
}
.chat-widget .chat-leave-btn:hover { background: #fff8ea; }

/* 留资表单 */
.chat-widget .chat-leave-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-widget .chat-leave-form input {
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.86rem;
  outline: none;
  font-family: inherit;
}
.chat-widget .chat-leave-form input:focus { border-color: #f5a623; }
.chat-widget .chat-leave-submit {
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5a623 0%, #ffb74d 100%);
  color: #0a0e1a;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}

/* 快捷模板 */
.chat-widget .chat-quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 12px 10px;
  background: #fff;
  flex-shrink: 0;
}
.chat-widget .chat-quick-tag {
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 14px;
  background: #f5f6f8;
  border: 1px solid #e8e8e8;
  color: #666;
  cursor: pointer;
  transition: 0.2s;
}
.chat-widget .chat-quick-tag:hover { border-color: #f5a623; color: #c97f12; }

/* 打字指示 */
.chat-widget .chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 10px 13px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  border-top-left-radius: 4px;
}
.chat-widget .chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bbb;
  animation: chatBounce 1.2s infinite;
}
.chat-widget .chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-widget .chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

@media (max-width: 768px) {
  .chat-widget {
    right: 10px;
    bottom: 76px;
    width: calc(100vw - 20px);
    height: 60vh;
  }
}
