/* JHR AI Chatbot — front-end widget
 * All colours/sizes come from CSS custom properties set by chatbot.js from the plugin settings.
 */

.jhr-aic {
	--jhr-aic-primary: #0f5c4d;
	--jhr-aic-header-text: #ffffff;
	--jhr-aic-bg: #ffffff;
	--jhr-aic-bot-bg: #f1f4f3;
	--jhr-aic-bot-text: #1d2b28;
	--jhr-aic-user-bg: #0f5c4d;
	--jhr-aic-user-text: #ffffff;
	--jhr-aic-font: inherit;
	--jhr-aic-font-size: 15px;
	--jhr-aic-radius: 16px;
	--jhr-aic-width: 380px;
	--jhr-aic-launcher: 60px;
	--jhr-aic-x: 24px;
	--jhr-aic-y: 24px;
	--jhr-aic-border: rgba(0, 0, 0, 0.08);
	--jhr-aic-muted: rgba(0, 0, 0, 0.5);

	position: fixed;
	bottom: var(--jhr-aic-y);
	right: var(--jhr-aic-x);
	z-index: 2147483000;
	font-family: var(--jhr-aic-font);
	font-size: var(--jhr-aic-font-size);
	line-height: 1.5;
	color: var(--jhr-aic-bot-text);
	-webkit-font-smoothing: antialiased;
}

.jhr-aic--left {
	right: auto;
	left: var(--jhr-aic-x);
}

.jhr-aic *,
.jhr-aic *::before,
.jhr-aic *::after {
	box-sizing: border-box;
}

/* Defend against aggressive theme styles on buttons/inputs. */
.jhr-aic button,
.jhr-aic textarea {
	font: inherit;
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
	box-shadow: none;
	min-height: 0;
	line-height: inherit;
}

.jhr-aic button {
	cursor: pointer;
	background: none;
	border: 0;
	padding: 0;
	width: auto;
	height: auto;
}

.jhr-aic svg {
	display: block;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

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

.jhr-aic__launcher {
	position: relative;
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: var(--jhr-aic-launcher) !important;
	height: var(--jhr-aic-launcher) !important;
	border-radius: 50% !important;
	background: var(--jhr-aic-primary) !important;
	color: var(--jhr-aic-header-text) !important;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12) !important;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	overflow: hidden;
	margin-left: auto !important;
}

.jhr-aic--left .jhr-aic__launcher {
	margin-left: 0 !important;
}

.jhr-aic__launcher:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22), 0 3px 8px rgba(0, 0, 0, 0.12) !important;
}

.jhr-aic__launcher:focus-visible,
.jhr-aic__icon-btn:focus-visible,
.jhr-aic__send:focus-visible,
.jhr-aic__chip:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--jhr-aic-primary) 45%, transparent);
	outline-offset: 2px;
}

.jhr-aic__launcher svg {
	width: 46%;
	height: 46%;
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.jhr-aic__launcher img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 0.2s ease;
}

.jhr-aic__launcher .jhr-aic__launcher-close {
	position: absolute;
	opacity: 0;
	transform: rotate(-90deg);
}

.jhr-aic--open .jhr-aic__launcher .jhr-aic__launcher-open {
	opacity: 0;
	transform: rotate(90deg);
}

.jhr-aic--open .jhr-aic__launcher .jhr-aic__launcher-close {
	opacity: 1;
	transform: none;
}

.jhr-aic--open .jhr-aic__launcher img {
	opacity: 0;
}

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

.jhr-aic__panel {
	position: absolute;
	bottom: calc(var(--jhr-aic-launcher) + 16px);
	right: 0;
	width: var(--jhr-aic-width);
	max-width: calc(100vw - 32px);
	height: min(620px, calc(100vh - var(--jhr-aic-launcher) - var(--jhr-aic-y) - 40px));
	display: flex;
	flex-direction: column;
	background: var(--jhr-aic-bg);
	border-radius: var(--jhr-aic-radius);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.08);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.98);
	transform-origin: bottom right;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.jhr-aic--left .jhr-aic__panel {
	right: auto;
	left: 0;
	transform-origin: bottom left;
}

.jhr-aic--open .jhr-aic__panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s;
}

