/**
 * CodeForge 全局 AI 悬浮助手样式。
 * 独立于工作台样式，挂在整站前台。
 */

.cff-wrap {
	--cff-accent: #4f7cff;
	position: fixed;
	inset: 0;
	z-index: 999999;
	pointer-events: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 悬浮球 ---------- */

.cff-ball {
	pointer-events: auto;
	position: fixed;
	width: 56px;
	height: 56px;
	right: 24px;
	bottom: 24px;
	border-radius: 50%;
	cursor: pointer;
	user-select: none;
	display: grid;
	place-items: center;
	background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .35), transparent 40%),
		linear-gradient(135deg, var(--cff-accent), #7b5cff 60%, #22d3ee);
	box-shadow:
		0 0 0 1px rgba(255, 255, 255, .22),
		0 8px 30px rgba(79, 124, 255, .45),
		0 0 24px rgba(34, 211, 238, .25);
	transition: transform .18s ease, box-shadow .18s ease;
}

.cff-ball:hover {
	transform: scale(1.08);
	box-shadow:
		0 0 0 1px rgba(255, 255, 255, .3),
		0 10px 36px rgba(79, 124, 255, .6),
		0 0 34px rgba(34, 211, 238, .35);
}

.cff-ball:active {
	transform: scale(1.02);
}

.cff-ball-core {
	font-size: 24px;
	color: #fff;
	text-shadow: 0 0 12px rgba(255, 255, 255, .8);
	line-height: 1;
}

.cff-ball.is-open .cff-ball-core {
	animation: cff-spin 2.4s linear infinite;
}

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

.cff-ball-tag {
	position: absolute;
	right: -2px;
	bottom: -2px;
	padding: 1px 6px;
	border-radius: 8px;
	font-size: 10px;
	font-weight: 700;
	color: #0b1020;
	background: linear-gradient(135deg, #67f7c4, #22d3ee);
	box-shadow: 0 2px 8px rgba(34, 211, 238, .5);
}

/* 呼吸光环 */
.cff-ball::before {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 1px solid rgba(79, 124, 255, .4);
	animation: cff-ring 2.8s ease-out infinite;
	pointer-events: none;
}

@keyframes cff-ring {
	0% { transform: scale(.9); opacity: .9; }
	100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- 迷你面板 ---------- */

.cff-panel {
	pointer-events: auto;
	position: fixed;
	width: min(380px, calc(100vw - 24px));
	height: min(520px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	border-radius: 16px;
	overflow: hidden;
	background: linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(246, 249, 254, .99));
	border: 1px solid rgba(79, 124, 255, .3);
	box-shadow:
		0 0 0 1px rgba(255, 255, 255, .04),
		0 20px 56px rgba(16, 24, 43, .18);
	color: #10182b;
	transform-origin: bottom right;
	animation: cff-in .2s ease;
}

@keyframes cff-in {
	from { opacity: 0; transform: translateY(10px) scale(.96); }
	to { opacity: 1; transform: none; }
}

/* 面板固定右下角，位于悬浮球上方 */
@media (min-width: 640px) {
	.cff-panel {
		right: 24px;
		bottom: 96px;
	}
}

@media (max-width: 639px) {
	.cff-panel {
		left: 12px;
		right: 12px;
		bottom: 92px;
		height: min(470px, calc(100vh - 120px));
	}
}

.cff-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	background: linear-gradient(90deg, rgba(47, 107, 255, .1), transparent);
	border-bottom: 1px solid rgba(47, 107, 255, .14);
}

.cff-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #0d9f6e;
	box-shadow: 0 0 8px rgba(13, 159, 110, .5);
}

.cff-head strong {
	font-size: 14px;
	flex: 1;
}

.cff-balance {
	font-size: 12px;
	color: #5a6b85;
}

