/**
 * Junnumunat Chatbot — front-end widget.
 *
 * Everything is scoped under .gz-chatbot-root and sets its own values rather
 * than inheriting, because the widget has to look the same in whatever theme
 * the site happens to run.
 */

.gz-chatbot-root {
	--gz-accent: #b3272d;
	--gz-surface: #ffffff;
	--gz-surface-alt: #f4f5f7;
	--gz-text: #1d2327;
	--gz-text-muted: #646970;
	--gz-border: #dcdfe4;
	--gz-radius: 16px;
	--gz-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--gz-text);
}

@media (prefers-color-scheme: dark) {
	.gz-chatbot-root {
		--gz-surface: #1e1f24;
		--gz-surface-alt: #2a2c33;
		--gz-text: #e8e8ea;
		--gz-text-muted: #a0a3ab;
		--gz-border: #3a3d45;
		--gz-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
	}
}

/* ------------------------------------------------------------- launcher */

.gz-chat__launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--gz-accent);
	color: #fff;
	box-shadow: var(--gz-shadow);
	cursor: pointer;
	transition: transform 160ms ease, filter 160ms ease;
}

.gz-chat__launcher:hover {
	transform: translateY(-2px);
	filter: brightness(1.08);
}

.gz-chat__launcher:focus-visible {
	outline: 3px solid var(--gz-accent);
	outline-offset: 3px;
}

.gz-chat__launcher svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.gz-chatbot-root.is-open .gz-chat__launcher {
	transform: scale(0.85);
	opacity: 0.75;
}

/* ---------------------------------------------------------------- panel */

.gz-chat__panel {
	display: flex;
	flex-direction: column;
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	overflow: hidden;
	border: 1px solid var(--gz-border);
	border-radius: var(--gz-radius);
	background: var(--gz-surface);
	box-shadow: var(--gz-shadow);
}

.gz-chat__panel[hidden] {
	display: none;
}

.gz-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex: 0 0 auto;
	padding: 14px 16px;
	background: var(--gz-accent);
	color: #fff;
}

.gz-chat__title {
	font-weight: 600;
	font-size: 15px;
}

.gz-chat__close {
	display: flex;
	padding: 4px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.85;
}

.gz-chat__close:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.15);
}

.gz-chat__close svg {
	width: 18px;
	height: 18px;
}

/* ------------------------------------------------------------- messages */

.gz-chat__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--gz-surface);
}

.gz-chat__msg {
	display: flex;
	flex-direction: column;
	max-width: 88%;
}

.gz-chat__msg--user {
	align-self: flex-end;
	align-items: flex-end;
}

.gz-chat__msg--assistant {
	align-self: flex-start;
}

.gz-chat__bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14.5px;
	word-break: break-word;
	overflow-wrap: anywhere;
}

