/* 整站会话/客服浮动组件 */
.chat-widget-root {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  box-sizing: border-box;
}
.chat-widget-root * {
  box-sizing: border-box;
}

/* 右下角触发按钮：固定定位并置于最上层 */
.chat-widget-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 9999;
}
.chat-widget-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.chat-widget-trigger svg {
  width: 28px;
  height: 28px;
}
.chat-widget-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.chat-widget-badge.hide {
  display: none;
}

/* 面板容器 */
.chat-widget-panel {
  position: fixed;
  right: 24px;
  bottom: 90px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-widget-panel-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-widget-panel-header .chat-widget-header-actions { display: flex; align-items: center; gap: 6px; }
.chat-widget-panel-header .chat-widget-notify-btn { background: rgba(255,255,255,0.2); border: none; color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.chat-widget-panel-header .chat-widget-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.chat-widget-panel-header .chat-widget-close:hover {
  background: rgba(255,255,255,0.3);
}

.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-widget-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
}
.chat-widget-msg.system {
  align-self: center;
  background: #e2e8f0;
  color: #64748b;
  font-size: 12px;
}
.chat-widget-msg.self {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
}
.chat-widget-msg.other {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}
.chat-widget-msg .chat-widget-msg-meta {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 4px;
}
.chat-widget-msg .chat-widget-msg-sender {
  font-weight: 600;
  margin-right: 4px;
}
.chat-widget-msg.self .chat-widget-msg-sender { color: rgba(255,255,255,0.95); }
.chat-widget-msg.other .chat-widget-msg-sender { color: #1e293b; }

.chat-widget-new-message-toast {
  align-self: center;
  padding: 6px 14px;
  border-radius: 20px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  animation: chat-widget-toast-in 0.25s ease;
}
@keyframes chat-widget-toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-widget-input-area {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
.chat-widget-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-widget-input-area textarea {
  flex: 1;
  min-height: 44px;
  max-height: 100px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
}
.chat-widget-input-area textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.chat-widget-send {
  padding: 10px 18px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}
.chat-widget-send:hover {
  background: #1d4ed8;
}
.chat-widget-send:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.chat-widget-loading,
.chat-widget-error {
  padding: 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}
.chat-widget-error {
  color: #dc2626;
}
