/* ===================================================
   在线客服聊天组件 - 样式表
   使用 .cc- 前缀隔离，不污染页面样式
   =================================================== */

/* === 悬浮按钮 === */
.cc-widget-btn {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1677ff;
  box-shadow: 0 4px 16px rgba(22,119,255,0.35);
  cursor: pointer;
  z-index: 99998;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
}
.cc-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(22,119,255,0.45);
}
.cc-widget-btn.cc-bottom-right { right: 24px; bottom: 80px; }
.cc-widget-btn.cc-bottom-left  { left: 24px; bottom: 80px; }

.cc-widget-btn svg { width: 28px; height: 28px; fill: #fff; }

/* === 未读角标 === */
.cc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #ff4d4f;
  color: #fff;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  line-height: 20px;
  display: none;
}
.cc-badge.cc-visible { display: block; }

/* === 聊天窗口 === */
.cc-window {
  position: fixed;
  width: 380px;
  height: 560px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
}
.cc-window.cc-open { display: flex; }
.cc-window.cc-bottom-right { right: 24px; bottom: 148px; }
.cc-window.cc-bottom-left  { left: 24px; bottom: 148px; }

/* === 头部 === */
.cc-header {
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.cc-header-title {
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cc-header-status {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.cc-header-status .dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 4px;
}
.cc-header-status .dot.online { background: #52c41a; }
.cc-header-status .dot.offline { background: #ff4d4f; }

.cc-header-actions { display: flex; gap: 4px; }
.cc-header-actions button {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 6px;
  color: #fff; cursor: pointer;
  font-size: 16px; line-height: 28px;
  transition: background 0.2s;
}
.cc-header-actions button:hover { background: rgba(255,255,255,0.3); }

/* === 消息区域 === */
.cc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f5f6fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cc-messages::-webkit-scrollbar { width: 5px; }
.cc-messages::-webkit-scrollbar-thumb {
  background: #d9d9d9; border-radius: 3px;
}

/* === 系统提示 === */
.cc-system-tip {
  text-align: center;
  color: #999;
  font-size: 12px;
  padding: 4px 0;
}

/* === 时间标签 === */
.cc-time-label {
  text-align: center;
  color: #ccc;
  font-size: 11px;
  margin: 4px 0;
}

/* === 消息气泡 === */
.cc-bubble-wrap { display: flex; }
.cc-bubble-wrap.cc-agent { justify-content: flex-start; }
.cc-bubble-wrap.cc-customer { justify-content: flex-end; }
.cc-bubble-wrap.cc-system { justify-content: center; }

.cc-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  position: relative;
  animation: ccFadeIn 0.25s ease;
}
@keyframes ccFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cc-bubble.cc-agent-msg {
  background: #fff;
  border-top-left-radius: 2px;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cc-bubble.cc-customer-msg {
  background: #1677ff;
  border-top-right-radius: 2px;
  color: #fff;
}
.cc-bubble.cc-system-msg {
  background: none;
  color: #999;
  font-size: 12px;
  max-width: 100%;
  text-align: center;
}

.cc-bubble .cc-time {
  font-size: 11px;
  color: rgba(0,0,0,0.35);
  margin-top: 6px;
  text-align: right;
}
.cc-bubble.cc-customer-msg .cc-time {
  color: rgba(255,255,255,0.55);
}

/* === 图片消息 === */
.cc-bubble .cc-image {
  max-width: 200px;
  border-radius: 8px;
  cursor: pointer;
}

/* === 商品卡片 === */
.cc-product-card {
  width: 240px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
}
.cc-product-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}
.cc-product-card .cc-product-info {
  padding: 10px 12px;
}
.cc-product-card .cc-product-name {
  font-size: 13px;
  color: #333;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-product-card .cc-product-price {
  font-size: 15px;
  color: #ff4d4f;
  font-weight: 600;
  margin-top: 6px;
}

/* === 输入区域 === */
.cc-input-area {
  padding: 10px 12px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
}
.cc-input-area textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  max-height: 80px;
  min-height: 24px;
  font-family: inherit;
  padding: 4px 0;
}
.cc-input-area textarea::placeholder { color: #bbb; }
.cc-input-area .cc-toolbar { display: flex; gap: 2px; align-items: center; }
.cc-input-area .cc-toolbar button {
  width: 32px; height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #999;
  font-size: 18px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cc-input-area .cc-toolbar button:hover {
  color: #1677ff;
  background: rgba(22,119,255,0.08);
}
.cc-input-area .cc-send-btn {
  width: 36px; height: 36px;
  background: #1677ff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cc-input-area .cc-send-btn:hover { background: #0958d9; }
.cc-input-area .cc-send-btn:disabled {
  background: #d9d9d9;
  cursor: not-allowed;
}

/* === 快捷回复（客服端） === */
.cc-quick-replies {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}
.cc-quick-replies button {
  padding: 4px 12px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 14px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cc-quick-replies button:hover {
  color: #1677ff;
  border-color: #1677ff;
  background: rgba(22,119,255,0.04);
}

/* === 占位/加载 === */
.cc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 13px;
}
.cc-loading::before {
  content: "";
  width: 16px; height: 16px;
  border: 2px solid #e8e8e8;
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: ccSpin 0.6s linear infinite;
  margin-right: 8px;
}
@keyframes ccSpin {
  to { transform: rotate(360deg); }
}

.cc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
  font-size: 14px;
  gap: 12px;
}
.cc-empty svg { width: 48px; height: 48px; fill: #ddd; }

/* === 移动端适配 === */
@media (max-width: 480px) {
  .cc-window {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    top: 0; right: 0; bottom: 0; left: 0;
  }
  .cc-window.cc-open { display: flex; }
  .cc-window.cc-bottom-right,
  .cc-window.cc-bottom-left { right: 0; bottom: 0; }
}
