/**
 * 页脚聊天抽屉：内嵌系统 im/chat 的 iframe Shell（阶段 A + D）
 */
.mdc-chat-drawer__content {
	position: relative;
	/* 移动端底部安全区，避免 iframe 贴底被 Home 条遮挡 */
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mdc-chat-drawer__system-shell {
	display: none;
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	z-index: 3;
	background: var(--md-sys-color-surface, #fff);
	flex-direction: column;
	min-height: 0;
	max-height: 100%;
	/* 键盘弹出时部分浏览器可用动态视口 */
	max-height: 100dvh;
}

.mdc-chat-drawer__system-shell.is-active {
	display: flex;
}

/* 加载 / 错误遮罩 */
.mdc-chat-drawer__system-shell-overlay {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	box-sizing: border-box;
	padding: 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
	background: var(--md-sys-color-surface, #fff);
	color: var(--md-sys-color-on-surface, rgba(0, 0, 0, 0.87));
	text-align: center;
}

.mdc-chat-drawer__system-shell-overlay[hidden] {
	display: none !important;
}

.mdc-chat-drawer__system-shell-panel {
	max-width: 320px;
}

.mdc-chat-drawer__system-shell-spinner {
	width: 36px;
	height: 36px;
	margin: 0 auto 12px;
	border: 3px solid rgba(0, 0, 0, 0.08);
	border-top-color: var(--md-sys-color-primary, #1976d2);
	border-radius: 50%;
	animation: sanxio-im-shell-spin 0.75s linear infinite;
}

@media (prefers-color-scheme: dark) {
	.mdc-chat-drawer__system-shell-spinner {
		border-color: rgba(255, 255, 255, 0.12);
		border-top-color: var(--md-sys-color-primary, #90caf9);
	}
}

@keyframes sanxio-im-shell-spin {
	to {
		transform: rotate(360deg);
	}
}

.mdc-chat-drawer__system-shell-hint,
.mdc-chat-drawer__system-shell-msg {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
}

.mdc-chat-drawer__system-shell-hint {
	color: var(--md-sys-color-on-surface-variant, rgba(0, 0, 0, 0.6));
}

.mdc-chat-drawer__system-shell-actions {
	margin: 16px 0 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 12px;
}

.mdc-chat-drawer__system-shell-link {
	color: var(--md-sys-color-primary, #1976d2);
	text-decoration: underline;
	font-size: 14px;
}

.mdc-chat-drawer__system-shell-retry {
	appearance: none;
	cursor: pointer;
	font-size: 14px;
	padding: 8px 16px;
	border-radius: 20px;
	border: 1px solid var(--md-sys-color-outline, rgba(0, 0, 0, 0.38));
	background: var(--md-sys-color-surface, #fff);
	color: var(--md-sys-color-primary, #1976d2);
}

.mdc-chat-drawer__system-shell-retry:active {
	opacity: 0.85;
}

.mdc-chat-drawer__system-iframe {
	flex: 1 1 auto;
	width: 100%;
	min-height: 0;
	border: 0;
	background: var(--md-sys-color-surface, #fff);
}

.mdc-chat-drawer__header-start {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	min-width: 0;
}

/* 抽屉打开时，全站 Dmsgs 需盖在抽屉之上（抽屉 z-index: 1001） */
body:has(.mdc-chat-drawer--open) #msgs.mdc-footer-message {
	z-index: 1200 !important;
}

/* 抽屉场景下错误提示：红底白字，与未读角标一致 */
body:has(.mdc-chat-drawer--open) #msgs.mdc-footer-message.error {
	background: var(--md-sys-color-error, #b3261e) !important;
	color: #fff !important;
	border: 1px solid rgba(255, 255, 255, 0.35) !important;
}

body:has(.mdc-chat-drawer--open) #msgs.mdc-footer-message.error .mdc-footer-message__close:hover {
	background: rgba(255, 255, 255, 0.12) !important;
}

/* embed 模式：仅保留聊天抽屉本体，隐藏页面其它元素，避免会员中心 iframe 显示首页背景 */
body.sanxio-chat-embed-mode > *:not(#chatDrawer):not(#chatDrawerScrim) {
	display: none !important;
}
body.sanxio-chat-embed-mode #chatDrawer {
	left: 0 !important;
	right: 0 !important;
	top: 0 !important;
	bottom: 0 !important;
	width: 100% !important;
	max-width: none !important;
	border-radius: 0 !important;
}
