.aicg-widget {
	--aicg-color: #2563eb;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: var(--aicg-font-size, 14px);
	line-height: 1.45;
	box-sizing: border-box;
}
.aicg-widget * {
	box-sizing: border-box;
}

/* ---------- Floating widget ---------- */
.aicg-floating {
	position: fixed;
	bottom: var(--aicg-bubble-bottom, 24px);
	z-index: 999999;
}
.aicg-pos-right { right: 24px; }
.aicg-pos-left  { left: 24px; }

.aicg-bubble {
	width: var(--aicg-avatar-size, 60px);
	height: var(--aicg-avatar-size, 60px);
	border-radius: 50%;
	background: var(--aicg-color);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	overflow: hidden;
}
.aicg-bubble.aicg-has-avatar {
	background: transparent !important;
	box-shadow: none !important;
	padding: 0 !important;
	border-radius: 0 !important;
	overflow: visible !important;
}
.aicg-bubble.aicg-has-avatar img {
	border-radius: 0 !important;
	object-fit: contain !important;
}
/* When transparent bg is disabled in settings, restore the solid circle */
.aicg-bubble.aicg-has-avatar.aicg-solid-bg {
	background: #ffffff !important;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22) !important;
	border-radius: 50% !important;
	overflow: hidden !important;
}
.aicg-bubble.aicg-has-avatar.aicg-solid-bg img {
	border-radius: 50% !important;
	object-fit: cover !important;
}
.aicg-bubble img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}
.aicg-bubble:hover {
	transform: scale(1.06);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.aicg-bubble:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ---------- Teaser bubble (invites visitors to chat) ---------- */
.aicg-teaser {
	position: absolute;
	bottom: 16px;
	z-index: 2;       /* above .aicg-panel (z-index:auto) which is later in DOM order */
	max-width: min(230px, calc(100vw - 110px));
	background: #fff;
	color: #1f2329;
	padding: 10px 14px; /* Symmetric padding without overlap of the old close button */
	border-radius: 14px;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
	font-size: 14px;
	line-height: 1.35;
	cursor: pointer;
	/* Start invisible; JS adds .aicg-teaser-visible to reveal with animation */
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px) scale(0.92);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.aicg-pos-right .aicg-teaser { right: 76px; }
.aicg-pos-left  .aicg-teaser { left: 76px; }

/* Small speech-bubble tail pointing toward the launcher icon */
.aicg-teaser::after {
	content: "";
	position: absolute;
	bottom: 22px;
	width: 11px;
	height: 11px;
	background: #fff;
	transform: rotate(45deg);
}
.aicg-pos-right .aicg-teaser::after { right: -5px; }
.aicg-pos-left  .aicg-teaser::after { left: -5px; }

.aicg-teaser.aicg-teaser-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	animation: aicg-teaser-bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes aicg-teaser-bounce-in {
	0%   { opacity: 0; transform: translateY(18px) scale(0.85); }
	60%  { opacity: 1; transform: translateY(-4px) scale(1.04); }
	100% { opacity: 1; transform: translateY(0) scale(1); }
}

.aicg-floating .aicg-panel {
	position: absolute;
	bottom: calc(var(--aicg-avatar-size, 60px) + var(--aicg-bubble-gap, 16px));
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 480px;
	max-height: calc(100vh - 140px);
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}
.aicg-pos-right .aicg-panel { right: 0; }
.aicg-pos-left  .aicg-panel { left: 0; }

.aicg-floating.aicg-open .aicg-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}
.aicg-floating.aicg-open .aicg-bubble {
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

/* ---------- Inline (shortcode) widget ---------- */
.aicg-inline {
	max-width: 480px;
}
.aicg-inline .aicg-panel {
	position: relative;
	width: 100%;
	height: 520px;
}

/* ---------- Panel shell (shared) ---------- */
.aicg-panel {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 10px 36px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.aicg-header {
	background: var(--aicg-color);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.aicg-title {
	font-weight: 600;
	font-size: 16px;
}
.aicg-header-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	border: 1.5px solid rgba(255, 255, 255, 0.6);
}
.aicg-header.aicg-header-transparent-avatar .aicg-header-avatar {
	border-radius: 0;
	border: none;
	object-fit: contain;
}
.aicg-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 0 2px;
	opacity: 0.9;
}
.aicg-close:hover { opacity: 1; }

.aicg-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f7f7f9;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.aicg-msg {
	max-width: 85%;
}
/* Bot messages stack bubble + chips vertically */
.aicg-msg-bot {
	align-self: flex-start;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0;
}
/* User messages: simple single bubble */
.aicg-msg-user {
	align-self: flex-end;
	display: flex;
}

.aicg-bubble-text {
	padding: 9px 13px;
	border-radius: 14px;
	word-break: break-word;
	max-width: 100%;
}
/* Bot bubbles: no pre-wrap (we use <br> for newlines) */
.aicg-msg-bot .aicg-bubble-text {
	background: #fff;
	color: #1f2329;
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-bottom-left-radius: 4px;
	white-space: normal;
}
/* User bubbles: keep pre-wrap so typed newlines show */
.aicg-msg-user .aicg-bubble-text {
	background: var(--aicg-color);
	color: #fff;
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

/* Typing indicator */
.aicg-typing .aicg-bubble-text {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 12px 14px;
}
.aicg-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9aa0a6;
	display: inline-block;
	animation: aicg-bounce 1.2s infinite ease-in-out;
}
.aicg-typing span:nth-child(2) { animation-delay: 0.15s; }
.aicg-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aicg-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
	40% { transform: translateY(-4px); opacity: 1; }
}

