/* EchoService 前端聊天挂件样式(前缀 ecs- 避免冲突) */

#ecs-root {
	--ecs-primary: #2563eb;
	--ecs-primary-dark: #1d4ed8;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99999;
	font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

/* 气泡按钮 */
.ecs-bubble {
	width: 56px;
	height: 56px;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--ecs-primary), var(--ecs-primary-dark));
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
}

.ecs-bubble:hover {
	transform: scale(1.06);
}

.ecs-bubble .ecs-icon-close { display: none; }
.ecs-open .ecs-bubble .ecs-icon-chat { display: none; }
.ecs-open .ecs-bubble .ecs-icon-close { display: block; }

/* 面板 */
.ecs-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 360px;
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	display: none;
	flex-direction: column;
	overflow: hidden;
}

.ecs-open .ecs-panel { display: flex; }

.ecs-header {
	background: linear-gradient(135deg, var(--ecs-primary), var(--ecs-primary-dark));
	color: #fff;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.ecs-back {
	background: none;
	border: 0;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	padding: 0 6px 2px 0;
	cursor: pointer;
	flex-shrink: 0;
}

.ecs-header-left {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	flex: 1;
}

.ecs-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	flex-shrink: 0;
}

.ecs-title { font-weight: 600; font-size: 15px; }

.ecs-ai-badge {
	font-size: 11px;
	font-weight: 600;
	background: rgba(255, 255, 255, 0.25);
	color: #fff;
	padding: 1px 7px;
	border-radius: 999px;
	margin-left: 7px;
	letter-spacing: 0.5px;
}

.ecs-lead-link {
	background: rgba(255, 255, 255, 0.18);
	border: 0;
	color: #fff;
	font-size: 12px;
	padding: 4px 10px;
	border-radius: 999px;
	cursor: pointer;
}

.ecs-lead-link:hover { background: rgba(255, 255, 255, 0.3); }