.gz-chat__msg--user .gz-chat__bubble {
	background: var(--gz-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.gz-chat__msg--assistant .gz-chat__bubble {
	background: var(--gz-surface-alt);
	color: var(--gz-text);
	border-bottom-left-radius: 4px;
}

.gz-chat__p {
	margin: 0 0 8px;
}

.gz-chat__bubble > :last-child {
	margin-bottom: 0;
}

.gz-chat__list {
	margin: 0 0 8px;
	padding-left: 20px;
}

.gz-chat__list li {
	margin-bottom: 4px;
}

.gz-chat__bubble code {
	padding: 1px 5px;
	border-radius: 4px;
	background: rgba(127, 127, 127, 0.2);
	font-size: 0.92em;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.gz-chat__bubble a {
	color: inherit;
	text-decoration: underline;
}

.gz-chat__sources {
	margin-top: 5px;
	font-size: 12px;
	color: var(--gz-text-muted);
}

/* ------------------------------------------------------------- feedback */

.gz-chat__feedback {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 6px;
	font-size: 12px;
	color: var(--gz-text-muted);
}

.gz-chat__feedback-btn {
	padding: 2px 6px;
	border: 1px solid var(--gz-border);
	border-radius: 999px;
	background: transparent;
	font-size: 13px;
	line-height: 1.2;
	cursor: pointer;
}

.gz-chat__feedback-btn:hover {
	background: var(--gz-surface-alt);
}

/* ---------------------------------------------------------- typing, error */

.gz-chat__msg--typing .gz-chat__bubble {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--gz-text-muted);
	font-size: 13px;
}

.gz-chat__dots {
	display: inline-flex;
	gap: 3px;
}

.gz-chat__dots i {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: currentColor;
	animation: gz-bounce 1.2s infinite ease-in-out;
}

.gz-chat__dots i:nth-child(2) {
	animation-delay: 0.15s;
}

.gz-chat__dots i:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes gz-bounce {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
	.gz-chat__dots i,
	.gz-chat__launcher {
		animation: none;
		transition: none;
	}
}

.gz-chat__error {
	padding: 8px 12px;
	border-radius: 8px;
	background: rgba(214, 54, 56, 0.12);
	color: #a12b2d;
	font-size: 13px;
}

@media (prefers-color-scheme: dark) {
	.gz-chat__error {
		color: #ff9b9d;
	}
}

/* ---------------------------------------------------------------- input */

.gz-chat__disclaimer {
	flex: 0 0 auto;
	margin: 0;
	padding: 8px 16px 0;
	font-size: 11px;
	line-height: 1.35;
	color: var(--gz-text-muted);
}

.gz-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex: 0 0 auto;
	padding: 10px 12px 6px;
}

.gz-chat__input {
	flex: 1 1 auto;
	min-height: 40px;
	max-height: 120px;
	padding: 9px 12px;
	border: 1px solid var(--gz-border);
	border-radius: 20px;
	background: var(--gz-surface-alt);
	color: var(--gz-text);
	font: inherit;
	font-size: 14.5px;
	resize: none;
	overflow-y: auto;
}

.gz-chat__input:focus {
	outline: none;
	border-color: var(--gz-accent);
}

.gz-chat__send {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: var(--gz-accent);
	color: #fff;
	cursor: pointer;
}

.gz-chat__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.gz-chat__send svg {
	width: 19px;
	height: 19px;
	fill: currentColor;
}

.gz-chat__footer {
	flex: 0 0 auto;
	padding: 0 16px 10px;
}

.gz-chat__hint {
	font-size: 11px;
	color: var(--gz-text-muted);
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 480px) {
	.gz-chatbot-root {
		right: 14px;
		bottom: 14px;
	}

	.gz-chat__panel {
		position: fixed;
		right: 0;
		left: 0;
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 88vh;
		max-height: 88vh;
		border-radius: var(--gz-radius) var(--gz-radius) 0 0;
		border-left: 0;
		border-right: 0;
		border-bottom: 0;
	}
}

/* Standalone chat on mobile: its own document with no underlying site. */
.gz-chatbot-root *, .gz-chatbot-root *::before, .gz-chatbot-root *::after { box-sizing: border-box; }
.gz-chat__launcher { text-decoration: none; }
.gz-chat__log { min-height: 0; overscroll-behavior: contain; }
.gz-chat__input { min-width: 0; font-size: 16px; }
.gz-chat__close { align-items: center; min-height: 44px; min-width: 44px; justify-content: center; text-decoration: none; }
.gz-chat-page { margin: 0; overflow: hidden; }
.gz-chatbot-root--standalone {
 position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh;
}
.gz-chatbot-root--standalone .gz-chat__panel {
 position: absolute; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none;
 border: 0; border-radius: 0; box-shadow: none;
}
.gz-chatbot-root--standalone .gz-chat__header {
 padding-top: max(14px, env(safe-area-inset-top));
 padding-left: max(16px, env(safe-area-inset-left));
 padding-right: max(16px, env(safe-area-inset-right));
}
.gz-chatbot-root--standalone .gz-chat__close { font-size: 13px; }
.gz-chatbot-root--standalone .gz-chat__footer { display: none; }
.gz-chatbot-root--standalone .gz-chat__form {
 padding-bottom: max(12px, env(safe-area-inset-bottom));
 padding-left: max(12px, env(safe-area-inset-left));
 padding-right: max(12px, env(safe-area-inset-right));
}
.gz-chatbot-root--standalone .gz-chat__send { width: 44px; height: 44px; }
@media (max-width: 768px) {
 .gz-chatbot-root.is-open .gz-chat__launcher { display: none; }
 .gz-chat__hint { display: none; }
}

/* The little egg lives in the header, never over the message composer. */
.gz-chat__identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.gz-chat__identity .gz-chat__title { font-size: 14px; overflow-wrap: anywhere; }
.gz-chat__header { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.gz-chatbot-root--standalone .gz-chat__header { padding-top: max(8px, env(safe-area-inset-top)); }
.gz-egg { display: block; width: 48px; height: 54px; flex: 0 0 48px; color: #fff; }
.gz-egg svg { display: block; width: 100%; height: 100%; overflow: visible; }
.gz-egg__body { transform-origin: 36px 70px; }
.gz-egg__think, .gz-egg__talk, .gz-egg__thought, .gz-egg__zzz { display: none; }
.gz-egg[data-state="sleeping"] .gz-egg__body { animation: gz-egg-breathe 3s ease-in-out infinite; }
.gz-egg[data-state="sleeping"] .gz-egg__zzz { display: block; animation: gz-egg-dream 3s ease-in-out infinite; }
.gz-egg[data-state="thinking"] .gz-egg__sleep, .gz-egg[data-state="talking"] .gz-egg__sleep { display: none; }
.gz-egg[data-state="thinking"] .gz-egg__think, .gz-egg[data-state="thinking"] .gz-egg__thought { display: block; }
.gz-egg[data-state="thinking"] .gz-egg__body { animation: gz-egg-ponder 2.4s ease-in-out infinite; }
.gz-egg[data-state="thinking"] .gz-egg__thought { animation: gz-egg-dots 1.6s ease-in-out infinite; }
.gz-egg[data-state="talking"] .gz-egg__talk { display: block; }
.gz-egg__mouth { transform-box: fill-box; transform-origin: center; }
.gz-egg[data-state="talking"] .gz-egg__mouth { animation: gz-egg-speak .32s ease-in-out infinite alternate; }
@keyframes gz-egg-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.025, .965); } }
@keyframes gz-egg-dream { 0%, 100% { opacity: .3; transform: translateY(1px); } 65% { opacity: 1; transform: translateY(-4px); } }
@keyframes gz-egg-ponder { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(2deg); } }
@keyframes gz-egg-dots { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes gz-egg-speak { 0% { transform: scale(1, .25); } 55% { transform: scale(.85, 1); } 100% { transform: scale(1.1, .45); } }
@media (prefers-reduced-motion: reduce) {
 .gz-egg *, .gz-egg[data-state] * { animation: none !important; }
}
