/*
 * Loan Chat Widget v1.0
 * 网页客服插件样式表
 */

:root {
  /* 颜色配置 */
  --chat-primary: #1e9fff;
  --chat-primary-dark: #1890e6;
  --chat-bg: #ffffff;
  --chat-header-text: #ffffff;
  --chat-bubble-left: #f5f5f5;
  --chat-bubble-right: #1e9fff;
  --chat-text: #333333;
  --chat-text-light: #999999;
  --chat-border: #e8e8e8;
  --chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --chat-link: #1e9fff;

  /* 尺寸配置 */
  --chat-width: 360px;
  --chat-height: 520px;
  --chat-radius: 12px;
  --chat-avatar-size: 40px;
}

/* 插件容器 */
#loan-chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  box-sizing: border-box;
}

#loan-chat-widget *,
#loan-chat-widget *::before,
#loan-chat-widget *::after {
  box-sizing: border-box;
}

/* 悬浮按钮 */
.chat-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: absolute;
  right: 0;
  bottom: 0;
  opacity: 0;
  transform: scale(0.8) translateY(20px);
}

.chat-launcher.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.chat-launcher:hover {
  transform: scale(1.05);
  background: var(--chat-primary-dark);
}

.chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* 对话框 */
.chat-dialog {
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  right: 0;
  bottom: 76px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
  visibility: hidden;
}

.chat-dialog.open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* 头部 */
.chat-header {
  background: var(--chat-primary);
  color: var(--chat-header-text);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: var(--chat-avatar-size);
  height: var(--chat-avatar-size);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: #fff;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
}

.chat-subtitle {
  font-size: 12px;
  opacity: 0.9;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.chat-header-btn:hover {
  opacity: 1;
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

.chat-time {
  text-align: center;
  color: var(--chat-text-light);
  font-size: 12px;
  margin-bottom: 16px;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message.user .chat-bubble {
  background: var(--chat-bubble-right);
  color: #fff;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 4px;
}

.chat-message.user .chat-bubble a {
  color: #fff;
  text-decoration: underline;
}

.chat-bubble {
  max-width: 240px;
  padding: 10px 12px;
  background: var(--chat-bubble-left);
  color: var(--chat-text);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-bubble a {
  color: var(--chat-link);
  text-decoration: none;
}

.chat-bubble a:hover {
  text-decoration: underline;
}

/* 快捷按钮 */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 0 16px 12px;
  background: #f9fafb;
  flex-shrink: 0;
}

.chat-quick-btn {
  padding: 6px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  background: #fff;
  color: var(--chat-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-quick-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
}

/* 输入区域 */
.chat-footer {
  border-top: 1px solid var(--chat-border);
  padding: 10px 12px;
  background: #fff;
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--chat-text);
  background: transparent;
  resize: none;
  height: 36px;
  line-height: 20px;
  padding: 8px 0;
  font-family: inherit;
}

.chat-input::placeholder {
  color: var(--chat-text-light);
}

.chat-send-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--chat-primary);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.chat-send-btn:hover {
  background: var(--chat-primary-dark);
}

/* 移动端适配 */
@media screen and (max-width: 480px) {
  .chat-dialog {
    width: calc(100vw - 40px);
    height: 60vh;
    max-height: 480px;
  }
}