/* ---------- Header ---------- */

.jhr-aic__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 14px 16px 18px;
	background: var(--jhr-aic-primary);
	background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.06));
	color: var(--jhr-aic-header-text);
	flex-shrink: 0;
}

.jhr-aic__brand {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
	flex: 1;
}

.jhr-aic__logo {
	display: block;
	max-height: 34px;
	max-width: 96px;
	width: auto;
	height: auto;
	object-fit: contain;
	flex-shrink: 0;
}

.jhr-aic__titles {
	min-width: 0;
}

.jhr-aic__title {
	font-weight: 600;
	font-size: 1.05em;
	line-height: 1.25;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: inherit;
}

.jhr-aic__subtitle {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.8em;
	opacity: 0.85;
	white-space: nowrap;
/*	overflow: hidden;*/
	text-overflow: ellipsis;
}

.jhr-aic__subtitle::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #04ba46;
	box-shadow: 0 0 0 2px rgb(0 255 67);
/*	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);*/
	flex-shrink: 0;
}

.jhr-aic__icon-btn {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 34px !important;
	height: 34px !important;
	border-radius: 50% !important;
	color: var(--jhr-aic-header-text) !important;
	opacity: 0.85;
	transition: background-color 0.15s ease, opacity 0.15s ease;
	flex-shrink: 0;
}

.jhr-aic__icon-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.16) !important;
}

.jhr-aic__icon-btn svg {
	width: 18px;
	height: 18px;
}

/* ---------- Messages ---------- */

.jhr-aic__messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}

.jhr-aic__row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
	animation: jhr-aic-in 0.25s ease both;
}

.jhr-aic__row--user {
	justify-content: flex-end;
}

@keyframes jhr-aic-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

.jhr-aic__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--jhr-aic-primary);
	color: var(--jhr-aic-header-text);
	overflow: hidden;
	border: 1px solid var(--jhr-aic-border);
}

.jhr-aic__avatar--img {
	background: var(--jhr-aic-primary);
	padding: 3px;
}

.jhr-aic__avatar img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.jhr-aic__avatar svg {
	width: 15px;
	height: 15px;
}

.jhr-aic__bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: calc(var(--jhr-aic-radius) * 0.9);
	background: var(--jhr-aic-bot-bg);
	color: var(--jhr-aic-bot-text);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.jhr-aic__row--bot .jhr-aic__bubble {
	border-bottom-left-radius: 4px;
}

.jhr-aic--left .jhr-aic__row--bot .jhr-aic__bubble,
.jhr-aic__row--bot .jhr-aic__bubble {
	border-bottom-left-radius: 4px;
}

.jhr-aic__row--user .jhr-aic__bubble {
	background: var(--jhr-aic-user-bg);
	color: var(--jhr-aic-user-text);
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}

.jhr-aic__row--error .jhr-aic__bubble {
	background: #fdecec;
	color: #8a1f1f;
}

.jhr-aic__bubble p {
	margin: 0 0 0.6em;
	padding: 0;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

.jhr-aic__bubble p:last-child,
.jhr-aic__bubble ul:last-child,
.jhr-aic__bubble ol:last-child {
	margin-bottom: 0;
}

.jhr-aic__bubble ul,
.jhr-aic__bubble ol {
	margin: 0 0 0.6em;
	padding: 0 0 0 1.25em;
	list-style-position: outside;
}

.jhr-aic__bubble ul { list-style-type: disc; }
.jhr-aic__bubble ol { list-style-type: decimal; }

.jhr-aic__bubble[dir="rtl"] ul,
.jhr-aic__bubble[dir="rtl"] ol {
	padding: 0 1.25em 0 0;
}

.jhr-aic__bubble li {
	margin: 0 0 0.25em;
	padding: 0;
	color: inherit;
}

.jhr-aic__bubble a {
	color: var(--jhr-aic-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 500;
}

.jhr-aic__row--user .jhr-aic__bubble a {
	color: inherit;
}

.jhr-aic__bubble strong {
	font-weight: 600;
	color: inherit;
}

.jhr-aic__bubble code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.88em;
	background: rgba(0, 0, 0, 0.06);
	padding: 1px 5px;
	border-radius: 4px;
}

.jhr-aic__sources {
	margin-top: 10px;
	padding-top: 8px;
	border-top: 1px solid var(--jhr-aic-border);
	font-size: 0.85em;
}

.jhr-aic__sources-label {
	display: block;
	color: var(--jhr-aic-muted);
	margin-bottom: 4px;
	font-size: 0.92em;
}

.jhr-aic__sources a {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-decoration: none;
}

.jhr-aic__sources a::before {
	content: "↗ ";
}

.jhr-aic__sources a:hover {
	text-decoration: underline;
}

/* Typing indicator */
.jhr-aic__typing {
	display: inline-flex;
	gap: 4px;
	padding: 4px 2px;
}

.jhr-aic__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.35;
	animation: jhr-aic-dot 1.2s infinite ease-in-out;
}

