/* CyberneticsNexa Chatbot – front-end styles
   Every selector is prefixed with .cnx-root so theme CSS cannot leak in. */

.cnx-root {
	--cnx-primary: #2563eb;
	--cnx-primary-rgb: 37, 99, 235;
	--cnx-secondary: #06b6d4;
	--cnx-header: #0b1020;
	--cnx-launcher-bg: #0b1020;
	--cnx-launcher-text: #ffffff;
	--cnx-send: #0b1020;
	--cnx-x: 24px;
	--cnx-y: 24px;
	--cnx-w: 370px;
	--cnx-z: 99999;
	--cnx-launcher-h: 52px;
	--cnx-surface: #eef2f7;
	--cnx-line: #dfe5ee;
	--cnx-ink: #0f172a;

	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--cnx-ink);
}

.cnx-root.cnx-style-icon { --cnx-launcher-h: 60px; }

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

.cnx-root button,
.cnx-root input,
.cnx-root a {
	font-family: inherit;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	text-decoration: none;
}

.cnx-root svg { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------ Placement */

.cnx-root .cnx-launcher,
.cnx-root .cnx-window { position: fixed; z-index: var(--cnx-z); }

.cnx-root.cnx-pos-bottom-right .cnx-launcher { right: var(--cnx-x); bottom: var(--cnx-y); }
.cnx-root.cnx-pos-bottom-right .cnx-window   { right: var(--cnx-x); bottom: calc(var(--cnx-y) + var(--cnx-launcher-h) + 14px); transform-origin: bottom right; }

.cnx-root.cnx-pos-bottom-left .cnx-launcher  { left: var(--cnx-x); bottom: var(--cnx-y); }
.cnx-root.cnx-pos-bottom-left .cnx-window    { left: var(--cnx-x); bottom: calc(var(--cnx-y) + var(--cnx-launcher-h) + 14px); transform-origin: bottom left; }

.cnx-root.cnx-pos-top-right .cnx-launcher    { right: var(--cnx-x); top: var(--cnx-y); }
.cnx-root.cnx-pos-top-right .cnx-window      { right: var(--cnx-x); top: calc(var(--cnx-y) + var(--cnx-launcher-h) + 14px); transform-origin: top right; }

.cnx-root.cnx-pos-top-left .cnx-launcher     { left: var(--cnx-x); top: var(--cnx-y); }
.cnx-root.cnx-pos-top-left .cnx-window       { left: var(--cnx-x); top: calc(var(--cnx-y) + var(--cnx-launcher-h) + 14px); transform-origin: top left; }

.admin-bar .cnx-root.cnx-pos-top-right .cnx-launcher,
.admin-bar .cnx-root.cnx-pos-top-left .cnx-launcher { top: calc(var(--cnx-y) + 32px); }
.admin-bar .cnx-root.cnx-pos-top-right .cnx-window,
.admin-bar .cnx-root.cnx-pos-top-left .cnx-window { top: calc(var(--cnx-y) + var(--cnx-launcher-h) + 46px); }

/* ------------------------------------------------------------ Popup window */

.cnx-root .cnx-window {
	display: flex;
	flex-direction: column;
	width: var(--cnx-w);
	max-width: calc(100vw - 24px);
	max-height: calc(100vh - var(--cnx-y) - var(--cnx-launcher-h) - 40px);
	background: #fff;
	border-radius: 22px;
	overflow: hidden;
	box-shadow: 0 28px 64px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .12);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(14px) scale(.96);
	transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.cnx-root.cnx-pos-top-right .cnx-window,
.cnx-root.cnx-pos-top-left .cnx-window { transform: translateY(-14px) scale(.96); }

.cnx-root.cnx-open .cnx-window {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: none;
	transition: opacity .22s ease, transform .22s ease, visibility 0s;
}

/* Header */
.cnx-root .cnx-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 16px 18px;
	background: var(--cnx-header);
	color: #fff;
}

.cnx-root .cnx-avatar {
	position: relative;
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: rgba(255, 255, 255, .08);
}
.cnx-root .cnx-avatar img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 12px;
	object-fit: contain;
	margin: 0;
	padding: 0;
	border: 0;
}
.cnx-root .cnx-online {
	position: absolute;
	right: -3px;
	bottom: -3px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #22c55e;
	border: 2px solid var(--cnx-header);
}

