/**
 * Xiuno Chatroom 前端样式（v1.1 · Modern Light · 降噪重写）
 * 设计 tokens 统一放在 .zybns-chatroom-wrap 上，用 CSS 变量集中管理配色/圆角/阴影
 * 风格：极简轻拟物 + 柔和阴影 + 紫蓝主色 + 消息气泡化
 */

/* ====== Design Tokens（可一键换肤） ====== */
.zybns-chatroom-wrap {
	--cr-bg:            #f4f6fb;   /* 页面整体背景：灰蓝浅底 */
	--cr-surface:       #ffffff;   /* 卡片/主区表面：纯白 */
	--cr-sidebar:       #f1f3f8;   /* 侧栏：更柔和的浅灰白 */
	--cr-border:        #e5e9f0;   /* 分割线：淡蓝灰 */
	--cr-border-soft:   #edf0f5;   /* 柔和分割线 */
	--cr-text:          #1f2937;   /* 主文字：深蓝灰 */
	--cr-text-sub:      #6b7280;   /* 次文字：中灰 */
	--cr-text-mute:     #9ca3af;   /* 弱化文字：浅灰 */
	--cr-primary:       #6366f1;   /* 主色：Indigo 500 */
	--cr-primary-600:   #4f46e5;   /* 主色 hover：Indigo 600 */
	--cr-primary-soft:  #eef2ff;   /* 主色浅底：选中/标签 */
	--cr-accent:        #f59e0b;   /* 强调色：暖黄（公告/默认标记） */
	--cr-danger:        #ef4444;   /* 警示色：红 */
	--cr-success:       #10b981;   /* 成功色：绿 */

	--cr-radius-sm:  8px;
	--cr-radius-md:  12px;
	--cr-radius-lg:  16px;
	--cr-radius-xl:  20px;
	--cr-radius-pill: 9999px;

	--cr-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
	--cr-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
	--cr-shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
	--cr-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

	/* 字号体系：12/13/14/15/16 */
	--cr-fs-xs: 12px;
	--cr-fs-sm: 13px;
	--cr-fs-md: 14px;
	--cr-fs-lg: 15px;
	--cr-fs-xl: 16px;
}

/* ====== 整体容器 ====== */
.zybns-chatroom-wrap {
	background: var(--cr-bg);
	border-radius: var(--cr-radius-lg);
	overflow: hidden;
	margin-bottom: 24px;
	box-shadow: var(--cr-shadow-sm);
	border: 1px solid var(--cr-border);
}
.zybns-chatroom-row {
	min-height: 60vh;
	background: var(--cr-bg);
}

