/* ===========================================================
   Lyrargon AI Agent - 样式补全
   注：窗口定位/阴影由 JS 内联 !important 设置，这里补动画与内布局。
   =========================================================== */

/* ---- 窗口基础（带渐变动画：从左展开/向左收回） ---- */
.ai-agent-window {
	opacity: 1;
	transform: scale(1, 1);
	visibility: visible;
	overflow: hidden !important;
	border-radius: var(--card-radius, 12px) !important;
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
	transform-origin: left center;
}

/* ---- 关闭态（向左收回动画） ---- */
.ai-agent-window.ai-agent-closed {
	opacity: 0;
	transform: scale(0, 1);
	pointer-events: none;
	visibility: hidden;
}

/* ---- 最小化：只显示头部 ---- */
.ai-agent-window.ai-agent-minimized {
	max-height: 48px !important;
}
.ai-agent-window.ai-agent-minimized .ai-agent-messages,
.ai-agent-window.ai-agent-minimized .ai-agent-status,
.ai-agent-window.ai-agent-minimized .ai-agent-input-area {
	display: none;
}

/* ---- 浮动按钮 tooltip ---- */
#float_action_buttons #fabtn_ai_agent:before {
	content: attr(tooltip);
}

/* ---- 头部 ---- */
.ai-agent-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: var(--themecolor, #2196f3) !important;
	color: #fff;
	user-select: none;
}
.ai-agent-title {
	font-weight: 600;
	font-size: 14px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.ai-agent-header-actions {
	display: flex;
	gap: 4px;
}
.ai-agent-icon-btn {
	width: 26px;
	height: 26px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	background: rgba(255, 255, 255, 0.92) !important;
	color: var(--themecolor, #2196f3);
	border-radius: 6px;
	cursor: pointer;
	line-height: 1;
	font-size: 15px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, color 0.15s ease;
}
.ai-agent-icon-btn:hover {
	background: #fff !important;
	color: var(--themecolor-dark, #1976d2);
}
.ai-agent-icon-round {
	border-radius: 50%;
}

/* ---- 消息区 ---- */
.ai-agent-messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--color-background, #f5f7fa) !important;
}

.ai-message {
	display: flex;
	gap: 8px;
	max-width: 90%;
}
.ai-message-agent { align-self: flex-start; }
.ai-message-user { align-self: flex-end; flex-direction: row-reverse; }
.ai-message-error { align-self: center; max-width: 100%; }

.ai-message-avatar {
	flex: 0 0 28px; width: 28px; height: 28px;
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--themecolor, #2196f3);
	color: #fff; font-size: 13px;
}
.ai-message-user .ai-message-avatar { background: #9e9e9e; }

.ai-message-content {
	padding: 9px 13px;
	border-radius: 18px;
	background: var(--color-foreground, #fff) !important;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	font-size: 14px; line-height: 1.6;
	word-break: break-word;
}
.ai-message-user .ai-message-content {
	background: var(--themecolor, #2196f3) !important;
	color: #fff;
	border-bottom-right-radius: 6px;
}
.ai-message-agent .ai-message-content {
	background: var(--color-foreground, #fff) !important;
	border-bottom-left-radius: 6px;
}
.ai-message-error .ai-message-content {
	background: #fdecea !important;
	color: #c0392b;
}
/* 深色模式：错误消息 */
html.darkmode .ai-message-error .ai-message-content {
	background: #3d1a1a !important;
	color: #ff8a80;
}

.ai-message-content p { margin: 0 0 8px; }
.ai-message-content p:last-child { margin-bottom: 0; }
.ai-message-content pre {
	background: rgba(0, 0, 0, 0.06);
	padding: 8px 10px;
	border-radius: 6px; overflow-x: auto; font-size: 13px;
}
/* 深色模式：代码块 */
html.darkmode .ai-message-content pre {
	background: rgba(255, 255, 255, 0.08);
}
.ai-message-content code { font-family: monospace; }
.ai-message-content ul, .ai-message-content ol {
	margin: 4px 0; padding-left: 20px;
}

/* ---- 文章卡片 ---- */
.ai-article-card {
	display: block; margin-top: 6px;
	padding: 10px 12px; border-radius: 8px;
	background: rgba(33, 150, 243, 0.08);
	border: 1px solid rgba(33, 150, 243, 0.25);
	text-decoration: none; color: inherit;
}
/* 深色模式：文章卡片 */
html.darkmode .ai-article-card {
	background: rgba(33, 150, 243, 0.15);
	border-color: rgba(33, 150, 243, 0.35);
}
.ai-article-card-title {
	display: block; font-weight: 600;
	color: var(--themecolor, #2196f3);
}
.ai-article-card-excerpt {
	display: block; font-size: 12px; color: #888; margin: 2px 0;
}
.ai-article-card-url,
.ai-article-card-excerpt {
	display: block; font-size: 12px; color: #888; margin: 2px 0; word-break: break-all;
}
.ai-article-card-meta {
	display: block; font-size: 11px; color: #aaa;
}

/* ---- 外部链接富卡片（由异步预览渲染） ---- */
.ai-link-preview {
	display: flex; gap: 10px; margin-top: 6px;
	padding: 10px; border-radius: 8px;
	background: rgba(33, 150, 243, 0.08);
	border: 1px solid rgba(33, 150, 243, 0.25);
	cursor: pointer; color: inherit; text-decoration: none;
	transition: background 0.15s ease;
}
.ai-link-preview:hover {
	background: rgba(33, 150, 243, 0.14);
}
html.darkmode .ai-link-preview {
	background: rgba(33, 150, 243, 0.15);
	border-color: rgba(33, 150, 243, 0.35);
}
html.darkmode .ai-link-preview:hover {
	background: rgba(33, 150, 243, 0.22);
}

.ai-link-preview-img {
	flex: 0 0 80px; width: 80px; height: 80px;
	border-radius: 6px; overflow: hidden;
}
.ai-link-preview-img img {
	width: 100%; height: 100%; object-fit: cover; display: block;
}

.ai-link-preview-body {
	flex: 1; min-width: 0;
	display: flex; flex-direction: column; gap: 3px;
}
.ai-link-preview-title {
	font-weight: 600; font-size: 14px;
	color: var(--themecolor, #2196f3);
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
	overflow: hidden;
}
.ai-link-preview-desc {
	font-size: 12px; color: #888;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
	overflow: hidden;
}
.ai-link-preview-url {
	font-size: 11px; color: #aaa; word-break: break-all;
}

/* ---- 链接卡片底部容器 ---- */
.ai-link-previews {
	margin-top: 10px; padding-top: 8px;
	border-top: 1px solid rgba(0,0,0,0.06);
}
html.darkmode .ai-link-previews {
	border-top-color: rgba(255,255,255,0.08);
}
html.darkmode .ai-link-preview-url {
	color: #777;
}

/* ---- 打字指示器 ---- */
.ai-typing-indicator {
	display: flex; gap: 4px; align-items: center; padding: 4px 0;
}
.ai-typing-indicator span {
	width: 6px; height: 6px; border-radius: 50%;
	background: #bbb;
	animation: ai-typing 1s infinite ease-in-out;
}
/* 深色模式：打字点 */
html.darkmode .ai-typing-indicator span {
	background: #666;
}
.ai-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-typing {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- 状态栏 ---- */
.ai-agent-status {
	padding: 4px 14px;
	font-size: 12px; color: #888;
	background: var(--color-background, #f5f7fa) !important;
	border-top: 1px solid rgba(0, 0, 0, 0.05);
	border-radius: 0 0 12px 12px;
	margin: 0 6px 6px;
}
/* 深色模式：状态栏分割线 */
html.darkmode .ai-agent-status {
	border-top-color: rgba(255, 255, 255, 0.08);
}

/* ---- 输入区 ---- */
.ai-agent-input-area {
	display: flex; gap: 8px; padding: 10px;
	background: var(--color-foreground, #fff) !important;
}
.ai-agent-input {
	flex: 1; resize: none; border-radius: 8px;
	padding: 8px 10px; font-size: 14px;
	font-family: inherit; line-height: 1.4;
	max-height: 120px; outline: none;
}
.ai-agent-input:focus { border-color: var(--themecolor, #2196f3); }

.ai-agent-send {
	flex: 0 0 auto; width: 40px; height: 40px;
	border: none; border-radius: var(--card-radius, 12px);
	background: var(--themecolor, #2196f3);
	color: #fff; font-size: 16px;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background 0.15s ease;
}
.ai-agent-send:hover { background: var(--themecolor-dark, #1976d2); }

/* ---- 重试按钮 ---- */
.ai-retry-btn {
	display: inline-block; margin-left: 4px;
	color: var(--themecolor, #2196f3); cursor: pointer;
	font-weight: 600; text-decoration: underline;
	font-size: 13px;
}

/* ---- 隐私政策提示条 ---- */
.ai-agent-privacy {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 12px; margin: 4px 8px 4px;
	font-size: 12px; line-height: 1.4;
	color: #666;
	background: var(--color-background, #f5f7fa);
	border: 1px solid rgba(255, 152, 0, 0.3);
	border-radius: var(--card-radius, 8px);
}
html.darkmode .ai-agent-privacy {
	color: #aaa;
	background: rgba(255, 152, 0, 0.08);
	border-color: rgba(255, 152, 0, 0.2);
}
.ai-agent-privacy-text { flex: 1; }
.ai-agent-privacy-text a {
	color: var(--themecolor, #2196f3);
	white-space: nowrap;
}
.ai-agent-privacy-close {
	flex: 0 0 22px; width: 22px; height: 22px;
	border: none; border-radius: 50%;
	background: rgba(0,0,0,0.1); color: #888;
	cursor: pointer; font-size: 16px; line-height: 1;
	display: flex; align-items: center; justify-content: center;
}
.ai-agent-privacy-close:hover { background: rgba(0,0,0,0.2); color: #333; }


.ai-agent-send:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-agent-send.is-loading { background: var(--themecolor-dark, #1976d2); }
.ai-agent-send.is-loading i { display: inline-block; animation: ai-spin 0.8s linear infinite; }

@keyframes ai-spin {
	to { transform: rotate(360deg); }
}