.cnx-root .cnx-head-text { flex: 1 1 auto; min-width: 0; }
.cnx-root .cnx-title  { font-size: 16px; font-weight: 600; line-height: 1.25; color: #fff; }
.cnx-root .cnx-slogan { margin-top: 2px; font-size: 13px; line-height: 1.3; color: #9aa6b8; }

.cnx-root .cnx-close {
	flex: 0 0 34px;
	width: 34px;
	height: 34px;
	padding: 8px;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #cbd5e1;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.cnx-root .cnx-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* Messages */
.cnx-root .cnx-messages {
	flex: 1 1 auto;
	min-height: 150px;
	max-height: 340px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 18px 18px 8px;
	background: var(--cnx-surface);
	scroll-behavior: smooth;
}

.cnx-root .cnx-msg {
	max-width: 88%;
	padding: 13px 16px;
	border-radius: 18px;
	font-size: 15.5px;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	animation: cnx-in .25s ease both;
}
.cnx-root .cnx-msg.cnx-bot {
	align-self: flex-start;
	background: #fff;
	color: var(--cnx-ink);
	border: 1px solid var(--cnx-line);
	border-bottom-left-radius: 6px;
}
.cnx-root .cnx-msg.cnx-user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--cnx-primary), var(--cnx-secondary));
	color: #fff;
	border-bottom-right-radius: 6px;
}
.cnx-root .cnx-msg a:not(.cnx-action) { color: var(--cnx-primary); text-decoration: underline; }

.cnx-root .cnx-action {
	display: inline-block;
	margin-top: 10px;
	padding: 8px 16px;
	border-radius: 999px;
	background: var(--cnx-header);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	white-space: normal;
	transition: transform .15s, opacity .15s;
}
.cnx-root .cnx-action:hover { opacity: .9; transform: translateY(-1px); color: #fff; }
.cnx-root .cnx-action.cnx-wa { background: #16a34a; }

/* Typing indicator */
.cnx-root .cnx-typing { display: flex; gap: 5px; align-items: center; padding: 16px 18px; width: 64px; }
.cnx-root .cnx-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #94a3b8;
	animation: cnx-dots 1.1s infinite ease-in-out;
}
.cnx-root .cnx-typing span:nth-child(2) { animation-delay: .15s; }
.cnx-root .cnx-typing span:nth-child(3) { animation-delay: .3s; }

/* Chips */
.cnx-root .cnx-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-height: 132px;
	overflow-y: auto;
	padding: 6px 18px 16px;
	background: var(--cnx-surface);
}
.cnx-root .cnx-chips:empty { display: none; }