/* ====== 左侧侧栏：频道列表（Modern · Pill 选中态） ====== */
.zybns-chatroom-sidebar {
	background: var(--cr-sidebar);
	color: var(--cr-text);
	display: flex;
	flex-direction: column;
	border-right: none;
}
.zybns-chatroom-sidebar-header {
	padding: 16px 18px 12px;
	border-bottom: 1px solid var(--cr-border-soft);
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: var(--cr-fs-lg);
	font-weight: 700;
	letter-spacing: 0.3px;
	color: var(--cr-text);
}
.zybns-chatroom-sidebar-title {
	color: var(--cr-text);
}
.zybns-chatroom-sidebar-title::before {
	content: '';
	display: inline-block;
	width: 6px; height: 6px;
	border-radius: 50%;
	background: var(--cr-success);
	margin-right: 8px;
	vertical-align: middle;
	box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

.zybns-chatroom-channel-list {
	flex: 1;
	overflow-y: auto;
	margin: 0;
	padding: 10px 10px 12px;
	max-height: calc(60vh - 80px);
}
.zybns-chatroom-empty-channel {
	color: var(--cr-text-mute);
	font-size: var(--cr-fs-xs);
	padding: 10px 14px !important;
	border-radius: var(--cr-radius-sm);
	background: transparent;
}

.zybns-chatroom-channel-item {
	position: relative;
	display: flex;
	align-items: center;
	margin: 2px 0;
	border-radius: var(--cr-radius-md);
	transition: background 0.15s ease;
}
.zybns-chatroom-channel-item:hover {
	background: #ffffff88;
}
.zybns-chatroom-channel-item:hover .zybns-chatroom-share-btn {
	opacity: 1;
}
.zybns-chatroom-channel-link {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	color: var(--cr-text-sub);
	font-size: var(--cr-fs-md);
	font-weight: 500;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	border-radius: var(--cr-radius-md);
	transition: background 0.15s ease, color 0.15s ease, padding 0.15s ease;
}
.zybns-chatroom-channel-link i {
	opacity: 0.75;
	font-size: 14px;
}
.zybns-chatroom-channel-link:hover {
	background: #fff;
	color: var(--cr-text);
	text-decoration: none;
	box-shadow: var(--cr-shadow-xs);
}
.zybns-chatroom-channel-item.active .zybns-chatroom-channel-link {
	background: var(--cr-surface);
	color: var(--cr-primary-600);
	font-weight: 600;
	box-shadow: var(--cr-shadow-xs);
}
.zybns-chatroom-channel-item.active .zybns-chatroom-channel-link::before {
	content: '';
	position: absolute;
	left: 0; top: 8px; bottom: 8px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: var(--cr-primary);
}
.zybns-chatroom-channel-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
	min-width: 0;
}
.zybns-chatroom-default-flag {
	color: var(--cr-accent);
	margin-left: 4px;
	font-weight: 700;
	font-size: 12px;
}
.zybns-chatroom-share-btn {
	opacity: 0;
	color: var(--cr-text-mute);
	font-size: 13px;
	padding: 6px 10px !important;
	flex-shrink: 0;
	border-radius: var(--cr-radius-sm);
	transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.zybns-chatroom-share-btn:hover {
	color: var(--cr-primary-600);
	background: var(--cr-primary-soft);
	text-decoration: none;
	opacity: 1 !important;
}

.zybns-chatroom-sidebar-footer {
	padding: 12px 14px;
	border-top: 1px solid var(--cr-border-soft);
	display: flex;
	align-items: center;
	gap: 10px;
	background: #eaedf5;
}
.zybns-chatroom-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	box-shadow: var(--cr-shadow-xs);
	border: 2px solid #fff;
}
.zybns-chatroom-username {
	color: var(--cr-text);
	font-size: var(--cr-fs-sm);
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 130px;
}

