/* GH Site Assistant chat widget */
#ghsa-root {
	--ghsa-primary: #2563eb;
	--ghsa-on-primary: #fff;
	--ghsa-bg: #fff;
	--ghsa-text: #1f2937;
	--ghsa-bot-bg: #f1f5f9;
	--ghsa-radius: 16px;
	--ghsa-width: 380px;
	--ghsa-height: 560px;
	--ghsa-bubble: 60px;
	--ghsa-offset-x: 20px;
	--ghsa-offset-y: 20px;
	--ghsa-font: inherit;
	position: fixed;
	bottom: var(--ghsa-offset-y);
	z-index: 999999;
	font-family: var(--ghsa-font);
	font-size: 15px;
	line-height: 1.45;
	color: var(--ghsa-text);
}
#ghsa-root *, #ghsa-root *::before, #ghsa-root *::after { box-sizing: border-box; }
#ghsa-root.ghsa-pos-right { right: var(--ghsa-offset-x); }
#ghsa-root.ghsa-pos-left { left: var(--ghsa-offset-x); }
#ghsa-root button { font: inherit; cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; box-shadow: none; }
#ghsa-root svg { width: 100%; height: 100%; display: block; }

/* Launcher */
#ghsa-root .ghsa-launcher {
	position: relative;
	width: var(--ghsa-bubble);
	height: var(--ghsa-bubble);
	border-radius: 50%;
	border: 0;
	padding: 0;
	background: var(--ghsa-primary);
	color: var(--ghsa-on-primary);
	box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease, box-shadow .2s ease;
	overflow: hidden;
}
#ghsa-root.ghsa-pos-left .ghsa-launcher { margin-right: auto; }
#ghsa-root.ghsa-pos-right .ghsa-launcher { margin-left: auto; }
#ghsa-root .ghsa-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(0, 0, 0, .28); }
#ghsa-root .ghsa-launcher:focus-visible { outline: 3px solid var(--ghsa-primary); outline-offset: 3px; }
#ghsa-root .ghsa-launcher > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transition: opacity .2s, transform .2s; }
#ghsa-root .ghsa-launch-open svg { width: 46%; height: 46%; }
#ghsa-root .ghsa-launch-open img { width: 100%; height: 100%; object-fit: cover; }
#ghsa-root .ghsa-launch-close { opacity: 0; transform: rotate(-90deg); }
#ghsa-root .ghsa-launch-close svg { width: 40%; height: 40%; }
#ghsa-root.ghsa-open .ghsa-launch-open { opacity: 0; transform: rotate(90deg); }
#ghsa-root.ghsa-open .ghsa-launch-close { opacity: 1; transform: none; }

/* Proactive prompt */
#ghsa-root .ghsa-teaser {
	position: absolute;
	bottom: calc(var(--ghsa-bubble) + 12px);
	display: none;
	align-items: flex-start;
	gap: 4px;
	width: max-content;
	max-width: min(280px, calc(100vw - 2 * var(--ghsa-offset-x)));
	background: var(--ghsa-bg);
	color: var(--ghsa-text);
	border-radius: 14px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
	padding: 4px 4px 4px 0;
	animation: ghsa-pop .25s ease-out;
}
#ghsa-root.ghsa-pos-right .ghsa-teaser { right: 0; }
#ghsa-root.ghsa-pos-left .ghsa-teaser { left: 0; }
#ghsa-root.ghsa-teaser-on:not(.ghsa-open) .ghsa-teaser { display: flex; }
#ghsa-root .ghsa-teaser-text { background: none; border: 0; padding: 10px 4px 10px 14px; text-align: left; color: inherit; font-size: 14px; line-height: 1.4; }
#ghsa-root .ghsa-teaser-close { flex: none; width: 24px; height: 24px; padding: 5px; border: 0; background: none; color: inherit; opacity: .55; border-radius: 50%; }
#ghsa-root .ghsa-teaser-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* Panel */
#ghsa-root .ghsa-panel {
	position: absolute;
	bottom: calc(var(--ghsa-bubble) + 14px);
	width: var(--ghsa-width);
	height: var(--ghsa-height);
	max-width: calc(100vw - 2 * var(--ghsa-offset-x));
	max-height: calc(100vh - var(--ghsa-bubble) - var(--ghsa-offset-y) - 30px);
	background: var(--ghsa-bg);
	border-radius: var(--ghsa-radius);
	box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(.98);
	transform-origin: bottom right;
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
#ghsa-root.ghsa-pos-right .ghsa-panel { right: 0; }
#ghsa-root.ghsa-pos-left .ghsa-panel { left: 0; transform-origin: bottom left; }
#ghsa-root.ghsa-open .ghsa-panel { opacity: 1; visibility: visible; transform: none; transition: opacity .2s ease, transform .2s ease; }

#ghsa-root .ghsa-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 10px 12px 14px;
	background: var(--ghsa-primary);
	color: var(--ghsa-on-primary);
	flex: none;
}
#ghsa-root .ghsa-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
#ghsa-root .ghsa-avatar-icon { display: flex; padding: 7px; background: rgba(255, 255, 255, .18); }
#ghsa-root .ghsa-title { font-weight: 600; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ghsa-root .ghsa-icon-btn { width: 32px; height: 32px; padding: 7px; border: 0; border-radius: 8px; background: none; color: inherit; opacity: .85; flex: none; }
#ghsa-root .ghsa-icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, .16); }

