/* CSChat - 前台样式 */

#cschat {
	position: fixed;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.4;
}

/* 位置修饰类（必须用 class 选择器，PHP 输出的是 class 不是 id） */
.cschat--bottom-right { right: var(--cschat-margin, 20px); bottom: var(--cschat-margin, 20px); }
.cschat--bottom-left  { left:  var(--cschat-margin, 20px); bottom: var(--cschat-margin, 20px); align-items: flex-start; }

/* 右中 / 左中：贴边垂直居中。
   弹窗 / 表单 / 客服面板改为绝对定位挂在按钮上方，否则它们弹出后会把容器撑高，
   而容器用 translateY(-50%) 居中，会导致按钮跟着往下跳。 */
.cschat--middle-right {
	right: var(--cschat-margin, 20px);
	top: 50%;
	transform: translateY(-50%);
}
.cschat--middle-left {
	left: var(--cschat-margin, 20px);
	top: 50%;
	transform: translateY(-50%);
	align-items: flex-start;
}
.cschat--middle-right .cschat__greetings,
.cschat--middle-right .cschat__form,
.cschat--middle-right .cschat__agents,
.cschat--middle-left .cschat__greetings,
.cschat--middle-left .cschat__form,
.cschat--middle-left .cschat__agents {
	position: absolute;
	/* 12px 与容器 flex gap 保持一致，视觉上等同"贴在按钮上方" */
	bottom: calc(var(--cschat-size, 58px) + 12px);
	/* 矮屏（如手机横屏）时限制高度并允许滚动，避免弹窗被顶出视口 */
	max-height: calc(50vh - var(--cschat-size, 58px) * 0.5 - 28px);
	overflow-y: auto;
}
.cschat--middle-right .cschat__greetings,
.cschat--middle-right .cschat__form,
.cschat--middle-right .cschat__agents { right: 0; }
.cschat--middle-left .cschat__greetings,
.cschat--middle-left .cschat__form,
.cschat--middle-left .cschat__agents { left: 0; }

/* 部分主题会给 div 设 display，这里保证 hidden 属性始终生效 */
#cschat [hidden] { display: none !important; }

/* 浮动按钮 */
.cschat__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	border: none;
	cursor: pointer;
	background: var(--cschat-color, #25D366);
	color: var(--cschat-text, #fff);
	font-size: 15px;
	font-weight: 600;
	height: var(--cschat-size, 58px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
	transition: transform .15s ease, box-shadow .15s ease;
}

/* 圆形图标按钮（勾选「圆形图标按钮」）：等宽等高的正圆，只显示图标 */
.cschat--round .cschat__btn {
	width: var(--cschat-size, 58px);
	min-width: var(--cschat-size, 58px);
	padding: 0;
	border-radius: 50%;
}
.cschat--round .cschat__btn-text { display: none !important; }
.cschat--round .cschat__btn-icon { width: 50%; height: 50%; }

/* 胶囊长条按钮（未勾选）：图标 + 文字 */
.cschat:not(.cschat--round) .cschat__btn {
	padding: 0 22px 0 16px;
	border-radius: 999px;
}

.cschat__btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); }

.cschat__btn-icon {
	display: inline-flex;
	width: 26px;
	height: 26px;
	flex: 0 0 auto;
	color: var(--cschat-text, #fff);
}
.cschat__btn-icon svg { display: block; width: 100%; height: 100%; }

/* 通用卡片（弹窗 / 表单） */
.cschat__greetings,
.cschat__form {
	position: relative;
	width: 300px;
	max-width: calc(100vw - 40px);
	background: #fff;
	color: #1a1a1a;
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
	padding: 18px;
	animation: cschat-pop .2s ease;
}
@keyframes cschat-pop {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

.cschat__close {
	position: absolute;
	top: 8px;
	right: 10px;
	border: none;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: #999;
	cursor: pointer;
	padding: 0;
}
.cschat__close:hover { color: #555; }

/* 欢迎弹窗 */
.cschat__greetings-head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 10px;
}
.cschat__avatar {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--cschat-color, #25D366);
	display: inline-flex;
	overflow: hidden;
}
.cschat__avatar--svg { color: #fff; padding: 8px; box-sizing: border-box; }
.cschat__g-title { font-weight: 700; font-size: 15px; }
.cschat__g-sub { font-size: 12px; color: #777; }
.cschat__g-text { font-size: 14px; color: #444; margin-bottom: 14px; }
.cschat__cta {
	width: 100%;
	border: none;
	cursor: pointer;
	background: var(--cschat-color, #25D366);
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	padding: 11px;
	border-radius: 8px;
}
.cschat__cta:hover { filter: brightness(0.95); }

/* 线索表单 */
.cschat__form-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.cschat__form form { display: flex; flex-direction: column; gap: 8px; }
.cschat__form input,
.cschat__form textarea {
	width: 100%;
	border: 1px solid #ddd;
	border-radius: 8px;
	padding: 9px 11px;
	font-size: 14px;
	font-family: inherit;
	box-sizing: border-box;
}
.cschat__form input:focus,
.cschat__form textarea:focus { outline: none; border-color: var(--cschat-color, #25D366); }
.cschat__form textarea { resize: vertical; }
.cschat__submit {
	border: none;
	cursor: pointer;
	background: var(--cschat-color, #25D366);
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	padding: 11px;
	border-radius: 8px;
}
.cschat__submit:hover { filter: brightness(0.95); }
.cschat__submit[disabled] { opacity: .6; cursor: default; }
.cschat__error {
	color: #c0392b;
	font-size: 13px;
}

/* 多客服选择面板 */
.cschat__agents {
	position: relative;
	width: 300px;
	max-width: calc(100vw - 40px);
	background: #fff;
	color: #1a1a1a;
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
	padding: 18px;
	animation: cschat-pop .2s ease;
}
.cschat__agents-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.cschat__agent {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	border: 1px solid #eee;
	background: #fafafa;
	cursor: pointer;
	border-radius: 10px;
	padding: 10px 12px;
	margin-bottom: 8px;
	text-align: left;
	font-size: 14px;
	color: #1a1a1a;
	font-family: inherit;
}
.cschat__agent:last-child { margin-bottom: 0; }
.cschat__agent:hover { border-color: var(--cschat-color, #25D366); background: #fff; }
.cschat__agent-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--cschat-color, #25D366);
	display: inline-flex;
	overflow: hidden;
	flex: 0 0 auto;
}
.cschat__agent-name { font-weight: 600; }

/* 状态条（营业时间） */
.cschat__status {
	font-size: 13px;
	padding: 8px 12px;
	border-radius: 8px;
	margin-bottom: 12px;
}
.cschat__status--offline {
	background: #fff4e5;
	color: #8a5a00;
	border: 1px solid #ffd8a8;
}