/* ====== 右侧主区 ====== */
.zybns-chatroom-main {
	display: flex;
	flex-direction: column;
	min-height: 60vh;
	background: var(--cr-surface);
	border-left: 1px solid var(--cr-border);
}
.zybns-chatroom-main-header {
	padding: 14px 20px;
	border-bottom: 1px solid var(--cr-border-soft);
	background: var(--cr-surface);
	display: flex;
	align-items: center;
	font-size: var(--cr-fs-lg);
	gap: 8px;
}
.zybns-chatroom-main-title {
	font-weight: 700;
	color: var(--cr-text);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.zybns-chatroom-main-title i {
	color: var(--cr-primary);
}
.zybns-chatroom-main-desc {
	margin-left: 2px;
	font-size: var(--cr-fs-sm);
	color: var(--cr-text-sub);
}
.zybns-chatroom-main-counter {
	font-size: var(--cr-fs-xs);
	color: var(--cr-text-mute);
	background: var(--cr-primary-soft);
	color: var(--cr-primary-600);
	padding: 3px 10px;
	border-radius: var(--cr-radius-pill);
	font-weight: 600;
}

/* ====== 全局公告（顶部横跨整页） ====== */
.zybns-chatroom-global-notice {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 16px 16px 0;
	padding: 14px 18px;
	background: linear-gradient(135deg, #4f46e5 0%, #8b5cf6 100%);
	color: #fff;
	font-size: var(--cr-fs-md);
	line-height: 1.6;
	border-radius: var(--cr-radius-md);
	box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
	border: 1px solid rgba(255,255,255,0.12);
}
.zybns-chatroom-global-notice > i:first-child {
	flex-shrink: 0;
	margin-top: 2px;
	color: #fde68a;
	font-size: 18px;
	background: rgba(255,255,255,0.12);
	width: 30px; height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
}
.zybns-chatroom-global-notice-body {
	flex: 1;
	min-width: 0;
	word-wrap: break-word;
	overflow-wrap: break-word;
	font-weight: 500;
}
.zybns-chatroom-global-notice-close {
	flex-shrink: 0;
	font-size: 22px;
	line-height: 1;
	padding: 0 6px;
	margin-top: -2px;
	color: #fff;
	opacity: 0.75;
	transition: opacity 0.15s, transform 0.15s;
	text-shadow: none;
}
.zybns-chatroom-global-notice-close:hover {
	opacity: 1;
	color: #fff;
	transform: scale(1.15);
}

/* ====== 消息列表 ====== */
/* 频道公告 */
.zybns-chatroom-announcement {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 12px 16px;
	padding: 12px 16px;
	background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
	border: 1px solid #fde68a;
	border-radius: var(--cr-radius-md);
	color: #92400e;
	font-size: var(--cr-fs-sm);
	line-height: 1.6;
	box-shadow: var(--cr-shadow-xs);
}
.zybns-chatroom-announcement > i:first-child {
	flex-shrink: 0;
	margin-top: 1px;
	color: #f59e0b;
	background: #fff;
	width: 26px; height: 26px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	box-shadow: var(--cr-shadow-xs);
}
.zybns-chatroom-announcement-body {
	flex: 1;
	min-width: 0;
	word-wrap: break-word;
	overflow-wrap: break-word;
	font-weight: 500;
}
.zybns-chatroom-announcement-close {
	flex-shrink: 0;
	font-size: 20px;
	line-height: 1;
	padding: 0 4px;
	margin-top: -2px;
	color: #b45309;
	opacity: 0.55;
	transition: opacity 0.15s;
}
.zybns-chatroom-announcement-close:hover {
	opacity: 1;
}

.zybns-chatroom-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px 20px 16px;
	background: var(--cr-surface);
	min-height: 320px;
	max-height: calc(60vh - 120px);
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.zybns-chatroom-empty {
	color: var(--cr-text-mute);
	padding: 40px 0;
	text-align: center;
	font-size: var(--cr-fs-sm);
}
.zybns-chatroom-empty::before {
	content: '💬';
	display: block;
	font-size: 32px;
	margin-bottom: 10px;
	opacity: 0.5;
}

.zybns-chatroom-msg {
	display: flex;
	gap: 12px;
	padding: 10px 10px;
	border-radius: var(--cr-radius-md);
	transition: background 0.12s;
	position: relative;
}
.zybns-chatroom-msg:hover {
	background: #f9fafb;
}
.zybns-chatroom-msg:hover .zybns-chatroom-msg-delete {
	opacity: 1;
}

/* 自己的消息：右侧紫色气泡 */
.zybns-chatroom-msg-self {
	flex-direction: row-reverse;
}
.zybns-chatroom-msg-self .zybns-chatroom-msg-body {
	text-align: right;
	align-items: flex-end;
}
.zybns-chatroom-msg-self .zybns-chatroom-msg-meta {
	justify-content: flex-end;
	flex-direction: row-reverse;
}
.zybns-chatroom-msg-self .zybns-chatroom-msg-content {
	margin-left: auto;
	background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
	color: #fff;
	border-radius: 18px 18px 4px 18px;
	box-shadow: 0 3px 10px rgba(99,102,241,0.28);
}
.zybns-chatroom-msg-self .zybns-chatroom-msg-content a {
	color: #fde68a;
	text-decoration: underline;
}

.zybns-chatroom-msg-avatar {
	flex-shrink: 0;
	width: 40px;
	height: 40px;
}
.zybns-chatroom-msg-avatar img {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	display: block;
	box-shadow: var(--cr-shadow-xs);
	border: 2px solid #fff;
}
.zybns-chatroom-msg-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	max-width: 80%;
}
.zybns-chatroom-msg-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}
.zybns-chatroom-msg-user {
	font-weight: 700;
	color: var(--cr-text);
	font-size: var(--cr-fs-sm);
	text-decoration: none;
}
.zybns-chatroom-msg-user:hover {
	color: var(--cr-primary-600);
	text-decoration: none;
}
.zybns-chatroom-msg-time {
	color: var(--cr-text-mute);
	font-size: var(--cr-fs-xs);
}
.zybns-chatroom-msg-delete {
	opacity: 0;
	padding: 3px 8px !important;
	font-size: 11px;
	transition: opacity 0.15s, background 0.15s;
	border-radius: var(--cr-radius-sm);
}
.zybns-chatroom-msg-delete:hover {
	background: #fef2f2;
	color: var(--cr-danger) !important;
}