#ghsa-root .ghsa-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
#ghsa-root .ghsa-msg { display: flex; flex-direction: column; max-width: 88%; }
#ghsa-root .ghsa-user { align-self: flex-end; align-items: flex-end; }
#ghsa-root .ghsa-bot { align-self: flex-start; }
#ghsa-root .ghsa-bubble { padding: 9px 13px; border-radius: 14px; word-wrap: break-word; overflow-wrap: anywhere; }
#ghsa-root .ghsa-user .ghsa-bubble { background: var(--ghsa-primary); color: var(--ghsa-on-primary); border-bottom-right-radius: 4px; white-space: pre-wrap; }
#ghsa-root .ghsa-bot .ghsa-bubble { background: var(--ghsa-bot-bg); color: var(--ghsa-text); border-bottom-left-radius: 4px; }
#ghsa-root .ghsa-bubble p { margin: 0 0 .5em; }
#ghsa-root .ghsa-bubble p:last-child { margin-bottom: 0; }
#ghsa-root .ghsa-bubble ul { margin: .2em 0 .5em; padding-left: 1.2em; }
#ghsa-root .ghsa-bubble li { margin: .15em 0; }
#ghsa-root .ghsa-bubble a { color: var(--ghsa-primary); text-decoration: underline; }
#ghsa-root .ghsa-cite a { display: inline-block; min-width: 1.4em; padding: 0 .3em; margin-left: 1px; border-radius: 6px; background: var(--ghsa-primary); color: var(--ghsa-on-primary); text-decoration: none; font-size: 10px; line-height: 1.5; text-align: center; font-weight: 600; }

#ghsa-root .ghsa-sources { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
#ghsa-root .ghsa-sources-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; opacity: .6; }
#ghsa-root .ghsa-source { display: flex; gap: 8px; align-items: flex-start; padding: 7px 9px; border: 1px solid rgba(0, 0, 0, .1); border-radius: 10px; text-decoration: none; color: inherit; background: var(--ghsa-bg); transition: border-color .15s; }
#ghsa-root .ghsa-source:hover { border-color: var(--ghsa-primary); }
#ghsa-root .ghsa-source-icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--ghsa-primary); }
#ghsa-root .ghsa-source-body { display: flex; flex-direction: column; min-width: 0; }
#ghsa-root .ghsa-source-title { font-size: 13px; font-weight: 600; color: var(--ghsa-primary); }
#ghsa-root .ghsa-source-meta { font-size: 12px; opacity: .7; }

#ghsa-root .ghsa-typing .ghsa-bubble { display: flex; gap: 4px; padding: 12px 14px; }
#ghsa-root .ghsa-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35; animation: ghsa-blink 1.2s infinite; }
#ghsa-root .ghsa-dot:nth-child(2) { animation-delay: .2s; }
#ghsa-root .ghsa-dot:nth-child(3) { animation-delay: .4s; }
#ghsa-root .ghsa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#ghsa-root .ghsa-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; flex: none; }
#ghsa-root .ghsa-chip { border: 1px solid var(--ghsa-primary); color: var(--ghsa-primary); background: var(--ghsa-bg); border-radius: 999px; padding: 5px 11px; font-size: 13px; line-height: 1.3; }
#ghsa-root .ghsa-chip:hover { background: var(--ghsa-primary); color: var(--ghsa-on-primary); }

#ghsa-root .ghsa-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(0, 0, 0, .08); flex: none; background: var(--ghsa-bg); margin: 0; }
#ghsa-root .ghsa-input { flex: 1; resize: none; border: 1px solid rgba(0, 0, 0, .15); border-radius: 12px; padding: 9px 12px; font: inherit; font-size: 15px; line-height: 1.35; color: var(--ghsa-text); background: var(--ghsa-bg); max-height: 120px; min-height: 40px; margin: 0; box-shadow: none; width: auto; }
#ghsa-root .ghsa-input:focus { outline: none; border-color: var(--ghsa-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ghsa-primary) 25%, transparent); }
#ghsa-root .ghsa-send { width: 40px; height: 40px; flex: none; border: 0; border-radius: 12px; padding: 10px; background: var(--ghsa-primary); color: var(--ghsa-on-primary); }
#ghsa-root.ghsa-busy .ghsa-send { opacity: .5; pointer-events: none; }

@keyframes ghsa-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .8; } }
@keyframes ghsa-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 600px) {
	#ghsa-root.ghsa-hide-mobile { display: none !important; }
	#ghsa-root.ghsa-mobile-full.ghsa-open .ghsa-panel {
		position: fixed;
		inset: 0;
		width: 100vw;
		height: 100%;
		max-width: none;
		max-height: none;
		border-radius: 0;
	}
	#ghsa-root.ghsa-mobile-full.ghsa-open .ghsa-launcher { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	#ghsa-root * { transition: none !important; animation: none !important; }
}

/* Admin live preview */
#ghsa-root.ghsa-preview { position: absolute; }
#ghsa-root.ghsa-preview .ghsa-panel { max-height: none; max-width: calc(470px - 2 * var(--ghsa-offset-x)); }
