/* ================================================================
   【页面/插件】FAQ智能问答插件
   【模块】Widget 前端对话浮层
   【用途】用户端 FAQ 智能问答对话框，覆盖悬浮按钮、对话框、聊天气泡、输入区域、关联问题等完整交互样式
   【关键属性】CSS 自定义变量 (--faq-primary / --faq-secondary / --faq-primary-rgb) 实现主题色定制
   【交互】点击悬浮按钮展开对话框，气泡呼吸/脉冲动画引导，hover 箭头位移，打字动画
   ================================================================ */

/* 悬浮按钮 */
.faq-widget-toggle {
	position: fixed;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	box-shadow: 0 6px 20px rgba(var(--faq-primary-rgb, 102, 126, 234), 0.45);
	cursor: pointer;
	z-index: 999;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s ease, opacity 0.3s ease;
	border: none;
	animation: faq-breathe 2.6s ease-in-out infinite;
}

/* 【FAQ插件】| 【位置变体】控制浮动按钮在屏幕角落的三种位置 */
.faq-widget-pos-bottom-right { bottom: 28px; right: 28px; }
.faq-widget-pos-bottom-left { bottom: 28px; left: 28px; }
.faq-widget-pos-bottom-right-up { bottom: 100px; right: 28px; }

/* 【FAQ插件】| 【呼吸动画 @keyframes faq-breathe】阴影周期性明暗变化，让按钮持续"活"起来 */
@keyframes faq-breathe {
	0%, 100% { box-shadow: 0 6px 20px rgba(var(--faq-primary-rgb, 102, 126, 234), 0.45); }
	50% { box-shadow: 0 6px 36px rgba(var(--faq-primary-rgb, 102, 126, 234), 0.8); }
}

/* 【FAQ插件】| 【脉冲波纹 ::after 伪元素】从按钮边缘向外扩散的圆环，吸引用户点击 */
.faq-widget-toggle::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	border: 2px solid rgba(var(--faq-primary-rgb, 102, 126, 234), 0.65);
	box-sizing: border-box;
	animation: faq-ripple 2.2s ease-out infinite;
	pointer-events: none;
}

@keyframes faq-ripple {
	0% { transform: scale(1); opacity: 0.9; }
	75% { transform: scale(1.75); opacity: 0; }
	100% { transform: scale(1.75); opacity: 0; }
}

/* 【FAQ插件】| 【引导气泡 ::before 伪元素】默认在按钮左侧显示"在线客服"提示气泡，附带动画 */
.faq-widget-toggle::before {
	content: '在线客服';
	position: absolute;
	right: calc(100% + 14px);
	top: 50%;
	transform: translateY(-50%);
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	color: #fff;
	padding: 8px 14px;
	border-radius: 20px;
	box-shadow: 0 6px 20px rgba(var(--faq-primary-rgb, 102, 126, 234), 0.4);
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	line-height: 1;
	animation: faq-bubble 3s ease-in-out infinite;
}

/* 【FAQ插件】| 【引导气泡位置覆盖】bottom-left 位置时气泡移到按钮右侧 */
.faq-widget-toggle.faq-widget-pos-bottom-left::before {
	right: auto;
	left: calc(100% + 14px);
}

/* 【FAQ插件】| 【气泡浮动动画 @keyframes faq-bubble】引导气泡上下微动，增强视觉引导 */
@keyframes faq-bubble {
	0%, 100% { transform: translateY(-50%); }
	50% { transform: translateY(calc(-50% - 5px)); }
}

/* 【FAQ插件】| 【按钮 hover】放大 1.08 倍，同时暂停引导气泡动画 */
.faq-widget-toggle:hover {
	transform: scale(1.08);
}

/* 【FAQ插件】| 【hover 暂停气泡】放大态下暂停气泡动画避免重叠干扰 */
.faq-widget-toggle:hover::before {
	animation-play-state: paused;
}

/* 【FAQ插件】| 【按钮 SVG 图标】白色 30px 图标，置于最上层 */
.faq-widget-toggle svg {
	width: 30px;
	height: 30px;
	fill: #fff;
	position: relative;
	z-index: 1;
}

/* 【FAQ插件】| 【按钮激活态】对话框打开时缩为 0 并隐藏，让出视觉空间 */
.faq-widget-toggle.active {
	transform: scale(0);
	opacity: 0;
	pointer-events: none;
}