/* 他人消息：浅灰气泡，左对齐 */
.zybns-chatroom-msg-content {
	color: var(--cr-text);
	font-size: var(--cr-fs-md);
	line-height: 1.6;
	word-wrap: break-word;
	overflow-wrap: break-word;
	display: inline-block;
	white-space: pre-wrap;
	padding: 10px 14px;
	background: #f3f4f6;
	border-radius: 6px 18px 18px 18px;
	max-width: 100%;
}
.zybns-chatroom-msg-content a {
	color: var(--cr-primary-600);
	text-decoration: none;
	font-weight: 600;
}
.zybns-chatroom-msg-content a:hover {
	text-decoration: underline;
}

/* ====== 分享卡片消息 ====== */
.zybns-chatroom-share-card {
	display: block;
	margin-top: 6px;
	padding: 14px 16px;
	border-radius: var(--cr-radius-md);
	background: #fff;
	border: 1px solid var(--cr-border);
	text-decoration: none;
	color: var(--cr-text);
	transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
	max-width: 380px;
	box-shadow: var(--cr-shadow-xs);
	overflow: hidden;
	position: relative;
}
.zybns-chatroom-share-card::before {
	content: '';
	position: absolute;
	left: 0; top: 0; bottom: 0;
	width: 4px;
	background: linear-gradient(180deg, #6366f1, #8b5cf6);
}
.zybns-chatroom-share-card:hover {
	transform: translateY(-1px);
	box-shadow: var(--cr-shadow-md);
	border-color: #c7d2fe;
	text-decoration: none;
	color: var(--cr-text);
}
.zybns-chatroom-share-card-name {
	font-weight: 700;
	font-size: var(--cr-fs-md);
	color: var(--cr-text);
}
.zybns-chatroom-share-card-name i {
	color: var(--cr-primary);
	margin-right: 4px;
}
.zybns-chatroom-share-card-desc {
	font-size: var(--cr-fs-xs);
	color: var(--cr-text-sub);
	margin: 5px 0 8px;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	line-height: 1.5;
}
.zybns-chatroom-share-card-action {
	font-size: var(--cr-fs-xs);
	color: var(--cr-primary-600);
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 4px;
}
.zybns-chatroom-share-card-action::after {
	content: '→';
	margin-left: 2px;
	transition: transform 0.15s;
}
.zybns-chatroom-share-card:hover .zybns-chatroom-share-card-action::after {
	transform: translateX(3px);
}

/* ====== 输入区（磨砂容器） ====== */
.zybns-chatroom-input-area {
	border-top: 1px solid var(--cr-border-soft);
	padding: 12px 20px 18px;
	background: linear-gradient(180deg, #fafbfe 0%, #f5f7fc 100%);
}
.zybns-chatroom-input-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
}
.zybns-chatroom-emoji-btn {
	font-size: 17px;
	padding: 8px 12px !important;
	border: 1px solid var(--cr-border);
	background: #fff;
	border-radius: var(--cr-radius-sm);
	transition: all 0.15s;
	box-shadow: var(--cr-shadow-xs);
	color: var(--cr-text-sub);
}
.zybns-chatroom-emoji-btn:hover {
	background: var(--cr-primary-soft);
	color: var(--cr-primary-600);
	border-color: #c7d2fe;
	box-shadow: var(--cr-shadow-sm);
	transform: translateY(-1px);
}
.zybns-chatroom-input-tip {
	flex: 1;
	color: var(--cr-text-mute);
	font-size: var(--cr-fs-xs);
}
.zybns-chatroom-input-form {
	display: flex;
	gap: 10px;
	align-items: flex-end;
}
.zybns-chatroom-input {
	flex: 1;
	resize: none;
	max-height: 140px;
	min-height: 44px;
	line-height: 1.6;
	font-size: var(--cr-fs-md);
	padding: 11px 14px;
	border-radius: var(--cr-radius-md);
	border: 1px solid var(--cr-border);
	background: #fff;
	box-shadow: 0 0 0 3px transparent;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.zybns-chatroom-input:focus {
	border-color: var(--cr-primary);
	box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
	outline: 0;
}
.zybns-chatroom-send-btn {
	flex-shrink: 0;
	min-width: 100px;
	height: 44px;
	border-radius: var(--cr-radius-md) !important;
	font-weight: 600;
	background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
	border: none !important;
	box-shadow: 0 4px 12px rgba(99,102,241,0.32);
	transition: all 0.15s;
}
.zybns-chatroom-send-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(99,102,241,0.40);
	filter: brightness(1.05);
}
.zybns-chatroom-send-btn:active {
	transform: translateY(0);
	box-shadow: 0 3px 10px rgba(99,102,241,0.30);
}
.zybns-chatroom-input-locked {
	border: 1px dashed var(--cr-border);
	border-radius: var(--cr-radius-md);
	background: #fff;
	padding: 10px 14px;
}

/* ====== Emoji Picker Popover（圆角 + 柔和阴影） ====== */
.zybns-chatroom-emoji-popover {
	position: absolute;
	z-index: 1050;
	width: 340px;
	max-width: 100%;
	background: #fff;
	border: 1px solid var(--cr-border);
	border-radius: var(--cr-radius-lg);
	box-shadow: var(--cr-shadow-lg);
	overflow: hidden;
}
.zybns-chatroom-emoji-tabs {
	display: flex;
	flex-wrap: wrap;
	border-bottom: 1px solid var(--cr-border-soft);
	background: #f9fafb;
	padding: 4px 6px 0;
	gap: 2px;
}
.zybns-chatroom-emoji-tab {
	background: none;
	border: 0;
	padding: 8px 10px;
	font-size: 18px;
	cursor: pointer;
	border-radius: var(--cr-radius-sm);
	transition: background 0.12s, transform 0.12s;
}
.zybns-chatroom-emoji-tab:hover {
	background: #eef2ff;
	transform: scale(1.15);
}
.zybns-chatroom-emoji-tab.active {
	background: #fff;
	color: var(--cr-primary);
	box-shadow: 0 -2px 0 var(--cr-primary) inset;
}
.zybns-chatroom-emoji-grid {
	max-height: 240px;
	overflow-y: auto;
	padding: 10px 8px;
	display: grid;
	grid-template-columns: repeat(9, 1fr);
	gap: 2px;
}
.zybns-chatroom-emoji-item {
	background: none;
	border: 0;
	width: 100%;
	aspect-ratio: 1 / 1;
	max-height: 36px;
	font-size: 20px;
	cursor: pointer;
	border-radius: var(--cr-radius-sm);
	transition: background 0.12s, transform 0.12s;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.zybns-chatroom-emoji-item:hover {
	background: var(--cr-primary-soft);
	transform: scale(1.25);
}

/* ====== 响应式：移动端 ====== */
@media (max-width: 767px) {
	.zybns-chatroom-wrap {
		border-radius: var(--cr-radius-md);
	}
	.zybns-chatroom-global-notice {
		margin: 12px 12px 0;
		padding: 12px 14px;
	}
	.zybns-chatroom-messages {
		padding: 14px 12px;
		gap: 2px;
		max-height: calc(70vh - 140px);
	}
	.zybns-chatroom-row {
		min-height: 70vh;
	}
	/* 移动端默认隐藏侧栏，点击按钮显示 */
	.zybns-chatroom-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		z-index: 1040;
		width: 260px;
		max-width: 82vw;
		transform: translateX(-100%);
		transition: transform 0.22s cubic-bezier(.4,0,.2,1);
		box-shadow: var(--cr-shadow-lg);
		border-radius: 0 var(--cr-radius-md) var(--cr-radius-md) 0;
	}
	.zybns-chatroom-sidebar.zybns-chatroom-sidebar-show {
		transform: translateX(0);
	}
	.zybns-chatroom-main {
		min-height: 70vh;
		border-left: none;
	}
	.zybns-chatroom-main-header {
		padding: 12px 14px;
	}
	.zybns-chatroom-input-area {
		padding: 10px 12px 14px;
	}
	.zybns-chatroom-input-tip {
		display: none;
	}
	.zybns-chatroom-emoji-popover {
		width: 280px;
		max-width: 92vw;
	}
	.zybns-chatroom-emoji-grid {
		grid-template-columns: repeat(8, 1fr);
	}
	.zybns-chatroom-share-card {
		max-width: 100%;
	}
	.zybns-chatroom-msg-body {
		max-width: 78%;
	}
}

/* 侧栏遮罩（移动端） */
@media (max-width: 767px) {
	body.zybns-chatroom-overlay::before {
		content: '';
		position: fixed;
		top: 0; left: 0; right: 0; bottom: 0;
		background: rgba(15, 23, 42, 0.45);
		backdrop-filter: blur(2px);
		z-index: 1035;
	}
}
