/**
 * FAQ 对话框样式
 * 类似火山助手的展示效果
 */

/* 悬浮按钮 */
.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-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; }

/* 呼吸光晕：阴影周期性明暗变化，让按钮持续“活”起来 */
@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-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; }
}

/* 引导气泡：默认在按钮左侧（bottom-right / bottom-right-up 位置） */
.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;
}

/* bottom-left 位置时气泡移到按钮右侧 */
.faq-widget-toggle.faq-widget-pos-bottom-left::before {
	right: auto;
	left: calc(100% + 14px);
}

@keyframes faq-bubble {
	0%, 100% { transform: translateY(-50%); }
	50% { transform: translateY(calc(-50% - 5px)); }
}

.faq-widget-toggle:hover {
	transform: scale(1.08);
}

.faq-widget-toggle:hover::before {
	animation-play-state: paused;
}

.faq-widget-toggle svg {
	width: 30px;
	height: 30px;
	fill: #fff;
	position: relative;
	z-index: 1;
}

.faq-widget-toggle.active {
	transform: scale(0);
	opacity: 0;
	pointer-events: none;
}

/* 对话框容器 */
.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-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-widget-container.active {
	opacity: 1;
	transform: scale(1) translateY(0);
	pointer-events: auto;
}

/* 标题栏 */
.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-widget-header-title {
	font-size: 16px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
}

.faq-widget-header-title svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* 头部按钮组 */
.faq-widget-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.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-widget-clear:hover,
.faq-widget-close:hover {
	opacity: 1;
}

.faq-widget-clear svg,
.faq-widget-close svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* 内容区域 */
.faq-widget-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	scroll-behavior: smooth;
}

.faq-widget-body::-webkit-scrollbar {
	width: 4px;
}

.faq-widget-body::-webkit-scrollbar-thumb {
	background: #ddd;
	border-radius: 2px;
}

/* 常见问题小标题 */
.faq-widget-faq-tip {
	font-size: 12px;
	color: #b5bec2;
	margin: 14px 0 8px;
	padding-left: 4px;
}

/* 快捷问题卡片 */
.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-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-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-widget-question-item .faq-question-text {
	flex: 1;
}

.faq-widget-question-item .faq-question-views {
	font-size: 11px;
	color: #bbb;
	flex-shrink: 0;
	margin-top: 2px;
}

/* 聊天气泡 */
.faq-widget-message {
	display: flex;
	margin-bottom: 14px;
	align-items: flex-end;
}

.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-widget-message-bot {
	justify-content: flex-start;
}

/* 客服头像 */
.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-widget-avatar svg {
	width: 20px;
	height: 20px;
	fill: #fff;
}

/* 消息内容区 */
.faq-widget-content {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 78%;
}

/* 用户消息内容区 */
.faq-widget-user-content {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	max-width: 78%;
}

/* 昵称 + 时间行 */
.faq-widget-meta {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 4px 4px;
}

.faq-widget-nickname {
	font-size: 11px;
	color: #b5bec2;
}

.faq-widget-time {
	font-size: 10px;
	color: #c4c9cc;
}

.faq-widget-time-user {
	margin: 0 4px 4px 0;
	text-align: right;
}

.faq-widget-message-bot .faq-widget-bubble {
	background: #f7f8fa;
	color: #333;
	border-radius: 16px 16px 16px 4px;
}

.faq-widget-bubble {
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.6;
	word-break: break-word;
}

/* 答案过渡语 */
.faq-widget-answer-lead {
	font-size: 13px;
	color: var(--faq-primary, #667eea);
	font-weight: 500;
	margin-bottom: 8px;
}

/* 转人工操作按钮 */
.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-widget-fallback-note {
	margin-top: 10px;
	font-size: 12px;
	color: #b5bec2;
}

/* 富文本答案内容样式 */
.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-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-widget-source a:hover {
	text-decoration: underline;
}

/* 关联问题标题 */
.faq-widget-related-title {
	font-size: 12px;
	color: #999;
	margin: 10px 0 6px;
	padding-left: 4px;
}

/* 关联问题标签 */
.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-widget-related-tag:hover {
	background: var(--faq-primary, #667eea);
	color: #fff;
}

/* 底部输入区域 */
.faq-widget-footer {
	padding: 12px 16px;
	border-top: 1px solid #f0f0f0;
	flex-shrink: 0;
	display: flex;
	gap: 8px;
}

.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-widget-footer input:focus {
	border-color: var(--faq-primary, #667eea);
}

.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-widget-footer button:hover {
	opacity: 0.9;
	transform: scale(1.05);
}

.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-widget-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 15px 16px;
}

.faq-widget-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #c4c9cc;
	animation: faq-typing-dot 1.2s infinite ease-in-out;
}

.faq-widget-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.faq-widget-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes faq-typing-dot {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

/* 空状态 */
.faq-widget-empty {
	text-align: center;
	padding: 24px;
	color: #ccc;
	font-size: 13px;
}

/* 响应式适配 */
@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;
	}
}
