/* AI Nexus chat — override --ainx-accent in your theme to change the colour. */
.ainx-chat {
	--ainx-accent: #2563eb;
	--ainx-accent-dark: #1d4ed8;
	--ainx-border: #e2e8f0;
	--ainx-bg: #f8fafc;
	--ainx-text: #1e293b;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	direction: rtl;
	text-align: right;
	font-family: inherit;
	color: var(--ainx-text);
	background: #fff;
}
.ainx-chat *, .ainx-chat *::before, .ainx-chat *::after { box-sizing: border-box; }

.ainx-inline-chat {
	max-width: 760px;
	margin: 24px auto;
	border: 1px solid var(--ainx-border);
	border-radius: 18px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .05);
	overflow: hidden;
}
.ainx-inline-chat .ainx-chat__messages { height: 420px; }

.ainx-chat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background: #0f172a;
	color: #fff;
}
.ainx-chat__title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.ainx-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }
.ainx-chat__close {
	background: transparent;
	border: 0;
	color: #cbd5e1;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 6px 8px;
	border-radius: 6px;
}
.ainx-chat__close:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.ainx-chat__messages {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
	background: var(--ainx-bg);
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}
.ainx-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.8;
	overflow-wrap: anywhere;
}
.ainx-msg--assistant { align-self: flex-start; background: #fff; border: 1px solid var(--ainx-border); border-top-right-radius: 4px; }
.ainx-msg--user { align-self: flex-end; background: var(--ainx-accent); color: #fff; border-top-left-radius: 4px; }
.ainx-msg--thinking { color: #64748b; background: #f1f5f9; }
.ainx-msg--error { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.ainx-msg code { background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; font-size: 13px; direction: ltr; unicode-bidi: isolate; }
.ainx-msg a { color: inherit; text-decoration: underline; }
.ainx-sources {
	margin-top: 10px;
	padding-top: 8px;
	border-top: 1px dashed var(--ainx-border);
	font-size: 12px;
	color: #64748b;
}
.ainx-sources-title {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	color: #475569;
}
.ainx-sources-links {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.ainx-sources a.ainx-source-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #f1f5f9;
	color: var(--ainx-accent);
	padding: 4px 10px;
	border-radius: 8px;
	text-decoration: none;
	font-size: 12px;
	border: 1px solid var(--ainx-border);
	transition: background .15s, border-color .15s;
}
.ainx-sources a.ainx-source-link:hover {
	background: #e2e8f0;
	border-color: #cbd5e1;
	text-decoration: none;
}

.ainx-chat__form { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--ainx-border); }
.ainx-chat textarea {
	flex: 1;
	resize: none;
	min-height: 44px;
	max-height: 120px;
	margin: 0;
	border: 1px solid #cbd5e1;
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	font-size: 16px; /* prevents iOS zoom on focus */
	background: #fff;
	color: var(--ainx-text);
}
.ainx-chat textarea:focus { outline: none; border-color: var(--ainx-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.ainx-chat button[type="submit"] {
	border: 0;
	border-radius: 12px;
	padding: 0 18px;
	background: var(--ainx-accent);
	color: #fff;
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}
.ainx-chat button[type="submit"]:hover { background: var(--ainx-accent-dark); }
.ainx-chat button[type="submit"]:disabled { opacity: .6; cursor: not-allowed; }
.ainx-chat button:focus-visible, .ainx-floating-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.ainx-chat .screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Floating widget — configurable position to avoid overlap with contact buttons */
.ainx-floating-container {
	position: fixed;
	bottom: var(--ainx-pos-bottom, 24px);
	left: var(--ainx-pos-left, 24px);
	right: var(--ainx-pos-right, auto);
	z-index: 999999;
	transition: bottom .25s ease-out, transform .2s ease;
}
.ainx-floating-container.ainx-pos-right,
.ainx-floating-container--bottom-right {
	left: auto !important;
	right: var(--ainx-pos-right, 24px) !important;
}
.ainx-floating-container.ainx-pos-right .ainx-floating-window,
.ainx-floating-container--bottom-right .ainx-floating-window {
	left: auto;
	right: 0;
}
.ainx-floating-container.ainx-pos-high,
.ainx-floating-container--bottom-left-high {
	bottom: var(--ainx-pos-bottom-high, 96px) !important;
}
.ainx-floating-container--bottom-right-high {
	left: auto !important;
	right: var(--ainx-pos-right, 24px) !important;
	bottom: var(--ainx-pos-bottom-high, 96px) !important;
}
.ainx-floating-container--bottom-right-high .ainx-floating-window {
	left: auto;
	right: 0;
}

.ainx-floating-btn {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: 0;
	background: #2563eb;
	color: #fff;
	font-size: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
	transition: transform .2s;
}
.ainx-floating-btn:hover { transform: scale(1.06); }
.ainx-chat-icon.close { display: none; font-size: 20px; }
.ainx-floating-btn[aria-expanded="true"] .ainx-chat-icon.open { display: none; }
.ainx-floating-btn[aria-expanded="true"] .ainx-chat-icon.close { display: block; }
.ainx-floating-window {
	position: absolute;
	bottom: 72px;
	left: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 120px);
	border-radius: 18px;
	overflow: hidden;
	border: 1px solid var(--ainx-border, #e2e8f0);
	box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
	animation: ainxUp .2s ease-out;
}
.ainx-floating-window[hidden] { display: none; }
.ainx-chat--floating { height: 100%; }

@keyframes ainxUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ainx-floating-window, .ainx-floating-btn { animation: none; transition: none; } }
@media (max-width: 600px) {
	.ainx-floating-container { bottom: var(--ainx-pos-bottom-mobile, 16px); left: var(--ainx-pos-left-mobile, 16px); }
	.ainx-floating-container.ainx-pos-right,
	.ainx-floating-container--bottom-right { left: auto !important; right: var(--ainx-pos-right-mobile, 16px) !important; }
	.ainx-floating-window { width: calc(100vw - 32px); height: 75vh; bottom: 68px; }
}
