/* ==========================================================================
   AI Migration Chatbot — front-end widget
   All rules are scoped under .aimc-root so the host theme is never touched.
   Colors come from CSS variables set inline by widget.js (--cb-*).
   ========================================================================== */

.aimc-root {
	--cb-header-c1: #14355c;
	--cb-header-c2: #0e8a80;
	--cb-header-text: #ffffff;
	--cb-win-bg: #ffffff;
	--cb-bot-bg: #f1f4f8;
	--cb-bot-text: #14243a;
	--cb-user-bg: #16324f;
	--cb-user-text: #ffffff;
	--cb-accent: #0e8a80;
	--cb-launcher-c1: #14355c;
	--cb-launcher-c2: #0e8a80;
	--cb-radius: 18px;
	--cb-width: 380px;
	--cb-height: 600px;
	--cb-font-size: 15px;
	--cb-shadow: 0 24px 60px rgba(13, 22, 38, .28);
	--cb-muted: #6b7688;
	--cb-border: rgba(20, 36, 58, .1);

	position: fixed;
	z-index: 2147483000;
	bottom: 0;
	font-family: inherit;
	font-size: var(--cb-font-size);
	line-height: 1.5;
	color: var(--cb-bot-text);
	-webkit-font-smoothing: antialiased;
}
.aimc-root.aimc-pos-right { right: 0; }
.aimc-root.aimc-pos-left  { left: 0; }

.aimc-root[data-theme="dark"] {
	--cb-win-bg: var(--cb-dark-win-bg, #0d1626);
	--cb-bot-bg: var(--cb-dark-bot-bg, #182338);
	--cb-bot-text: var(--cb-dark-bot-text, #e7edf6);
	--cb-muted: #9aa8bf;
	--cb-border: rgba(255, 255, 255, .12);
}

.aimc-root *,
.aimc-root *::before,
.aimc-root *::after {
	box-sizing: border-box;
}

/* The `hidden` attribute must win over the display rules below (otherwise the
   window and unread badge render open on load). */
.aimc-root [hidden] {
	display: none !important;
}

/* ---- Launcher ------------------------------------------------------------ */
.aimc-launcher {
	position: absolute;
	bottom: var(--cb-offset-y, 24px);
	width: 60px;
	height: 60px;
	border: none;
	overflow: hidden;
	cursor: pointer;
	color: #fff;
	background: linear-gradient(135deg, var(--cb-launcher-c1), var(--cb-launcher-c2));
	box-shadow: 0 12px 28px rgba(13, 22, 38, .3);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .18s ease, box-shadow .18s ease;
	padding: 0;
}
.aimc-pos-right .aimc-launcher { right: var(--cb-offset-x, 24px); }
.aimc-pos-left  .aimc-launcher { left:  var(--cb-offset-x, 24px); }
.aimc-launcher:hover { transform: translateY(-2px) scale(1.03); }
.aimc-launcher:active { transform: translateY(0) scale(.98); }
.aimc-launcher svg { width: 28px; height: 28px; display: block; }
/* Logo mode: the image fills the whole launcher and is clipped to its shape. */
.aimc-launcher img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.aimc-launcher-emoji { font-size: 26px; line-height: 1; }

.aimc-size-sm .aimc-launcher { width: 50px; height: 50px; }
.aimc-size-lg .aimc-launcher { width: 70px; height: 70px; }
.aimc-shape-circle .aimc-launcher { border-radius: 50%; }
.aimc-shape-square .aimc-launcher { border-radius: 18px; }

.aimc-launcher.aimc-pulse::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: 0 0 0 0 rgba(14, 138, 128, .5);
	animation: aimc-pulse 2.4s infinite;
}
@keyframes aimc-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(14, 138, 128, .45); }
	70%  { box-shadow: 0 0 0 16px rgba(14, 138, 128, 0); }
	100% { box-shadow: 0 0 0 0 rgba(14, 138, 128, 0); }
}

.aimc-unread {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: #e5484d;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid var(--cb-win-bg);
}