.aicg-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	background: #fff;
	flex-shrink: 0;
}
.aicg-input {
	flex: 1;
	border: 1px solid rgba(0, 0, 0, 0.14);
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 14px;
	outline: none;
}
.aicg-input:focus-visible {
	border-color: var(--aicg-color);
}
.aicg-send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	background: var(--aicg-color);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.aicg-send:hover { filter: brightness(1.08); }
.aicg-send:disabled { opacity: 0.6; cursor: default; }

/* ---------- Markdown Elements (Headings, Lists, Links) ---------- */
.aicg-heading {
	color: var(--aicg-color);
	margin: 14px 0 6px 0;
	font-weight: 600;
	line-height: 1.3;
}
.aicg-heading:first-child {
	margin-top: 0;
}
.aicg-list {
	margin: 8px 0;
	padding-left: 20px;
}
.aicg-list-item {
	margin-bottom: 4px;
}
.aicg-ordered-list {
	list-style-type: decimal;
}
.aicg-bubble-text a {
	color: var(--aicg-color);
	text-decoration: underline;
	word-break: break-all;
}

/* ---------- AI Tools (Typing indicator, etc) ---------- */
/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	.aicg-floating .aicg-panel {
		position: fixed;
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		height: 85vh;
		max-height: 85vh;
		border-radius: 16px 16px 0 0;
	}
	.aicg-pos-left .aicg-panel,
	.aicg-pos-right .aicg-panel {
		left: 0;
		right: 0;
	}
	.aicg-floating .aicg-bubble {
		width: var(--aicg-avatar-size-mobile, 48px);
		height: var(--aicg-avatar-size-mobile, 48px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.aicg-bubble,
	.aicg-panel,
	.aicg-teaser,
	.aicg-typing span {
		transition: none !important;
		animation: none !important;
	}
}

/* ---------- Bot message HTML content ---------- */
.aicg-bubble-text strong { font-weight: 700; }
.aicg-bubble-text em { font-style: italic; }
.aicg-bubble-text a { color: var(--aicg-color); text-decoration: underline; }
.aicg-bubble-text code {
	background: rgba(0,0,0,0.07);
	border-radius: 4px;
	padding: 1px 5px;
	font-family: monospace;
	font-size: 0.9em;
}
.aicg-bubble-text ul,
.aicg-bubble-text ol {
	margin: 6px 0 6px 18px;
	padding: 0;
}
.aicg-bubble-text li { margin-bottom: 2px; }

/* ---------- Button chips ---------- */
.aicg-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
	width: 100%;
	box-sizing: border-box;
}
/* Equal width: each chip takes same share of the row */
.aicg-chip {
	flex: 1 1 auto;
	min-width: 60px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	border-radius: 16px;
	border: 1.5px solid var(--aicg-color);
	background: #fff;
	color: var(--aicg-color);
	font-family: inherit;
	font-weight: 500;
	cursor: pointer;
	white-space: normal;
	word-break: break-word;
	transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
	box-sizing: border-box;
}

/* Size variants */
.aicg-chip-small  { padding: 4px 10px; font-size: var(--aicg-btn-font-size, 12px) !important; letter-spacing: var(--aicg-btn-letter-spacing, 0px) !important; }
.aicg-chip-medium { padding: 6px 14px; font-size: var(--aicg-btn-font-size, 13px) !important; letter-spacing: var(--aicg-btn-letter-spacing, 0px) !important; }
.aicg-chip-large  { padding: 9px 18px; font-size: var(--aicg-btn-font-size, 14px) !important; letter-spacing: var(--aicg-btn-letter-spacing, 0px) !important; }

/* Fallback if no size class */
.aicg-chip:not(.aicg-chip-small):not(.aicg-chip-large) { padding: 6px 14px; font-size: var(--aicg-btn-font-size, 13px) !important; letter-spacing: var(--aicg-btn-letter-spacing, 0px) !important; }

.aicg-chip:hover:not(:disabled) {
	background: var(--aicg-color);
	color: #fff;
	border-color: var(--aicg-color);
	transform: translateY(-1px);
}
.aicg-chip:active:not(:disabled) {
	transform: scale(0.97);
}
.aicg-chip-selected {
	background: var(--aicg-color) !important;
	color: #fff !important;
	border-color: var(--aicg-color) !important;
	font-weight: 600;
}
.aicg-chip-used {
	opacity: 0.38;
	cursor: default;
	pointer-events: none;
}

