/* 客服聊天对话框 */
.chat-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-dialog-overlay.is-open {
  display: flex;
}

.chat-dialog {
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

/* 顶部标题栏 */
.chat-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #3b82f6;
  flex-shrink: 0;
}

.chat-dialog-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.chat-dialog-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-dialog-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.chat-dialog-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-dialog-header-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-dialog-header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-dialog-header-btn svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

.chat-dialog-close {
  margin-left: 0;
}

/* 消息区域 */
.chat-dialog-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
}

.chat-msg {
  margin-bottom: 16px;
}

.chat-msg--user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chat-msg--user .chat-msg-bubble {
  background: #3b82f6;
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 75%;
  word-break: break-word;
}

.chat-msg--user .chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding-right: 2px;
}

.chat-msg--cs {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-msg--cs .chat-msg-body {
  max-width: 75%;
}

.chat-msg--cs .chat-msg-bubble {
  background: #fff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg--cs .chat-msg-bubble p {
  margin: 0 0 8px;
}

.chat-msg--cs .chat-msg-bubble p:last-child {
  margin-bottom: 0;
}

.chat-msg-meta {
  margin-top: 4px;
}

.chat-msg-meta .time {
  font-size: 11px;
  color: #9ca3af;
}

/* 输入区域 */
.chat-dialog-input {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.chat-dialog-textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  color: #111827;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.chat-dialog-textarea::placeholder {
  color: #9ca3af;
}

.chat-dialog-textarea:focus {
  border-color: #93c5fd;
}

.chat-dialog-input-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 8px;
}

.chat-dialog-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-dialog-send:hover {
  background: #2563eb;
}

.chat-dialog-send:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.chat-msg-bubble--loading {
  color: #9ca3af;
}

.chat-dialog-send svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
  fill: none;
}

@media (max-width: 480px) {
  .chat-dialog {
    width: 100%;
    height: calc(100vh - 40px);
    border-radius: 12px;
  }
}