.jhr-aic__typing span:nth-child(2) { animation-delay: 0.15s; }
.jhr-aic__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes jhr-aic-dot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
	30% { transform: translateY(-4px); opacity: 0.8; }
}

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

.jhr-aic__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 16px 10px;
}

.jhr-aic__chips:empty {
	display: none;
}

.jhr-aic__chip {
	padding: 7px 13px !important;
	border-radius: 999px !important;
	border: 1px solid color-mix(in srgb, var(--jhr-aic-primary) 35%, transparent) !important;
	background: color-mix(in srgb, var(--jhr-aic-primary) 6%, var(--jhr-aic-bg)) !important;
	color: var(--jhr-aic-primary) !important;
	font-size: 0.86em !important;
	line-height: 1.3 !important;
	text-align: start;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.jhr-aic__chip:hover {
	background: var(--jhr-aic-primary) !important;
	color: var(--jhr-aic-header-text) !important;
}

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

.jhr-aic__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0 12px 12px;
	padding: 6px 6px 6px 14px;
	border: 1px solid var(--jhr-aic-border);
	border-radius: calc(var(--jhr-aic-radius) * 1.2);
	background: var(--jhr-aic-bg);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	flex-shrink: 0;
}

.jhr-aic__form:focus-within {
	border-color: color-mix(in srgb, var(--jhr-aic-primary) 55%, transparent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--jhr-aic-primary) 14%, transparent);
}

.jhr-aic__input {
	flex: 1;
	border: 0 !important;
	outline: 0 !important;
	background: transparent !important;
	resize: none;
	padding: 7px 0 !important;
	max-height: 120px;
	min-height: 22px !important;
	height: 36px;
	color: var(--jhr-aic-bot-text) !important;
	font-size: inherit !important;
	border-radius: 0 !important;
}

.jhr-aic__input::placeholder {
	color: var(--jhr-aic-muted);
	opacity: 1;
}

.jhr-aic__send {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 38px !important;
	height: 38px !important;
	border-radius: calc(var(--jhr-aic-radius) * 0.85) !important;
	background: var(--jhr-aic-primary) !important;
	color: var(--jhr-aic-header-text) !important;
	flex-shrink: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.jhr-aic__send:disabled {
	opacity: 0.4;
	cursor: default;
}

.jhr-aic__send:not(:disabled):hover {
	transform: scale(1.05);
}

.jhr-aic__send svg {
	width: 18px;
	height: 18px;
}

.jhr-aic__footer {
	text-align: center;
	font-size: 0.72em;
	color: var(--jhr-aic-muted);
	margin: -6px 0 8px;
}

.jhr-aic__footer:empty {
	display: none;
}

/* ---------- Mobile: full-screen panel ---------- */

@media (max-width: 480px) {
	.jhr-aic:not(.jhr-aic--preview) .jhr-aic__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
	}

	.jhr-aic--open:not(.jhr-aic--preview) .jhr-aic__launcher {
		display: none !important;
	}
}

/* ---------- Admin live preview ---------- */

.jhr-aic--preview {
	position: absolute;
	z-index: 1;
}

.jhr-aic--preview .jhr-aic__panel {
	height: 520px;
	max-width: none;
}

@media (prefers-reduced-motion: reduce) {
	.jhr-aic *,
	.jhr-aic *::before,
	.jhr-aic *::after {
		animation: none !important;
		transition: none !important;
	}
}
