/*
 * Ask Janam – AI News Chatbot
 *
 * Isolation contract, in both directions:
 *
 * Outbound — every selector begins with .aj-chatbot-, so no theme element,
 * class or layout rule is ever touched. Nothing is declared on html, body or
 * any bare element selector.
 *
 * Inbound — the widget subtree is reset with `all: revert`, which rolls theme
 * declarations back to browser defaults inside the widget only. That reset is
 * deliberately written at a LOWER specificity (0,1,0) than every component
 * rule below (0,3,0, via the doubled root class), so the reset clears theme
 * styling without ever clearing ours. Do not "simplify" the doubled class:
 * it is what keeps rules like `.entry-content button` from reaching in.
 */

/* ---------- Defensive reset (must stay above, and weaker than, everything else) ---------- */

.aj-chatbot-root {
	all: revert;
}

.aj-chatbot-root *:not(svg):not(svg *) {
	all: revert;
}

.aj-chatbot-inline-trigger {
	all: revert;
}

.aj-chatbot-root.aj-chatbot-root {
	position: fixed;
	z-index: 99990;
	font-family: var(--aj-font);
	font-size: var(--aj-font-size);
	font-weight: var(--aj-font-weight);
	line-height: var(--aj-line-height);
	color: var(--aj-bot-text);
	text-align: start;
	text-transform: none;
	letter-spacing: normal;
	isolation: isolate;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

.aj-chatbot-root.aj-chatbot-root *,
.aj-chatbot-root.aj-chatbot-root *::before,
.aj-chatbot-root.aj-chatbot-root *::after {
	box-sizing: border-box;
	float: none;
	text-shadow: none;
	text-indent: 0;
	text-transform: none;
	letter-spacing: normal;
	animation: none;
	max-width: none;
	min-width: 0;
}

.aj-chatbot-root.aj-chatbot-root p,
.aj-chatbot-root.aj-chatbot-root ul,
.aj-chatbot-root.aj-chatbot-root li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.aj-chatbot-root.aj-chatbot-root button {
	font-family: inherit;
	cursor: pointer;
	border: 0;
	background: none;
	color: inherit;
}

.aj-chatbot-root.aj-chatbot-root--bottom-right {
	inset-block-end: calc(var(--aj-offset-bottom) + env(safe-area-inset-bottom, 0px));
	inset-inline-end: calc(var(--aj-offset-side) + env(safe-area-inset-right, 0px));
}

.aj-chatbot-root.aj-chatbot-root--bottom-left {
	inset-block-end: calc(var(--aj-offset-bottom) + env(safe-area-inset-bottom, 0px));
	inset-inline-start: calc(var(--aj-offset-side) + env(safe-area-inset-left, 0px));
}

.aj-chatbot-root.aj-chatbot-root--center-right {
	inset-block-start: 50%;
	transform: translateY(-50%);
	inset-inline-end: calc(var(--aj-offset-side) + env(safe-area-inset-right, 0px));
}

.aj-chatbot-root.aj-chatbot-root--center-left {
	inset-block-start: 50%;
	transform: translateY(-50%);
	inset-inline-start: calc(var(--aj-offset-side) + env(safe-area-inset-left, 0px));
}

/* ---------- Launcher ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: var(--aj-launcher-size);
	padding: 0 18px 0 16px;
	border-radius: 999px;
	background: var(--aj-icon-bg);
	color: var(--aj-icon-color);
	font-size: var(--aj-btn-size);
	font-weight: 600;
	box-shadow: var(--aj-shadow);
	transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher:hover {
	transform: translateY(-2px);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher:focus-visible {
	outline: 3px solid var(--aj-primary);
	outline-offset: 3px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher__icon {
	display: inline-flex;
	width: var(--aj-launcher-icon);
	height: var(--aj-launcher-icon);
	flex: 0 0 auto;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher__img {
	width: var(--aj-launcher-icon);
	height: var(--aj-launcher-icon);
	object-fit: contain;
	border-radius: 6px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher__label {
	white-space: nowrap;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher--icon-only {
	width: var(--aj-launcher-size);
	padding: 0;
	justify-content: center;
	border-radius: var(--aj-launcher-radius);
}

.aj-chatbot-root.aj-chatbot-root.is-open .aj-chatbot-launcher {
	opacity: 0;
	pointer-events: none;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher--pulse::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: 0 0 0 0 var(--aj-icon-bg);
	animation: aj-chatbot-pulse 2.4s ease-out infinite;
	pointer-events: none;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher {
	position: relative;
	z-index: 2;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher--bounce {
	animation: aj-chatbot-bounce 3s ease-in-out infinite;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher--fade {
	animation: aj-chatbot-fade 3.4s ease-in-out infinite;
}

@keyframes aj-chatbot-pulse {
	0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.28); }
	70% { box-shadow: 0 0 0 16px rgba(0, 0, 0, 0); }
	100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}

@keyframes aj-chatbot-bounce {
	0%, 88%, 100% { transform: translateY(0); }
	92% { transform: translateY(-6px); }
	96% { transform: translateY(-3px); }
}

@keyframes aj-chatbot-fade {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.72; }
}

/* ---------- Panel ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-panel {
	position: absolute;
	inset-block-end: 0;
	width: min(var(--aj-width), calc(100vw - 32px));
	max-width: var(--aj-max-width);
	height: min(var(--aj-height), calc(100dvh - 48px));
	max-height: var(--aj-max-height);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--aj-chat-bg);
	border: 1px solid var(--aj-border);
	border-radius: var(--aj-radius);
	box-shadow: var(--aj-shadow);
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
	/*
	 * A closed panel must not intercept pointer events. It sits after the
	 * launcher in the DOM and is absolutely positioned over the same corner,
	 * so without this it would swallow every click aimed at the button.
	 */
	visibility: hidden;
	pointer-events: none;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-panel[hidden] {
	display: none;
}

.aj-chatbot-root.aj-chatbot-root--bottom-right .aj-chatbot-panel,
.aj-chatbot-root.aj-chatbot-root--center-right .aj-chatbot-panel {
	inset-inline-end: 0;
}

.aj-chatbot-root.aj-chatbot-root--bottom-left .aj-chatbot-panel,
.aj-chatbot-root.aj-chatbot-root--center-left .aj-chatbot-panel {
	inset-inline-start: 0;
}

.aj-chatbot-root.aj-chatbot-root--center-right .aj-chatbot-panel,
.aj-chatbot-root.aj-chatbot-root--center-left .aj-chatbot-panel {
	inset-block-end: auto;
	inset-block-start: 50%;
	transform: translateY(-50%);
}

.aj-chatbot-root.aj-chatbot-root.is-open .aj-chatbot-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	visibility: visible;
	pointer-events: auto;
	transition-delay: 0s;
}