/* ---- Teaser bubble ------------------------------------------------------- */
.aimc-teaser {
	position: absolute;
	bottom: calc(var(--cb-offset-y, 24px) + 74px);
	max-width: 240px;
	background: var(--cb-win-bg);
	color: var(--cb-bot-text);
	border: 1px solid var(--cb-border);
	border-radius: 14px;
	padding: 12px 34px 12px 14px;
	font-size: 13.5px;
	line-height: 1.4;
	box-shadow: 0 14px 34px rgba(13, 22, 38, .2);
	cursor: pointer;
	animation: aimc-fade-up .28s ease both;
}
.aimc-pos-right .aimc-teaser { right: calc(var(--cb-offset-x, 24px) + 4px); }
.aimc-pos-left  .aimc-teaser { left:  calc(var(--cb-offset-x, 24px) + 4px); }
.aimc-teaser-close {
	position: absolute;
	top: 6px;
	right: 8px;
	border: none;
	background: none;
	color: var(--cb-muted);
	cursor: pointer;
	font-size: 15px;
	line-height: 1;
	padding: 2px;
}

/* ---- Chat window --------------------------------------------------------- */
.aimc-window {
	position: absolute;
	bottom: var(--cb-offset-y, 24px);
	width: var(--cb-width);
	max-width: calc(100vw - 32px);
	height: var(--cb-height);
	max-height: calc(100vh - 48px);
	background: var(--cb-win-bg);
	border-radius: calc(var(--cb-radius) + 6px);
	box-shadow: var(--cb-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: aimc-open .24s cubic-bezier(.22, 1, .36, 1) both;
}
.aimc-pos-right .aimc-window { right: var(--cb-offset-x, 24px); }
.aimc-pos-left  .aimc-window { left:  var(--cb-offset-x, 24px); transform-origin: bottom left; }
.aimc-shadow-none .aimc-window { box-shadow: none; border: 1px solid var(--cb-border); }
.aimc-shadow-sm .aimc-window { --cb-shadow: 0 10px 26px rgba(13, 22, 38, .16); }
.aimc-shadow-lg .aimc-window { --cb-shadow: 0 32px 80px rgba(13, 22, 38, .36); }

@keyframes aimc-open {
	from { opacity: 0; transform: translateY(14px) scale(.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Header with meridian flight-path signature -------------------------- */
.aimc-header {
	position: relative;
	background: linear-gradient(120deg, var(--cb-header-c1), var(--cb-header-c2));
	color: var(--cb-header-text);
	padding: 15px 16px;
	display: flex;
	align-items: center;
	gap: 11px;
	overflow: hidden;
}
/* Dotted great-circle arc + a small plane dot, drawn as an inline SVG data URI. */
.aimc-header::after {
	content: "";
	position: absolute;
	inset: 0;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 380 120' preserveAspectRatio='none'%3E%3Cpath d='M-10 92 Q 190 -18 390 92' fill='none' stroke='%23ffffff' stroke-opacity='0.28' stroke-width='1.4' stroke-dasharray='1 7' stroke-linecap='round'/%3E%3Ccircle cx='300' cy='40' r='2.6' fill='%23ffffff' fill-opacity='0.7'/%3E%3C/svg%3E");
	background-size: 100% 100%;
	background-repeat: no-repeat;
	pointer-events: none;
}
.aimc-header > * { position: relative; z-index: 1; }
.aimc-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .18);
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	overflow: hidden;
}
.aimc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aimc-avatar svg { width: 20px; height: 20px; }
.aimc-hgroup { flex: 1; min-width: 0; }
.aimc-title { font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aimc-subtitle { font-size: 11.5px; opacity: .85; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.aimc-subtitle span:last-child { overflow: hidden; text-overflow: ellipsis; }
.aimc-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.aimc-header-actions { display: flex; align-items: center; gap: 6px; }
.aimc-lang-select {
	background: rgba(255, 255, 255, .16);
	color: var(--cb-header-text);
	border: none;
	border-radius: 8px;
	font-size: 12px;
	padding: 4px 6px;
	cursor: pointer;
}
.aimc-lang-select option { color: #14243a; }
.aimc-close {
	background: none;
	border: none;
	color: var(--cb-header-text);
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 4px 6px;
	border-radius: 8px;
	opacity: .9;
}
.aimc-close:hover { background: rgba(255, 255, 255, .16); opacity: 1; }

/* ---- Notice bar ---------------------------------------------------------- */
.aimc-notice {
	background: var(--cb-bot-bg);
	color: var(--cb-muted);
	font-size: 11px;
	line-height: 1.4;
	padding: 7px 14px;
	border-bottom: 1px solid var(--cb-border);
}
.aimc-notice a { color: var(--cb-accent); }

/* ---- Message list -------------------------------------------------------- */
.aimc-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--cb-win-bg);
}
.aimc-msg {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: var(--cb-radius);
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: aimc-fade-up .18s ease both;
}
.aimc-msg a { color: inherit; text-decoration: underline; }
.aimc-bot {
	align-self: flex-start;
	background: var(--cb-bot-bg);
	color: var(--cb-bot-text);
	border-bottom-left-radius: 5px;
}
.aimc-user {
	align-self: flex-end;
	background: var(--cb-user-bg);
	color: var(--cb-user-text);
	border-bottom-right-radius: 5px;
}
.aimc-user a { color: var(--cb-user-text); }
.aimc-time {
	display: block;
	font-size: 10px;
	opacity: .55;
	margin-top: 4px;
}
[dir="rtl"] .aimc-bot { border-bottom-left-radius: var(--cb-radius); border-bottom-right-radius: 5px; }
[dir="rtl"] .aimc-user { border-bottom-right-radius: var(--cb-radius); border-bottom-left-radius: 5px; }

@keyframes aimc-fade-up {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ---- Typing indicator ---------------------------------------------------- */
.aimc-typing {
	align-self: flex-start;
	background: var(--cb-bot-bg);
	border-radius: var(--cb-radius);
	border-bottom-left-radius: 5px;
	padding: 12px 14px;
	display: flex;
	gap: 4px;
}
.aimc-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--cb-muted);
	animation: aimc-bounce 1.2s infinite ease-in-out;
}
.aimc-typing span:nth-child(2) { animation-delay: .15s; }
.aimc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aimc-bounce {
	0%, 80%, 100% { transform: scale(.6); opacity: .5; }
	40% { transform: scale(1); opacity: 1; }
}

/* ---- Quick chips --------------------------------------------------------- */
.aimc-invite {
	align-self: flex-start;
	max-width: 88%;
	margin: -2px 2px 2px;
	font-size: 12px;
	line-height: 1.4;
	font-style: italic;
	color: var(--cb-muted);
}
.aimc-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 0 14px 12px;
	background: var(--cb-win-bg);
}
.aimc-chip {
	border: 1px solid var(--cb-accent);
	color: var(--cb-accent);
	background: transparent;
	border-radius: 999px;
	padding: 6px 13px;
	font-size: 13px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.aimc-chip:hover { background: var(--cb-accent); color: #fff; }

/* ---- Composer ------------------------------------------------------------ */
.aimc-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--cb-border);
	background: var(--cb-win-bg);
}
.aimc-input {
	flex: 1;
	resize: none;
	border: 1px solid var(--cb-border);
	border-radius: 20px;
	padding: 9px 14px;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	max-height: 120px;
	background: var(--cb-win-bg);
	color: var(--cb-bot-text);
	outline: none;
}
.aimc-input:focus-visible { border-color: var(--cb-accent); box-shadow: 0 0 0 2px rgba(14, 138, 128, .25); }
.aimc-send {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--cb-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .12s ease, opacity .12s ease;
}
.aimc-send:hover { transform: scale(1.06); }
.aimc-send:disabled { opacity: .5; cursor: default; transform: none; }
.aimc-send svg { width: 18px; height: 18px; }
[dir="rtl"] .aimc-send svg { transform: scaleX(-1); }

.aimc-footer {
	text-align: center;
	font-size: 10.5px;
	color: var(--cb-muted);
	padding: 0 12px 8px;
	background: var(--cb-win-bg);
}

/* ---- Focus quality floor ------------------------------------------------- */
.aimc-root :focus-visible {
	outline: 2px solid var(--cb-accent);
	outline-offset: 2px;
}

/* ---- Mobile full-height sheet ------------------------------------------- */
@media (max-width: 480px) {
	.aimc-window {
		position: fixed;
		top: 0;
		right: 0 !important;
		bottom: 0;
		left: 0 !important;
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		max-height: none;
		max-width: 100vw;
		border-radius: 0;
	}
	.aimc-teaser { max-width: 180px; }
}

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
	.aimc-window,
	.aimc-msg,
	.aimc-teaser { animation: none !important; }
	.aimc-launcher.aimc-pulse::after { animation: none; }
	.aimc-typing span { animation-duration: 2s; }
	.aimc-launcher { transition: none; }
}