.cnx-root .cnx-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 8px 18px;
	border: 1px solid var(--cnx-line);
	border-radius: 999px;
	background: #fff;
	color: #1e293b;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: none;
	transition: border-color .15s, color .15s, transform .15s;
}
.cnx-root .cnx-chip:hover { border-color: var(--cnx-primary); color: var(--cnx-primary); transform: translateY(-1px); }
.cnx-root .cnx-chip.cnx-chip-wa { border-color: #86efac; color: #15803d; }
.cnx-root .cnx-chip.cnx-chip-wa:hover { background: #f0fdf4; border-color: #22c55e; color: #15803d; }
.cnx-root .cnx-chip svg { width: 16px; height: 16px; flex: 0 0 16px; }

/* Input */
.cnx-root .cnx-form {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 14px 18px;
	background: #fff;
	border-top: 1px solid #e5e9f0;
}
.cnx-root .cnx-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0 18px;
	border: 1px solid #d5dbe5;
	border-radius: 999px;
	background: #fff;
	color: var(--cnx-ink);
	font-size: 15px;
	box-shadow: none;
	outline: 0;
	transition: border-color .15s, box-shadow .15s;
}
.cnx-root .cnx-input::placeholder { color: #8a94a6; opacity: 1; }
.cnx-root .cnx-input:focus { border-color: var(--cnx-primary); box-shadow: 0 0 0 3px rgba(var(--cnx-primary-rgb), .18); }

.cnx-root .cnx-send {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 12px;
	border: 0;
	border-radius: 50%;
	background: var(--cnx-send);
	color: #fff;
	cursor: pointer;
	transition: transform .15s, opacity .15s;
}
.cnx-root .cnx-send:hover { transform: scale(1.06); }

/* Keyboard focus */
.cnx-root .cnx-launcher:focus-visible,
.cnx-root .cnx-close:focus-visible,
.cnx-root .cnx-chip:focus-visible,
.cnx-root .cnx-send:focus-visible,
.cnx-root .cnx-action:focus-visible { outline: 3px solid rgba(var(--cnx-primary-rgb), .55); outline-offset: 2px; }

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

.cnx-root .cnx-launcher {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	height: var(--cnx-launcher-h);
	margin: 0;
	padding: 0 26px;
	border: 0;
	border-radius: 999px;
	background: var(--cnx-launcher-bg);
	color: var(--cnx-launcher-text);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 0 0 rgba(var(--cnx-primary-rgb), 0);
	transition: transform .18s ease, filter .18s ease;
}
.cnx-root .cnx-launcher:hover { transform: translateY(-2px); filter: brightness(1.12); }

.cnx-root.cnx-style-icon .cnx-launcher { width: var(--cnx-launcher-h); padding: 0; }

.cnx-root .cnx-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: 0 0 10px; }
.cnx-root .cnx-launcher-svg { display: block; width: 24px; height: 24px; flex: 0 0 24px; }
.cnx-root.cnx-style-icon .cnx-launcher-svg { width: 28px; height: 28px; flex-basis: 28px; }
.cnx-root .cnx-launcher-img { display: block; width: 26px; height: 26px; border-radius: 8px; object-fit: contain; margin: 0; }
.cnx-root.cnx-style-icon .cnx-launcher-img { width: 32px; height: 32px; border-radius: 10px; }

/* "Online" badge */
.cnx-root .cnx-badge {
	position: absolute;
	top: -1px;
	right: -1px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #22c55e;
	border: 2px solid #fff;
}
.cnx-root .cnx-badge::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: 50%;
	border: 2px solid #22c55e;
	animation: cnx-ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
.cnx-root.cnx-style-pill .cnx-badge { top: -3px; right: 10px; }

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

.cnx-root.cnx-anim-pulse:not(.cnx-open)  .cnx-launcher { animation: cnx-pulse 2.2s ease-out infinite; }
.cnx-root.cnx-anim-bounce:not(.cnx-open) .cnx-launcher { animation: cnx-bounce 3s ease-in-out infinite; }
.cnx-root.cnx-anim-wiggle:not(.cnx-open) .cnx-launcher { animation: cnx-wiggle 3.6s ease-in-out infinite; transform-origin: 50% 60%; }
.cnx-root.cnx-anim-glow:not(.cnx-open)   .cnx-launcher { animation: cnx-glow 2.4s ease-in-out infinite; }
.cnx-root.cnx-anim-float:not(.cnx-open)  .cnx-launcher { animation: cnx-float 3.4s ease-in-out infinite; }

@keyframes cnx-pulse {
	0%   { box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 0 0 rgba(var(--cnx-primary-rgb), .55); }
	70%  { box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 0 18px rgba(var(--cnx-primary-rgb), 0); }
	100% { box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 0 0 rgba(var(--cnx-primary-rgb), 0); }
}
@keyframes cnx-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	68% { transform: translateY(-14px); }
	76% { transform: translateY(0); }
	84% { transform: translateY(-7px); }
	92% { transform: translateY(0); }
}
@keyframes cnx-wiggle {
	0%, 70%, 100% { transform: rotate(0); }
	74% { transform: rotate(-8deg); }
	78% { transform: rotate(7deg); }
	82% { transform: rotate(-6deg); }
	86% { transform: rotate(5deg); }
	90% { transform: rotate(-3deg); }
	94% { transform: rotate(0); }
}
@keyframes cnx-glow {
	0%, 100% { box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 6px 0 rgba(var(--cnx-primary-rgb), .35); }
	50%      { box-shadow: 0 10px 28px rgba(15, 23, 42, .28), 0 0 26px 6px rgba(var(--cnx-primary-rgb), .75); }
}
@keyframes cnx-float {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-8px); }
}
@keyframes cnx-ping {
	0%   { transform: scale(1); opacity: .9; }
	80%, 100% { transform: scale(2.1); opacity: 0; }
}
@keyframes cnx-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}
@keyframes cnx-dots {
	0%, 80%, 100% { transform: translateY(0); opacity: .5; }
	40%           { transform: translateY(-4px); opacity: 1; }
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 600px) {
	.cnx-root.cnx-hide-mobile { display: none !important; }

	.cnx-root .cnx-window {
		left: 12px !important;
		right: 12px !important;
		width: auto;
		max-width: none;
	}
	.cnx-root .cnx-messages { max-height: 44vh; }
}

@media (prefers-reduced-motion: reduce) {
	.cnx-root *,
	.cnx-root *::before,
	.cnx-root *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
