/* Top Enzymes — AI Chat
 * Uses brand vars from topenzyme-brand plugin where available.
 */

#te-ai-root {
	--te-ai-bg:     var(--te-bg, #faf8f3);
	--te-ai-card:   var(--te-card, #ffffff);
	--te-ai-text:   var(--te-text, #1c1f1d);
	--te-ai-muted:  var(--te-muted, #5a625e);
	--te-ai-accent: var(--te-accent, #2f5b3a);
	--te-ai-border: var(--te-border, #e6e2d8);

	position: fixed;
	bottom: 1.5rem;
	right: 1.5rem;
	z-index: 99999;
	font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}

.te-ai-launcher {
	display: inline-flex;
	align-items: center;
	gap: .5rem;
	background: var(--te-ai-accent);
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: .85rem 1.4rem;
	font-size: .95rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0,0,0,.18);
	transition: transform .15s ease, box-shadow .15s ease;
	font-family: inherit;
}

.te-ai-launcher:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 26px rgba(0,0,0,.22);
}

.te-ai-open .te-ai-launcher { display: none; }

.te-ai-panel {
	width: 360px;
	max-width: calc(100vw - 2rem);
	height: 540px;
	max-height: calc(100vh - 3rem);
	background: var(--te-ai-card);
	border: 1px solid var(--te-ai-border);
	border-radius: 18px;
	box-shadow: 0 20px 50px rgba(0,0,0,.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	color: var(--te-ai-text);
}

.te-ai-header {
	background: var(--te-ai-accent);
	color: #fff;
	padding: 1rem 1.2rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.te-ai-header__title { font-weight: 700; font-size: 1rem; }
.te-ai-header__sub   { font-size: .8rem; opacity: .85; margin-top: .15rem; }

.te-ai-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 1.6rem;
	cursor: pointer;
	line-height: 1;
	padding: 0 .35em;
	font-family: inherit;
}

.te-ai-messages {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	background: var(--te-ai-bg);
	display: flex;
	flex-direction: column;
	gap: .65rem;
}

.te-ai-msg__body {
	max-width: 85%;
	padding: .65rem .85rem;
	border-radius: 14px;
	font-size: .92rem;
	line-height: 1.45;
	word-wrap: break-word;
}

.te-ai-msg--user {
	align-items: flex-end;
	display: flex;
	flex-direction: column;
}

.te-ai-msg--user .te-ai-msg__body {
	background: var(--te-ai-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.te-ai-msg--assistant .te-ai-msg__body {
	background: var(--te-ai-card);
	color: var(--te-ai-text);
	border: 1px solid var(--te-ai-border);
	border-bottom-left-radius: 4px;
}

.te-ai-msg__body a {
	color: inherit;
	text-decoration: underline;
	word-break: break-all;
}

.te-ai-msg--user .te-ai-msg__body a { color: #fff; }

/* Typing dots */
.te-ai-msg--typing .te-ai-msg__body {
	display: inline-flex;
	gap: 4px;
	padding: .85rem 1rem;
}
.te-ai-msg--typing span {
	width: 7px; height: 7px;
	border-radius: 50%;
	background: var(--te-ai-muted);
	animation: te-ai-bounce 1.2s infinite ease-in-out;
}
.te-ai-msg--typing span:nth-child(2) { animation-delay: .15s; }
.te-ai-msg--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes te-ai-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

.te-ai-form {
	display: flex;
	gap: .5rem;
	padding: .75rem;
	background: var(--te-ai-card);
	border-top: 1px solid var(--te-ai-border);
}

.te-ai-input {
	flex: 1;
	border: 1px solid var(--te-ai-border);
	border-radius: 999px;
	padding: .65rem 1rem;
	font-size: .92rem;
	background: var(--te-ai-bg);
	color: var(--te-ai-text);
	font-family: inherit;
}

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

.te-ai-send {
	background: var(--te-ai-accent);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 40px; height: 40px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.te-ai-send:hover { filter: brightness(1.08); }

.te-ai-footer {
	font-size: .72rem;
	color: var(--te-ai-muted);
	text-align: center;
	padding: .4rem;
	background: var(--te-ai-card);
	border-top: 1px solid var(--te-ai-border);
}

.te-ai-footer a { color: var(--te-ai-accent); }

@media (max-width: 480px) {
	#te-ai-root { bottom: 1rem; right: 1rem; }
	.te-ai-panel { width: calc(100vw - 2rem); height: calc(100vh - 6rem); }
}