/* ==========================================================================
   Host-theme hardening
   Some WordPress themes force <button> background / color / border (often with
   !important) and a color change on :hover. That turns the send button white
   with an invisible icon and boxes the close control. These rules re-assert the
   widget's own button styling with enough weight to win regardless.
   ========================================================================== */
.aimc-root button,
.aimc-root select {
	-webkit-appearance: none !important;
	appearance: none !important;
	min-height: 0 !important;
	min-width: 0 !important;
	text-transform: none !important;
	letter-spacing: normal !important;
	font-family: inherit !important;
	text-shadow: none !important;
}

.aimc-root .aimc-launcher,
.aimc-root .aimc-launcher:hover,
.aimc-root .aimc-launcher:focus {
	background: linear-gradient(135deg, var(--cb-launcher-c1), var(--cb-launcher-c2)) !important;
	color: #fff !important;
	border: 0 !important;
	box-shadow: 0 12px 28px rgba(13, 22, 38, .3) !important;
}

.aimc-root .aimc-send,
.aimc-root .aimc-send:hover,
.aimc-root .aimc-send:focus,
.aimc-root .aimc-send:active {
	background: var(--cb-accent) !important;
	color: #fff !important;
	border: 0 !important;
	box-shadow: none !important;
	width: 40px !important;
	height: 40px !important;
	min-width: 40px !important;
	min-height: 40px !important;
	padding: 0 !important;
	border-radius: 50% !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex: 0 0 auto !important;
}
.aimc-root .aimc-send:hover { filter: brightness(1.08); }
.aimc-root .aimc-send:disabled { opacity: .5 !important; }
.aimc-root .aimc-send svg,
.aimc-root .aimc-send svg path {
	fill: #fff !important;
}
.aimc-root .aimc-send svg {
	width: 18px !important;
	height: 18px !important;
	display: block !important;
	opacity: 1 !important;
}