.aj-chatbot-root.aj-chatbot-root--center-right.is-open .aj-chatbot-panel,
.aj-chatbot-root.aj-chatbot-root--center-left.is-open .aj-chatbot-panel {
	transform: translateY(-50%);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 14px 14px 16px;
	background: var(--aj-header-bg);
	color: var(--aj-header-text);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header__logo {
	width: var(--aj-logo-size);
	height: var(--aj-logo-size);
	object-fit: contain;
	border-radius: 6px;
	flex: 0 0 auto;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header__text {
	min-width: 0;
	flex: 1 1 auto;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header__title {
	font-size: var(--aj-heading-size);
	font-weight: 700;
	line-height: 1.2;
	color: inherit;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header__subtitle {
	font-size: calc(var(--aj-msg-size) - 3px);
	opacity: 0.78;
	line-height: 1.3;
	color: inherit;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-header__actions {
	display: flex;
	gap: 2px;
	flex: 0 0 auto;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-iconbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	color: inherit;
	opacity: 0.82;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-iconbtn svg {
	width: 17px;
	height: 17px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-iconbtn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.14);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-iconbtn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---------- Message log ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scrollbar-width: thin;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-log:focus-visible {
	outline: 2px solid var(--aj-primary);
	outline-offset: -2px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg {
	max-width: 88%;
	padding: 10px 13px;
	font-size: var(--aj-msg-size);
	border-radius: calc(var(--aj-radius) * 0.75);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg--user {
	align-self: flex-end;
	background: var(--aj-user-bg);
	color: var(--aj-user-text);
	border-end-end-radius: 4px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg--bot {
	align-self: flex-start;
	background: var(--aj-bot-bg);
	color: var(--aj-bot-text);
	border: 1px solid var(--aj-border);
	border-end-start-radius: 4px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg--error {
	border-color: var(--aj-primary);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-typing {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: calc(var(--aj-msg-size) - 1px);
	opacity: 0.85;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-typing__dots {
	display: inline-flex;
	gap: 4px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-typing__dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aj-primary);
	animation: aj-chatbot-blink 1.2s infinite ease-in-out;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-typing__dots span:nth-child(2) { animation-delay: 0.18s; }
.aj-chatbot-root.aj-chatbot-root .aj-chatbot-typing__dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes aj-chatbot-blink {
	0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- News cards ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-cards {
	align-self: stretch;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card {
	display: flex;
	gap: 12px;
	padding: 10px;
	background: var(--aj-bot-bg);
	border: 1px solid var(--aj-border);
	border-radius: calc(var(--aj-radius) * 0.7);
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card:hover {
	border-color: var(--aj-primary);
	transform: translateY(-1px);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__thumb {
	width: 84px;
	height: 84px;
	flex: 0 0 auto;
	object-fit: cover;
	border-radius: calc(var(--aj-radius) * 0.45);
	background: var(--aj-chat-bg);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__body {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	font-size: calc(var(--aj-msg-size) - 4px);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--aj-primary);
	font-weight: 600;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__meta span:not(:first-child) {
	color: var(--aj-bot-text);
	opacity: 0.62;
	font-weight: 500;
	text-transform: none;
	letter-spacing: 0;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__title {
	font-size: var(--aj-msg-size);
	font-weight: 700;
	line-height: 1.3;
	color: var(--aj-bot-text);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__excerpt {
	font-size: calc(var(--aj-msg-size) - 2px);
	opacity: 0.78;
	color: var(--aj-bot-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__link {
	align-self: flex-start;
	margin-top: 2px;
	font-size: calc(var(--aj-btn-size) - 1px);
	font-weight: 600;
	color: var(--aj-link);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__link:hover,
.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__link:focus-visible {
	border-bottom-color: currentColor;
	text-decoration: none;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__link:focus-visible {
	outline: 2px solid var(--aj-primary);
	outline-offset: 3px;
}

/* ---------- Suggestions ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-suggestions {
	padding: 10px 14px;
	border-top: 1px solid var(--aj-border);
	background: var(--aj-chat-bg);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-suggestions__title {
	font-size: calc(var(--aj-msg-size) - 3px);
	font-weight: 600;
	opacity: 0.66;
	margin-bottom: 7px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-suggestions__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-chip {
	padding: 6px 11px;
	font-size: calc(var(--aj-btn-size) - 1px);
	border: 1px solid var(--aj-border);
	border-radius: 999px;
	background: var(--aj-bot-bg);
	color: var(--aj-bot-text);
	transition: border-color 0.15s ease, color 0.15s ease;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-chip:hover {
	border-color: var(--aj-primary);
	color: var(--aj-primary);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-chip:focus-visible {
	outline: 2px solid var(--aj-primary);
	outline-offset: 2px;
}

/* ---------- Composer ---------- */

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-composer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--aj-border);
	background: var(--aj-bot-bg);
	margin: 0;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 42px;
	padding: 0 14px;
	font-family: inherit;
	font-size: max(16px, var(--aj-msg-size));
	color: var(--aj-input-text);
	background: var(--aj-input-bg);
	border: 1px solid var(--aj-border);
	border-radius: 999px;
	box-shadow: none;
	margin: 0;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-input:focus {
	outline: none;
	border-color: var(--aj-primary);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-input:focus-visible {
	outline: 2px solid var(--aj-primary);
	outline-offset: 1px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	flex: 0 0 auto;
	border-radius: 50%;
	background: var(--aj-btn-bg);
	color: var(--aj-btn-text);
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-send svg {
	width: 19px;
	height: 19px;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-send:hover {
	background: var(--aj-btn-bg-hover);
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-send:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-send:focus-visible {
	outline: 3px solid var(--aj-primary);
	outline-offset: 2px;
}

.aj-chatbot-inline-trigger.aj-chatbot-inline-trigger {
	display: inline-flex;
	align-items: center;
	padding: 10px 18px;
	border-radius: 999px;
	background: var(--aj-btn-bg, #c8102e);
	color: var(--aj-btn-text, #fff);
	font-weight: 600;
	cursor: pointer;
	border: 0;
}

.aj-chatbot-root.aj-chatbot-root .aj-chatbot-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
	.aj-chatbot-root.aj-chatbot-root {
		font-size: var(--aj-m-font-size);
	}

	.aj-chatbot-root.aj-chatbot-root--bottom-right,
	.aj-chatbot-root.aj-chatbot-root--center-right {
		inset-block-end: calc(var(--aj-m-offset-bottom) + env(safe-area-inset-bottom, 0px));
		inset-block-start: auto;
		inset-inline-end: calc(var(--aj-m-offset-side) + env(safe-area-inset-right, 0px));
		transform: none;
	}

	.aj-chatbot-root.aj-chatbot-root--bottom-left,
	.aj-chatbot-root.aj-chatbot-root--center-left {
		inset-block-end: calc(var(--aj-m-offset-bottom) + env(safe-area-inset-bottom, 0px));
		inset-block-start: auto;
		inset-inline-start: calc(var(--aj-m-offset-side) + env(safe-area-inset-left, 0px));
		transform: none;
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher {
		min-height: var(--aj-m-launcher-size);
		padding: 0 14px;
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher__label {
		display: none;
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-launcher {
		width: var(--aj-m-launcher-size);
		padding: 0;
		justify-content: center;
		border-radius: var(--aj-launcher-radius);
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-panel {
		position: fixed;
		inset-inline: var(--aj-m-gap);
		inset-block-end: calc(var(--aj-m-gap) + env(safe-area-inset-bottom, 0px));
		inset-block-start: auto;
		width: auto;
		max-width: none;
		height: var(--aj-m-height);
		max-height: calc(100dvh - (var(--aj-m-gap) * 2));
		transform: translateY(12px);
	}

	.aj-chatbot-root.aj-chatbot-root.is-open .aj-chatbot-panel,
	.aj-chatbot-root.aj-chatbot-root--center-right.is-open .aj-chatbot-panel,
	.aj-chatbot-root.aj-chatbot-root--center-left.is-open .aj-chatbot-panel {
		transform: translateY(0);
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card__thumb {
		width: 68px;
		height: 68px;
	}

	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg {
		max-width: 92%;
	}
}

/* Viewport unit fallback and on-screen keyboard handling. */
@supports not (height: 100dvh) {
	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-panel {
		height: min(var(--aj-height), calc(100vh - 48px));
	}

	@media (max-width: 600px) {
		.aj-chatbot-root.aj-chatbot-root .aj-chatbot-panel {
			height: calc(var(--aj-viewport-height, 100vh) - (var(--aj-m-gap) * 2));
		}
	}
}

.aj-chatbot-root.aj-chatbot-root.is-keyboard-open .aj-chatbot-panel {
	height: calc(var(--aj-viewport-height, 100dvh) - (var(--aj-m-gap) * 2));
}

@media (prefers-reduced-motion: reduce) {
	.aj-chatbot-root.aj-chatbot-root *,
	.aj-chatbot-root.aj-chatbot-root *::before,
	.aj-chatbot-root.aj-chatbot-root *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}

@media (prefers-contrast: more) {
	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-card,
	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-msg--bot,
	.aj-chatbot-root.aj-chatbot-root .aj-chatbot-chip {
		border-width: 2px;
	}
}