/* 渠道菜单 */
.ecs-menu {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f6f7f9;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ecs-menu-item {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 12px 14px;
	cursor: pointer;
	font: inherit;
	text-align: left;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ecs-menu-item:hover {
	border-color: var(--ecs-primary);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ecs-mi-icon {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	flex-shrink: 0;
	background: var(--ecs-primary);
}

.ecs-mi-wechat .ecs-mi-icon { background: #07c160; }
.ecs-mi-whatsapp .ecs-mi-icon { background: #25d366; }
.ecs-mi-email .ecs-mi-icon { background: #64748b; }
.ecs-mi-lead .ecs-mi-icon { background: #f59e0b; }

.ecs-mi-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ecs-mi-label {
	font-weight: 600;
	color: #1f2937;
	font-size: 14px;
}

.ecs-mi-sub {
	color: #6b7280;
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 渠道信息视图(二维码 / 号码) */
.ecs-info {
	flex: 1;
	overflow-y: auto;
	padding: 24px 18px;
	background: #f6f7f9;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	text-align: center;
}

.ecs-info-title {
	font-weight: 600;
	font-size: 15px;
	color: #1f2937;
}

.ecs-info-qr {
	width: 180px;
	height: 180px;
	object-fit: contain;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 8px;
}

.ecs-info-value-row {
	display: flex;
	align-items: center;
	gap: 10px;
}

.ecs-info-value {
	font-size: 17px;
	font-weight: 600;
	color: #1f2937;
	word-break: break-all;
}

.ecs-info-hint {
	color: #6b7280;
	font-size: 12px;
}

/* 消息区 */
.ecs-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f6f7f9;
}

.ecs-msg { display: flex; margin-bottom: 10px; }
.ecs-msg-user { justify-content: flex-end; }
.ecs-msg-assistant { justify-content: flex-start; }
.ecs-msg-system { justify-content: center; }

.ecs-msg-body {
	display: flex;
	flex-direction: column;
	max-width: 80%;
	min-width: 0;
}

.ecs-msg-user .ecs-msg-body { align-items: flex-end; }
.ecs-msg-assistant .ecs-msg-body { align-items: flex-start; }
.ecs-msg-system .ecs-msg-body { align-items: center; max-width: 100%; }

.ecs-msg-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
	margin-right: 8px;
	flex-shrink: 0;
	align-self: flex-end;
}

.ecs-msg-bubble {
	max-width: 100%;
	padding: 9px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-break: break-word;
}

.ecs-msg-user .ecs-msg-bubble {
	background: var(--ecs-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.ecs-msg-assistant .ecs-msg-bubble {
	background: #fff;
	color: #1f2937;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

.ecs-msg-system .ecs-msg-bubble {
	background: transparent;
	color: #6b7280;
	font-size: 12px;
	text-align: center;
}

/* 快捷问题 */
.ecs-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 4px 0 10px;
}

.ecs-quick-btn {
	background: #fff;
	border: 1px solid var(--ecs-primary);
	color: var(--ecs-primary);
	border-radius: 999px;
	padding: 6px 12px;
	cursor: pointer;
	font: inherit;
	font-size: 13px;
}

.ecs-quick-btn:hover {
	background: var(--ecs-primary);
	color: #fff;
}

/* 引导气泡(未打开时) */
.ecs-teaser {
	position: absolute;
	bottom: 10px;
	right: 68px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 10px 12px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
	display: flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
	cursor: pointer;
	font-size: 13px;
	color: #1f2937;
}

.ecs-teaser-close {
	background: none;
	border: 0;
	color: #9ca3af;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
	padding: 0 2px;
}

.ecs-teaser-close:hover { color: #4b5563; }

/* 左侧位置 */
#ecs-root.ecs-pos-left {
	left: 24px;
	right: auto;
}

.ecs-pos-left .ecs-panel {
	left: 0;
	right: auto;
}

.ecs-pos-left .ecs-teaser {
	left: 68px;
	right: auto;
}

/* 回复评价(点赞/点踩) */
.ecs-rate {
	display: flex;
	gap: 4px;
	margin: 3px 0 0 4px;
}

.ecs-rate-btn {
	background: none;
	border: 0;
	padding: 3px;
	cursor: pointer;
	color: #b6bcc4;
	line-height: 0;
	border-radius: 4px;
}

.ecs-rate-btn:hover {
	color: #6b7280;
	background: #eceef1;
}

.ecs-rate-up.ecs-rate-active { color: var(--ecs-primary); }
.ecs-rate-down.ecs-rate-active { color: #dc2626; }

/* 输入中动画 */
.ecs-typing span {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin: 0 2px;
	background: #9ca3af;
	border-radius: 50%;
	animation: ecs-blink 1.2s infinite both;
}

.ecs-typing span:nth-child(2) { animation-delay: 0.2s; }
.ecs-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ecs-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

/* 输入区 */
.ecs-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
	flex-shrink: 0;
}

.ecs-textarea {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 8px 10px;
	font: inherit;
	resize: none;
	max-height: 90px;
	outline: none;
	box-sizing: border-box;
}

.ecs-textarea:focus { border-color: var(--ecs-primary); }

.ecs-send {
	border: 0;
	background: var(--ecs-primary);
	color: #fff;
	padding: 8px 16px;
	border-radius: 10px;
	cursor: pointer;
	font: inherit;
	flex-shrink: 0;
}

.ecs-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ecs-send:hover:not(:disabled) { background: var(--ecs-primary-dark); }

/* 留言表单 */
.ecs-lead {
	padding: 14px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
	flex-shrink: 0;
}

.ecs-lead-title { font-weight: 600; margin-bottom: 10px; color: #1f2937; }

.ecs-field {
	display: block;
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 8px 10px;
	margin-bottom: 8px;
	font: inherit;
	outline: none;
}

.ecs-field:focus { border-color: var(--ecs-primary); }
.ecs-field-error { border-color: #dc2626; }
.ecs-lead-textarea { height: 64px; resize: none; }

.ecs-lead-actions { display: flex; gap: 8px; }

.ecs-btn {
	border: 0;
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
	font: inherit;
}

.ecs-btn-primary { background: var(--ecs-primary); color: #fff; }
.ecs-btn-primary:disabled { opacity: 0.5; }
.ecs-btn-plain { background: #f3f4f6; color: #374151; }

.ecs-hidden { display: none !important; }

/* 移动端 */
@media (max-width: 480px) {
	#ecs-root { right: 12px; bottom: 12px; }
	#ecs-root.ecs-pos-left { left: 12px; }

	.ecs-panel {
		width: calc(100vw - 24px);
		height: 70vh;
		bottom: 68px;
	}

	.ecs-teaser { white-space: normal; max-width: 60vw; }
}