.cff-close {
	appearance: none;
	border: 0;
	background: transparent;
	color: #5a6b85;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

.cff-close:hover { color: #10182b; }

/* ---------- 联系客服 ---------- */

.cff-service {
	appearance: none;
	border: 1px solid rgba(90, 107, 133, .3);
	background: rgba(47, 107, 255, .05);
	color: #40506b;
	font-size: 12px;
	line-height: 1;
	padding: 5px 9px;
	border-radius: 20px;
	cursor: pointer;
	white-space: nowrap;
	transition: all .15s ease;
}

.cff-service:hover,
.cff-service.is-on {
	border-color: transparent;
	background: linear-gradient(135deg, var(--cff-accent), #7b5cff);
	color: #fff;
}

.cff-service-card {
	position: absolute;
	top: 52px;
	left: 10px;
	right: 10px;
	z-index: 5;
	padding: 12px;
	border-radius: 12px;
	border: 1px solid rgba(79, 124, 255, .25);
	background: #fff;
	box-shadow: 0 14px 34px rgba(16, 24, 43, .18);
	animation: cff-in .16s ease;
}

.cff-service-hd {
	margin-bottom: 10px;
	font-size: 13px;
	font-weight: 600;
	color: #10182b;
}

.cff-service-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 10px;
	border: 1px solid rgba(16, 24, 43, .08);
	background: #f7f9ff;
}

.cff-service-row + .cff-service-row {
	margin-top: 8px;
}

.cff-service-ico {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	flex: none;
	border-radius: 8px;
	background: rgba(47, 107, 255, .1);
	font-size: 15px;
}

.cff-service-meta {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cff-service-meta b {
	font-size: 12px;
	font-weight: 600;
	color: #5a6b85;
}

.cff-service-meta em {
	font-style: normal;
	font-size: 13px;
	color: #10182b;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cff-service-open,
.cff-service-copy {
	flex: none;
	padding: 4px 9px;
	border-radius: 6px;
	font-size: 12px;
	line-height: 1.4;
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
	transition: all .15s ease;
}

.cff-service-open {
	border: 1px solid rgba(79, 124, 255, .4);
	color: var(--cff-accent);
	background: rgba(79, 124, 255, .06);
}

.cff-service-open:hover {
	background: rgba(79, 124, 255, .16);
}

.cff-service-copy {
	border: 1px solid rgba(90, 107, 133, .3);
	background: #fff;
	color: #40506b;
}

.cff-service-copy:hover {
	border-color: var(--cff-accent);
	color: var(--cff-accent);
}

.cff-service-copy:disabled {
	opacity: .65;
	cursor: default;
}

.cff-service-tip {
	margin: 9px 2px 0;
	font-size: 11px;
	line-height: 1.5;
	color: #8b9ab2;
}

.cff-modes {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 12px;
	border-bottom: 1px solid rgba(16, 24, 43, .06);
}

.cff-mode {
	appearance: none;
	border: 1px solid rgba(90, 107, 133, .3);
	background: rgba(47, 107, 255, .04);
	color: #40506b;
	font-size: 12px;
	padding: 4px 10px;
	border-radius: 20px;
	cursor: pointer;
	transition: all .15s ease;
}

.cff-mode i { font-style: normal; opacity: .7; font-size: 11px; }

.cff-mode:hover { border-color: var(--cff-accent); color: #fff; }

.cff-mode.is-on {
	background: linear-gradient(135deg, var(--cff-accent), #7b5cff);
	border-color: transparent;
	color: #fff;
}

.cff-msgs {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scrollbar-width: thin;
	scrollbar-color: rgba(143, 163, 200, .3) transparent;
}

.cff-hello {
	font-size: 13px;
	color: #5a6b85;
	line-height: 1.7;
	padding: 8px 10px;
	background: rgba(47, 107, 255, .05);
	border-radius: 10px;
}

.cff-msg {
	max-width: 88%;
	font-size: 13px;
	line-height: 1.65;
	word-break: break-word;
}

.cff-msg p { margin: 0 0 6px; }
.cff-msg p:last-child { margin-bottom: 0; }

.cff-msg.is-user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--cff-accent), #7b5cff);
	color: #fff;
	padding: 8px 12px;
	border-radius: 12px 12px 2px 12px;
}

.cff-msg.is-ai {
	align-self: flex-start;
	background: #f4f7fd;
	border: 1px solid rgba(16, 24, 43, .08);
	padding: 8px 12px;
	border-radius: 12px 12px 12px 2px;
}

.cff-msg a { color: #7fb0ff; }

.cff-inline {
	padding: 1px 5px;
	border-radius: 4px;
	background: rgba(47, 107, 255, .14);
	font-family: ui-monospace, "SF Mono", Consolas, monospace;
	font-size: 12px;
}

.cff-code {
	margin: 6px 0;
	padding: 10px;
	border-radius: 8px;
	background: #0e1526;
	border: 1px solid rgba(16, 24, 43, .1);
	overflow-x: auto;
}

.cff-code-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: -2px 0 8px;
	padding-bottom: 7px;
	border-bottom: 1px solid rgba(255, 255, 255, .08);
	font-family: inherit;
}

.cff-code-lang {
	margin-right: auto;
	font-size: 11px;
	letter-spacing: .02em;
	color: #8ea2c8;
}

.cff-apply,
.cff-run {
	padding: 3px 10px;
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, .16);
	background: rgba(255, 255, 255, .06);
	color: #dce7ff;
	font-size: 11px;
	line-height: 1.6;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease;
}

.cff-apply:hover {
	background: rgba(255, 255, 255, .14);
}

.cff-run {
	border-color: rgba(79, 124, 255, .55);
	background: rgba(79, 124, 255, .2);
	color: #fff;
}

.cff-run:hover {
	background: rgba(79, 124, 255, .34);
}

.cff-code code {
	font-family: ui-monospace, "SF Mono", Consolas, monospace;
	font-size: 12px;
	color: #7ee2b8;
	white-space: pre;
}

.cff-typing { display: inline-flex; gap: 4px; }

.cff-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #8fa3c8;
	animation: cff-blink 1.2s infinite;
}

.cff-typing i:nth-child(2) { animation-delay: .2s; }
.cff-typing i:nth-child(3) { animation-delay: .4s; }

@keyframes cff-blink {
	0%, 100% { opacity: .3; transform: translateY(0); }
	50% { opacity: 1; transform: translateY(-3px); }
}

.cff-foot {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(16, 24, 43, .08);
	background: rgba(255, 255, 255, .8);
}

.cff-input {
	flex: 1;
	resize: none;
	border: 1px solid rgba(143, 163, 200, .25);
	border-radius: 10px;
	background: rgba(255, 255, 255, .05);
	color: #10182b;
	font-size: 13px;
	font-family: inherit;
	padding: 8px 10px;
	line-height: 1.5;
}

.cff-input:focus {
	outline: none;
	border-color: var(--cff-accent);
}

.cff-input::placeholder { color: #93a3ba; }

.cff-send {
	appearance: none;
	border: 0;
	border-radius: 10px;
	padding: 0 16px;
	font-size: 13px;
	font-weight: 600;
	color: #fff;
	cursor: pointer;
	background: linear-gradient(135deg, var(--cff-accent), #7b5cff);
	transition: filter .15s ease;
}

.cff-send:hover { filter: brightness(1.15); }
.cff-send:disabled { filter: grayscale(.6); cursor: not-allowed; }

/* 用户开启减少动态时停用光环 */
@media (prefers-reduced-motion: reduce) {
	.cff-ball::before,
	.cff-ball.is-open .cff-ball-core,
	.cff-typing i {
		animation: none !important;
	}
}