.aimc-root .aimc-close {
	background: transparent !important;
	color: var(--cb-header-text) !important;
	border: 0 !important;
	box-shadow: none !important;
}
.aimc-root .aimc-close:hover,
.aimc-root .aimc-close:focus {
	background: rgba(255, 255, 255, .18) !important;
	color: var(--cb-header-text) !important;
}

.aimc-root .aimc-chip {
	background: transparent !important;
	color: var(--cb-accent) !important;
	border: 1px solid var(--cb-accent) !important;
	box-shadow: none !important;
}
.aimc-root .aimc-chip:hover,
.aimc-root .aimc-chip:focus {
	background: var(--cb-accent) !important;
	color: #fff !important;
}

.aimc-root .aimc-teaser-close {
	background: transparent !important;
	color: var(--cb-muted) !important;
	border: 0 !important;
	box-shadow: none !important;
}

.aimc-root .aimc-lang-select {
	background: rgba(255, 255, 255, .16) !important;
	color: var(--cb-header-text) !important;
	border: 0 !important;
	box-shadow: none !important;
	background-image: none !important;
}

/* ==========================================================================
   Layout hardening (RTL themes + aggressive host button/textarea styles)
   ========================================================================== */

/* Header: keep it a single centered row so the name and subtitle sit
   vertically centered next to the avatar. */
.aimc-root .aimc-header {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	gap: 11px !important;
}
.aimc-root .aimc-avatar {
	flex: 0 0 auto !important;
	width: 40px !important;
	height: 40px !important;
	border-radius: 50% !important;
	overflow: hidden !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
}
.aimc-root .aimc-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; display: block !important; }
.aimc-root .aimc-hgroup {
	flex: 1 1 auto !important;
	min-width: 0 !important;
	display: flex !important;
	flex-direction: column !important;
	justify-content: center !important;
}
.aimc-root .aimc-header-actions { flex: 0 0 auto !important; }

/* Message text aligns to the correct side based on its own language
   (dir="auto" on each element: English → left, Persian/Arabic → right). */
.aimc-root .aimc-msg,
.aimc-root .aimc-invite,
.aimc-root .aimc-notice { text-align: start !important; }

/* Composer: send button on the leading (left) side, input on the right, both
   vertically centered. direction:ltr + row-reverse keeps the send button on
   the left regardless of the host theme's direction. */
.aimc-root .aimc-composer {
	display: flex !important;
	flex-direction: row-reverse !important;
	direction: ltr !important;
	align-items: center !important;
	flex-wrap: nowrap !important;
	gap: 8px !important;
}

/* Input: fixed single-line height so the placeholder/text is vertically
   centered (overrides themes that force a tall textarea). */
.aimc-root .aimc-input {
	flex: 1 1 auto !important;
	height: 44px !important;
	min-height: 44px !important;
	max-height: 44px !important;
	padding: 12px 14px !important;
	line-height: 20px !important;
	overflow-y: auto !important;
	resize: none !important;
	box-sizing: border-box !important;
}