/* ================================================================
   【FAQ插件】对话框容器
   ================================================================ */
.faq-widget-container {
	position: fixed;
	width: 380px;
	height: 90vh;
	max-height: calc(100vh - 64px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
	z-index: 99999;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: scale(0.8) translateY(20px);
	pointer-events: none;
	transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 【FAQ插件】| 【容器位置变体】对话框与按钮位置对齐，三个方向变体 */
.faq-widget-container.faq-widget-pos-bottom-right { bottom: 32px; right: 32px; }
.faq-widget-container.faq-widget-pos-bottom-left { bottom: 32px; left: 32px; }
.faq-widget-container.faq-widget-pos-bottom-right-up { bottom: 100px; right: 32px; }

/* 【FAQ插件】| 【容器激活态】弹性弹出动画，从 scale(0.8) 弹入到 scale(1) */
.faq-widget-container.active {
	opacity: 1;
	transform: scale(1) translateY(0);
	pointer-events: auto;
}

/* ================================================================
   【FAQ插件】头部标题栏
   ================================================================ */
.faq-widget-header {
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	color: #fff;
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

/* 【FAQ插件】| 【标题文字 + 图标】左侧标题 + SVG 图标水平排列 */
.faq-widget-header-title {
	font-size: 16px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
}

/* 【FAQ插件】| 【标题图标样式】20px 白色 SVG */
.faq-widget-header-title svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* 【FAQ插件】| 【头部按钮组】右侧清空对话 + 关闭按钮容器 */
.faq-widget-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* 【FAQ插件】| 【清空/关闭按钮】半透明无样式按钮，hover 变为不透明 */
.faq-widget-clear,
.faq-widget-close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.8;
	transition: opacity 0.2s;
}

/* 【FAQ插件】| 【按钮 hover】透明度变为 1，表示可点击 */
.faq-widget-clear:hover,
.faq-widget-close:hover {
	opacity: 1;
}

/* 【FAQ插件】| 【按钮 SVG 图标】20px 白色图标 */
.faq-widget-clear svg,
.faq-widget-close svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* ================================================================
   【FAQ插件】内容区域（消息列表）
   ================================================================ */
.faq-widget-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	scroll-behavior: smooth;
}

/* 【FAQ插件】| 【滚动条样式】窄 4px 滚动条 + 浅灰色圆角滑块 */
.faq-widget-body::-webkit-scrollbar {
	width: 4px;
}

.faq-widget-body::-webkit-scrollbar-thumb {
	background: #ddd;
	border-radius: 2px;
}

/* 【FAQ插件】| 【常见问题小标题】"大家都在问" 引导文字 */
.faq-widget-faq-tip {
	font-size: 12px;
	color: #b5bec2;
	margin: 14px 0 8px;
	padding-left: 4px;
}

/* ================================================================
   【FAQ插件】快捷问题卡片
   ================================================================ */
.faq-widget-question-item {
	padding: 13px 14px;
	margin-bottom: 10px;
	background: #fff;
	border: 1px solid #eef1f2;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.2s;
	font-size: 13px;
	color: #333;
	line-height: 1.5;
	display: flex;
	align-items: center;
	gap: 8px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.faq-widget-question-item:hover {
	background: rgba(var(--faq-primary-rgb, 102, 126, 234), 0.06);
	border-color: var(--faq-primary, #667eea);
	color: var(--faq-primary, #667eea);
	transform: translateX(3px);
	box-shadow: 0 4px 12px rgba(var(--faq-primary-rgb, 102, 126, 234), 0.15);
}

/* 【FAQ插件】| 【问题箭头】右侧 > 箭头，hover 时向右位移并变色 */
.faq-widget-question-item .faq-question-arrow {
	margin-left: auto;
	color: #c4c9cc;
	font-size: 18px;
	line-height: 1;
	flex-shrink: 0;
	transition: all 0.2s;
}

.faq-widget-question-item:hover .faq-question-arrow {
	color: var(--faq-primary, #667eea);
	transform: translateX(2px);
}

/* 【FAQ插件】| 【问题圆点】左侧紫色圆点装饰 */
.faq-widget-question-item .faq-question-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--faq-primary, #667eea);
	margin-top: 7px;
	flex-shrink: 0;
}

/* 【FAQ插件】| 【问题文本】自适应撑满剩余空间 */
.faq-widget-question-item .faq-question-text {
	flex: 1;
}

/* 【FAQ插件】| 【浏览数】浅灰色小号文字，显示问题浏览量 */
.faq-widget-question-item .faq-question-views {
	font-size: 11px;
	color: #bbb;
	flex-shrink: 0;
	margin-top: 2px;
}

/* ================================================================
   【FAQ插件】聊天气泡
   ================================================================ */
.faq-widget-message {
	display: flex;
	margin-bottom: 14px;
	align-items: flex-end;
}

/* 【FAQ插件】| 【用户消息】右对齐，气泡右上角圆角 4px 形成对话感 */
.faq-widget-message-user {
	justify-content: flex-end;
}

.faq-widget-message-user .faq-widget-bubble {
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	color: #fff;
	border-radius: 16px 16px 4px 16px;
	max-width: 78%;
}

/* 【FAQ插件】| 【机器人消息】左对齐，气泡左上角圆角 4px */
.faq-widget-message-bot {
	justify-content: flex-start;
}

/* ================================================================
   【FAQ插件】客服头像
   ================================================================ */
.faq-widget-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-right: 8px;
}

/* 【FAQ插件】| 【头像图标】20px 白色 SVG 图标 */
.faq-widget-avatar svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* ================================================================
   【FAQ插件】消息内容区
   ================================================================ */
.faq-widget-content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 78%;
}

/* 【FAQ插件】| 【用户消息内容区】右对齐，与上方头像/时间对齐 */
.faq-widget-user-content {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	max-width: 78%;
}

/* 【FAQ插件】| 【昵称 + 时间行】客服名称和发送时间水平排列 */
.faq-widget-meta {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 4px 4px;
}

/* 【FAQ插件】| 【昵称文字】浅灰色 11px 小号文字 */
.faq-widget-nickname {
	font-size: 11px;
	color: #b5bec2;
}

/* 【FAQ插件】| 【时间文字】更浅的 10px 时间标注 */
.faq-widget-time {
	font-size: 10px;
	color: #c4c9cc;
}

/* 【FAQ插件】| 【用户消息时间】右对齐的时间行 */
.faq-widget-time-user {
	margin: 0 4px 4px 0;
	text-align: right;
}

/* 【FAQ插件】| 【机器人气泡】浅灰背景 + 左上角圆角，与用户气泡区分 */
.faq-widget-message-bot .faq-widget-bubble {
	background: #f7f8fa;
	color: #333;
	border-radius: 16px 16px 16px 4px;
}

/* 【FAQ插件】| 【气泡基础样式】内边距 12px/14px，13px 字号，自动换行 */
.faq-widget-bubble {
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.6;
	word-break: break-word;
}

/* 【FAQ插件】| 【答案过渡语】"已为您找到相关解答" 引导文字，主题色高亮 */
.faq-widget-answer-lead {
	font-size: 13px;
	color: var(--faq-primary, #667eea);
	font-weight: 500;
	margin-bottom: 8px;
}

/* 【FAQ插件】| 【转人工操作按钮】兜底答案中的"拨打热线"按钮区域 */
.faq-widget-actions {
	margin-top: 12px;
}

.faq-widget-action-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 18px;
	border-radius: 20px;
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	color: #fff;
	font-size: 13px;
	text-decoration: none;
	transition: all 0.2s;
}

.faq-widget-action-btn:hover {
	opacity: 0.9;
	transform: translateY(-1px);
	color: #fff;
	text-decoration: none;
}

.faq-widget-action-btn svg {
	width: 14px;
	height: 14px;
	fill: #fff;
}

/* 【FAQ插件】| 【兜底提示】未匹配答案时的提示文字，浅灰色小字 */
.faq-widget-fallback-note {
	margin-top: 10px;
	font-size: 12px;
	color: #b5bec2;
}

/* ================================================================
   【FAQ插件】富文本答案内容样式
   ================================================================ */
.faq-widget-bubble img {
	max-width: 100%;
	height: auto;
}

.faq-widget-bubble p {
	margin: 0 0 8px;
}

.faq-widget-bubble p:last-child {
	margin-bottom: 0;
}

.faq-widget-bubble ul,
.faq-widget-bubble ol {
	margin: 4px 0 8px;
	padding-left: 20px;
}

.faq-widget-bubble a {
	color: var(--faq-primary, #667eea);
}

/* ================================================================
   【FAQ插件】来源链接
   ================================================================ */
.faq-widget-source {
	margin-top: 10px;
	padding-top: 8px;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
	font-size: 12px;
}

.faq-widget-source a {
	color: var(--faq-primary, #667eea);
	text-decoration: none;
}

/* 【FAQ插件】| 【来源链接 hover】悬停下划线 */
.faq-widget-source a:hover {
	text-decoration: underline;
}

/* ================================================================
   【FAQ插件】关联问题
   ================================================================ */
.faq-widget-related-title {
	font-size: 12px;
	color: #999;
	margin: 10px 0 6px;
	padding-left: 4px;
}

/* 【FAQ插件】| 【关联问题标签】标签式水平排列，可点击跳转，hover 主题色填充 */
.faq-widget-related-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.faq-widget-related-tag {
	padding: 6px 12px;
	background: rgba(var(--faq-primary-rgb, 102, 126, 234), 0.1);
	color: var(--faq-primary, #667eea);
	border-radius: 14px;
	font-size: 12px;
	cursor: pointer;
	transition: all 0.2s;
	border: 1px solid transparent;
}

/* 【FAQ插件】| 【关联标签 hover】主题色填充反转，白色文字 */
.faq-widget-related-tag:hover {
	background: var(--faq-primary, #667eea);
	color: #fff;
}

/* ================================================================
   【FAQ插件】底部输入区域
   ================================================================ */
.faq-widget-footer {
	padding: 12px 16px;
	border-top: 1px solid #f0f0f0;
	flex-shrink: 0;
	display: flex;
	gap: 8px;
}

/* 【FAQ插件】| 【输入框】圆角 20px 搜索框，focus 时边框变主题色 */
.faq-widget-footer input {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #e0e0e0;
	border-radius: 20px;
	font-size: 13px;
	outline: none;
	transition: border-color 0.2s;
}

/* 【FAQ插件】| 【输入框 focus】聚焦时边框变主题色 */
.faq-widget-footer input:focus {
	border-color: var(--faq-primary, #667eea);
}

/* 【FAQ插件】| 【发送按钮】圆形 36px，主题色渐变，hover 放大，disabled 半透明 */
.faq-widget-footer button {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, var(--faq-primary, #667eea) 0%, var(--faq-secondary, #764ba2) 100%);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: all 0.2s;
}

/* 【FAQ插件】| 【发送按钮 hover】轻微放大 + 降低透明度 */
.faq-widget-footer button:hover {
	opacity: 0.9;
	transform: scale(1.05);
}

/* 【FAQ插件】| 【发送按钮 disabled】半透明 + 禁用光标，防止重复提交 */
.faq-widget-footer button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

.faq-widget-footer button svg {
	width: 18px;
	height: 18px;
	fill: #fff;
}

/* ================================================================
   【FAQ插件】"正在输入" 打字动画
   ================================================================ */
/* 【FAQ插件】| 【打字容器】气泡内三个圆点水平排列，模拟"正在输入"状态 */
.faq-widget-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 15px 16px;
}

/* 【FAQ插件】| 【打字圆点】7px 灰色圆点，轮流弹跳动画 */
.faq-widget-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #c4c9cc;
	animation: faq-typing-dot 1.2s infinite ease-in-out;
}

/* 【FAQ插件】| 【打字延时】第二个圆点延迟 0.15s，产生依次弹跳效果 */
.faq-widget-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

/* 【FAQ插件】| 【打字延时】第三个圆点延迟 0.3s */
.faq-widget-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

/* 【FAQ插件】| 【打字弹跳动画 @keyframes faq-typing-dot】三个圆点依次弹跳 -5px，模拟打字节奏 */
@keyframes faq-typing-dot {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

/* ================================================================
   【FAQ插件】空状态
   ================================================================ */
.faq-widget-empty {
	text-align: center;
	padding: 24px;
	color: #ccc;
	font-size: 13px;
}

/* ================================================================
   【FAQ插件】响应式适配（移动端 ≤480px）
   ================================================================ */
@media (max-width: 480px) {
	.faq-widget-container {
		bottom: 0;
		right: 0;
		width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.faq-widget-toggle {
		bottom: 20px;
		right: 20px;
	}
}