/* ============================================
   缝纫线智能客服 - 微信风格聊天界面
   ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --brand: #07c160;           /* 微信绿 */
  --brand-dark: #06ad56;
  --bg-page: #f0f0f0;
  --bg-chat: #f7f7f7;
  --bubble-agent: #ffffff;
  --bubble-user: #95ec69;
  --text-main: #1a1a1a;
  --text-sub: #888888;
  --border: #e5e5e5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: var(--text-main);
}

/* 手机外壳（桌面预览时居中显示） */
.phone-shell {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  max-height: 860px;
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  position: relative;
  overflow: hidden;
}

/* ---------- 顶部栏 ---------- */
.chat-header {
  background: #ededed;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
}
.status-dot {
  width: 8px; height: 8px;
  background: var(--brand);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.header-right {
  font-size: 11px;
  color: #fff;
  background: var(--brand);
  border-radius: 10px;
  padding: 3px 10px;
}
.header-right.offline {
  background: #999;
}

/* ---------- 消息区 ---------- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 4px; }
.chat-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }

.bubble {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
}
.agent-bubble .avatar { margin-right: 10px; }
.user-bubble { flex-direction: row-reverse; }
.user-bubble .avatar { background: #7d7d7d; margin-left: 10px; }

.bubble-content {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.bubble-text {
  background: var(--bubble-agent);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.user-bubble .bubble-text {
  background: var(--bubble-user);
  border-radius: 12px 4px 12px 12px;
}

/* 打字动画 */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 6px; height: 6px;
  background: #b0b0b0;
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* 快捷按钮 */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.quick-btn {
  background: #fff;
  border: 1px solid var(--brand);
  color: var(--brand-dark);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.quick-btn:hover { background: #e8f8ef; }
.quick-btn:active { transform: scale(0.96); }

/* 系统提示气泡 */
.system-tip {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  margin: 12px 0;
}

/* ---------- 输入区 ---------- */
.chat-input-area {
  background: #f4f4f4;
  border-top: 1px solid var(--border);
  padding: 10px 12px 8px;
  flex-shrink: 0;
}
.input-row {
  display: flex;
  gap: 10px;
}
.input-row input {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
.input-row input:focus { box-shadow: 0 0 0 2px rgba(7,193,96,0.2); }
#sendBtn {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 22px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}
#sendBtn:hover { background: var(--brand-dark); }
#sendBtn:disabled { background: #b8dcc6; cursor: not-allowed; }
.hint-row {
  text-align: center;
  font-size: 11px;
  color: var(--text-sub);
  padding-top: 6px;
}

/* 大屏适配 */
@media (min-width: 480px) {
  .phone-shell {
    border-radius: 24px;
    height: min(860px, 94vh);
    margin: 2vh auto;
  }
  .chat-body { padding: 18px 16px; }
}

/* 移动端全屏 */
@media (max-width: 479px) {
  .phone-shell { max-height: none; }
}
