/* KJ Chatbot — premium widget */
.kjcb, .kjcb * { box-sizing: border-box; }
.kjcb {
	--kj-accent: #4175fc;
	--kj-accent-2: #084af3;
	--kj-ink: #101218;
	--kj-ink-2: #1d2230;
	--kj-text: #1f2430;
	--kj-muted: #6b7280;
	--kj-bg: #f5f7fb;
	--kj-card: #ffffff;
	--kj-line: #e6e9f0;
	--kj-radius: 22px;
	font-family: 'Open Sans', 'Vazirmatn', Tahoma, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	font-size: 14.5px;
	line-height: 1.55;
	color: var(--kj-text);
	-webkit-font-smoothing: antialiased;
}

/* neutralise theme button/input styles inside the widget */
.kjcb button {
	text-transform: none; letter-spacing: normal; line-height: 1.3; font-family: inherit;
	min-height: 0; margin: 0; text-shadow: none;
}
.kjcb button:focus { outline: none; }
.kjcb button:focus-visible { outline: 2px solid rgba(65, 117, 252, .7); outline-offset: 2px; }

/* ---------- launcher ---------- */
.kjcb-launcher {
	position: fixed; right: 24px; bottom: 24px; z-index: 99998;
	width: 62px; height: 62px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
	display: grid; place-items: center; color: #fff;
	background: radial-gradient(120% 120% at 30% 20%, #2a3350 0%, var(--kj-ink) 60%);
	box-shadow: 0 10px 30px rgba(16, 18, 24, .35), 0 0 0 1px rgba(255, 255, 255, .08) inset;
	transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s ease;
}
.kjcb-launcher:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 16px 40px rgba(16, 18, 24, .42), 0 0 0 1px rgba(255, 255, 255, .1) inset; }
.kjcb-launcher:focus-visible { outline: 3px solid rgba(65, 117, 252, .6); outline-offset: 3px; }
.kjcb-launcher::before {
	content: ''; position: absolute; inset: -4px; border-radius: 50%; z-index: -1;
	background: conic-gradient(from 180deg, var(--kj-accent), #7aa0ff, var(--kj-accent-2), var(--kj-accent));
	opacity: .55; filter: blur(8px); animation: kjcb-spin 6s linear infinite;
}
.kjcb-launcher svg { width: 28px; height: 28px; transition: transform .3s ease, opacity .2s ease; position: absolute; }
.kjcb-launcher .kjcb-i-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.kjcb.is-open .kjcb-launcher .kjcb-i-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.kjcb.is-open .kjcb-launcher .kjcb-i-close { opacity: 1; transform: none; }
.kjcb-launcher .kjcb-dot {
	position: absolute; top: 4px; right: 4px; width: 13px; height: 13px; border-radius: 50%;
	background: #22c55e; border: 2px solid var(--kj-ink);
}
.kjcb.is-open .kjcb-dot { display: none; }

.kjcb-hint {
	position: fixed; right: 96px; bottom: 36px; z-index: 99998;
	max-width: 230px; padding: 11px 16px; border-radius: 16px 16px 4px 16px;
	background: var(--kj-card); color: var(--kj-text); font-size: 13.5px; font-weight: 600;
	box-shadow: 0 12px 32px rgba(16, 18, 24, .18); border: 1px solid var(--kj-line);
	opacity: 0; transform: translateY(8px); pointer-events: none;
	transition: opacity .35s ease, transform .35s ease;
}
.kjcb-hint.is-shown { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }

/* keep Astra's scroll-to-top clear of the launcher */
#ast-scroll-top { bottom: 100px !important; }

/* ---------- panel ---------- */
.kjcb-panel {
	position: fixed; right: 24px; bottom: 100px; z-index: 99999;
	width: 392px; height: min(640px, calc(100vh - 130px));
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--kj-bg); border-radius: var(--kj-radius);
	box-shadow: 0 30px 80px rgba(16, 18, 24, .28), 0 0 0 1px rgba(16, 18, 24, .06);
	opacity: 0; transform: translateY(16px) scale(.97); transform-origin: bottom right;
	visibility: hidden; pointer-events: none;
	transition: opacity .28s ease, transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .32s;
}
.kjcb.is-open .kjcb-panel {
	opacity: 1; transform: none; visibility: visible; pointer-events: auto;
	transition: opacity .28s ease, transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}

/* header */
.kjcb-head {
	position: relative; display: flex; align-items: center; gap: 12px;
	padding: 18px 16px 18px 18px; color: #fff;
	background: radial-gradient(140% 160% at 0% 0%, #2b3656 0%, var(--kj-ink-2) 45%, var(--kj-ink) 100%);
}
.kjcb-head::after {
	content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
	background: linear-gradient(90deg, transparent, rgba(122, 160, 255, .55), transparent);
}
.kjcb-avatar {
	flex: none; position: relative; width: 44px; height: 44px; border-radius: 14px;
	display: grid; place-items: center;
	background: linear-gradient(135deg, var(--kj-accent), var(--kj-accent-2));
	box-shadow: 0 6px 16px rgba(65, 117, 252, .45);
}
.kjcb-avatar img { width: 30px; height: auto; filter: brightness(0) invert(1); }
.kjcb-avatar::after {
	content: ''; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
	background: #22c55e; border: 2px solid var(--kj-ink-2);
}
.kjcb-title { flex: 1; min-width: 0; }
.kjcb-title strong { display: block; font-family: 'Raleway', system-ui, sans-serif; font-size: 16px; font-weight: 700; letter-spacing: .01em; }
.kjcb-title span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #b8c2d9; }
.kjcb-title span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: kjcb-pulse 2s infinite; }
.kjcb-hbtn {
	flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; padding: 0; cursor: pointer;
	display: grid; place-items: center; color: #c9d2e6; background: rgba(255, 255, 255, .06);
	transition: background .2s ease, color .2s ease;
}
.kjcb-hbtn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.kjcb-hbtn svg { width: 18px; height: 18px; }

/* messages */
.kjcb-body {
	flex: 1; overflow-y: auto; overscroll-behavior: contain;
	padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 12px;
	scrollbar-width: thin; scrollbar-color: #cfd5e2 transparent;
}
.kjcb-row { display: flex; gap: 8px; align-items: flex-end; animation: kjcb-in .32s cubic-bezier(.2, .8, .2, 1) both; }
.kjcb-row.is-user { justify-content: flex-end; }
.kjcb-mini {
	flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
	background: linear-gradient(135deg, var(--kj-accent), var(--kj-accent-2));
}
.kjcb-mini img { width: 18px; height: auto; filter: brightness(0) invert(1); }
.kjcb-bubble {
	max-width: 82%; padding: 11px 14px; border-radius: 18px;
	white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.kjcb-row.is-bot .kjcb-bubble {
	background: var(--kj-card); color: var(--kj-text); border-bottom-left-radius: 6px;
	box-shadow: 0 1px 2px rgba(16, 18, 24, .06), 0 4px 14px rgba(16, 18, 24, .05);
	border: 1px solid var(--kj-line);
}
.kjcb-row.is-user .kjcb-bubble {
	background: linear-gradient(135deg, var(--kj-accent), var(--kj-accent-2)); color: #fff;
	border-bottom-right-radius: 6px; box-shadow: 0 6px 18px rgba(65, 117, 252, .28);
}
.kjcb-row.is-error .kjcb-bubble { background: #fff4f4; border-color: #f6d0d0; color: #9b2c2c; }
.kjcb-bubble a { color: var(--kj-accent-2); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.kjcb-row.is-user .kjcb-bubble a { color: #fff; }
.kjcb-bubble strong { font-weight: 700; }
.kjcb-time { display: block; margin-top: 4px; font-size: 11px; opacity: .55; direction: ltr; text-align: end; }
.kjcb-row.is-bot .kjcb-time { text-align: start; }

/* typing */
.kjcb-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.kjcb-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa6c1; animation: kjcb-bounce 1.2s infinite ease-in-out; }
.kjcb-typing i:nth-child(2) { animation-delay: .15s; }
.kjcb-typing i:nth-child(3) { animation-delay: .3s; }

/* suggestions */
.kjcb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 6px 36px; animation: kjcb-in .4s .1s both; }
.kjcb-chip {
	border: 1px solid #d5ddf0; background: #fff; color: var(--kj-ink-2);
	padding: 8px 13px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
	transition: border-color .2s ease, background .2s ease, color .2s ease, transform .2s ease;
}
.kjcb-chip:hover { border-color: var(--kj-accent); color: var(--kj-accent-2); background: #f0f4ff; transform: translateY(-1px); }

/* composer */
.kjcb-foot { padding: 10px 14px 12px; background: var(--kj-bg); }
.kjcb-composer {
	display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 16px;
	background: var(--kj-card); border: 1px solid var(--kj-line); border-radius: 18px;
	box-shadow: 0 4px 16px rgba(16, 18, 24, .06); transition: border-color .2s ease, box-shadow .2s ease;
}
.kjcb-composer:focus-within { border-color: rgba(65, 117, 252, .6); box-shadow: 0 0 0 4px rgba(65, 117, 252, .12); }
.kjcb-input {
	flex: 1; min-width: 0; max-height: 120px; resize: none; border: 0 !important; outline: 0; background: transparent !important;
	padding: 9px 0 !important; margin: 0; font: inherit; color: var(--kj-text); line-height: 1.45; box-shadow: none !important;
	unicode-bidi: plaintext;
}
.kjcb-input::placeholder { color: #9aa3b5; }
.kjcb-send {
	flex: none; width: 40px; height: 40px; border: 0; border-radius: 13px; padding: 0; cursor: pointer;
	display: grid; place-items: center; color: #fff;
	background: linear-gradient(135deg, var(--kj-accent), var(--kj-accent-2));
	box-shadow: 0 6px 16px rgba(65, 117, 252, .35); transition: transform .2s ease, opacity .2s ease, box-shadow .2s ease;
}
.kjcb-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(65, 117, 252, .45); }
.kjcb-send:disabled { opacity: .4; cursor: default; box-shadow: none; }
.kjcb-send svg { width: 18px; height: 18px; }
.kjcb-note { margin: 8px 0 0; text-align: center; font-size: 11px; color: #9aa3b5; }

/* ---------- animations ---------- */
@keyframes kjcb-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes kjcb-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes kjcb-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); } 70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
@keyframes kjcb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
	.kjcb *, .kjcb *::before { animation: none !important; transition: none !important; }
}

/* ---------- mobile: full screen ---------- */
@media (max-width: 560px) {
	.kjcb-launcher { right: 16px; bottom: 16px; width: 58px; height: 58px; }
	.kjcb-hint { right: 84px; bottom: 26px; }
	.kjcb-panel {
		inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0;
		transform: translateY(24px); transform-origin: bottom center;
	}
	.kjcb-head { padding-top: max(18px, env(safe-area-inset-top)); }
	.kjcb-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
	.kjcb.is-open .kjcb-launcher { display: none; }
	.kjcb-input { font-size: 16px; } /* prevents iOS zoom */
	#ast-scroll-top { bottom: 90px !important; }
}
html.kjcb-lock, html.kjcb-lock body { overflow: hidden; }

/* leave room for the launcher in the site footer's bottom bar */
@media (min-width: 561px) {
	html.kjcb-active .kj-footer__bottom { padding-right: 84px; }
}
