/*
 * ApexNex AI Chat — front-end widget styles.
 * Brand colours come from --anc-primary / --anc-accent set by the plugin.
 */

.anc-root,
.anc-root * {
	box-sizing: border-box;
}

.anc-root {
	--anc-primary: #0b63f6;
	--anc-accent: #00c2a8;
	--anc-radius: 22px;
	--anc-surface: #ffffff;
	--anc-text: #0f172a;
	--anc-muted: #64748b;
	--anc-line: #e6eaf1;
	--anc-bot-bg: #ffffff;
	--anc-grad: linear-gradient(135deg, var(--anc-primary) 0%, var(--anc-accent) 100%);
	position: fixed;
	bottom: 22px;
	max-width: calc(100vw - 28px);
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--anc-text);
	-webkit-font-smoothing: antialiased;
}

.anc-root.anc-right {
	right: 22px;
	align-items: flex-end;
}

.anc-root.anc-left {
	left: 22px;
	align-items: flex-start;
}

.anc-root.anc-hidden {
	display: none !important;
}

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

.anc-launcher-wrap {
	position: relative;
	display: inline-flex;
}

.anc-pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--anc-grad);
	pointer-events: none;
	animation: anc-pulse 2.6s ease-out infinite;
}

@keyframes anc-pulse {
	0% {
		transform: scale(1);
		opacity: 0.45;
	}
	70% {
		transform: scale(1.55);
		opacity: 0;
	}
	100% {
		transform: scale(1.55);
		opacity: 0;
	}
}

/*
 * Theme guard.
 *
 * A widget lives inside somebody else's theme. Elementor's global "kit" style
 * (".elementor-kit-9 button { border-radius: 7px; ... }", specificity 0,1,1)
 * and the theme reset ("button { padding: .5rem 1rem; border: 1px solid ... }",
 * loaded AFTER this file) are more specific than a bare ".anc-launcher", so
 * they used to turn the round launcher into a 7px-radius square with 16px side
 * padding, and did the same to the send button and the message box.
 *
 * Adding ".anc-root" at the front raises every control selector below to
 * specificity 0,2,0 - higher than the theme's - so the widget renders the same
 * no matter which theme or page builder the site uses.
 */
.anc-root .anc-launcher {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	border: 0;
	cursor: pointer;
	padding: 0;
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: var(--anc-grad);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	box-shadow: 0 16px 32px -10px rgba(11, 99, 246, 0.65), 0 6px 14px -6px rgba(15, 23, 42, 0.3);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	animation: anc-in 0.3s ease-out both;
}

@keyframes anc-in {
	from {
		opacity: 0;
		transform: scale(0.6);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.anc-root .anc-launcher:hover {
	transform: translateY(-3px) scale(1.045);
	box-shadow: 0 22px 40px -12px rgba(11, 99, 246, 0.7), 0 8px 18px -6px rgba(15, 23, 42, 0.35);
}

.anc-root .anc-launcher:active {
	transform: translateY(-1px) scale(1);
}

.anc-root .anc-launcher:focus-visible {
	outline: 3px solid rgba(11, 99, 246, 0.45);
	outline-offset: 3px;
}

.anc-root .anc-launcher-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
}

.anc-root .anc-launcher-icon svg {
	width: 32px;
	height: 32px;
	fill: currentColor;
}

/*
 * Floating "Chat with us" pill above the launcher button. It points at the
 * bot, and hides itself while the panel is open because the header already
 * names the chat.
 */
.anc-root .anc-launcher-label {
	position: absolute;
	right: 2px;
	bottom: calc(100% + 20px);
	z-index: 0;
	max-width: min(70vw, 240px);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	padding: 9px 14px;
	border-radius: 999px;
	background: #fff;
	color: var(--anc-text);
	border: 1px solid var(--anc-line);
	box-shadow: 0 14px 28px -16px rgba(15, 23, 42, 0.5), 0 3px 8px rgba(15, 23, 42, 0.08);
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
	animation: anc-label-in 0.45s ease-out 0.5s both;
}

.anc-root.anc-left .anc-launcher-label {
	right: auto;
	left: 2px;
}

.anc-root.anc-open .anc-launcher-label {
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
}

@keyframes anc-label-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.9);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/*
 * Animated AI bot on the launcher. Pure SVG + CSS: it floats, blinks, wobbles
 * its antenna and "talks", so the button looks alive without shipping a GIF.
 */
.anc-root .anc-launcher-icon svg.anc-bot {
	width: 38px;
	height: 38px;
	overflow: visible;
}

.anc-root .anc-bot-head,
.anc-root .anc-bot-ear,
.anc-root .anc-bot-tip {
	fill: #fff;
}

.anc-root .anc-bot-stem {
	fill: none;
	stroke: #fff;
	stroke-width: 2.2;
	stroke-linecap: round;
}

.anc-root .anc-bot-eye {
	fill: var(--anc-primary);
}

.anc-root .anc-bot-mouth {
	fill: none;
	stroke: var(--anc-primary);
	stroke-width: 2.2;
	stroke-linecap: round;
	transform-box: fill-box;
	transform-origin: 50% 10%;
	animation: anc-bot-talk 1.9s ease-in-out infinite;
}

.anc-root .anc-bot {
	animation: anc-bot-float 3.4s ease-in-out infinite;
}

@keyframes anc-bot-float {
	0%, 100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-1.8px);
	}
}

.anc-root .anc-bot-antenna {
	transform-box: fill-box;
	transform-origin: 50% 100%;
	animation: anc-bot-antenna 2.8s ease-in-out infinite;
}

@keyframes anc-bot-antenna {
	0%, 100% {
		transform: rotate(-8deg);
	}
	50% {
		transform: rotate(8deg);
	}
}

.anc-root .anc-bot-tip {
	transform-box: fill-box;
	transform-origin: 50% 50%;
	animation: anc-bot-tip 2.8s ease-in-out infinite;
}

@keyframes anc-bot-tip {
	0%, 100% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.28);
	}
}

.anc-root .anc-bot-eyes {
	transform-box: fill-box;
	transform-origin: 50% 50%;
	animation: anc-bot-blink 4.6s infinite;
}

@keyframes anc-bot-blink {
	0%, 90%, 100% {
		transform: scaleY(1);
	}
	93%, 95% {
		transform: scaleY(0.12);
	}
}

@keyframes anc-bot-talk {
	0%, 100% {
		transform: scaleY(0.72);
	}
	50% {
		transform: scaleY(1.28);
	}
}

/* Unread badge */
.anc-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	z-index: 2;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: #ef4444;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
	box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
}

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

.anc-panel {
	position: absolute;
	bottom: 84px;
	width: min(384px, calc(100vw - 28px));
	height: min(640px, calc(100vh - 130px));
	background: var(--anc-surface);
	border-radius: var(--anc-radius);
	box-shadow: 0 30px 70px -20px rgba(15, 23, 42, 0.38), 0 8px 24px -12px rgba(15, 23, 42, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: anc-pop 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.anc-root.anc-left .anc-panel {
	transform-origin: bottom left;
}

/*
 * The panel must line up with the launcher's edge. It is absolutely
 * positioned inside .anc-root (which is only as wide as the launcher), so
 * without an explicit side it would overflow the viewport on the right.
 */
.anc-root.anc-right .anc-panel {
	right: 0;
	left: auto;
}

.anc-root.anc-left .anc-panel {
	left: 0;
	right: auto;
}

.anc-panel[hidden] {
	display: none;
}

@keyframes anc-pop {
	from {
		opacity: 0;
		transform: translateY(14px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.anc-header {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	background: var(--anc-grad);
	color: #fff;
	flex: 0 0 auto;
	overflow: hidden;
}

.anc-header::after {
	content: "";
	position: absolute;
	top: -70px;
	right: -40px;
	width: 200px;
	height: 200px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 68%);
	pointer-events: none;
}

.anc-avatar {
	position: relative;
	z-index: 1;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	/* White plate: the AN mark is transparent, so on the blue gradient header
	 * its colours had nothing to sit on and were almost invisible. */
	background: #fff;
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), 0 1px 4px rgba(2, 6, 23, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	font-weight: 700;
	font-size: 16px;
	color: #0b63f6;
	flex: 0 0 auto;
}

.anc-avatar img {
	width: 100%;
	height: 100%;
	/* Show the whole mark instead of cropping it into a circle. */
	object-fit: contain;
	padding: 3px;
	box-sizing: border-box;
}

.anc-head-text {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	min-width: 0;
}

.anc-title {
	font-size: 15.5px;
	font-weight: 700;
	letter-spacing: 0.005em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.anc-subtitle {
	font-size: 12.5px;
	opacity: 0.95;
	display: flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.anc-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #6ee7b7;
	box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.3);
	flex: 0 0 auto;
}

.anc-dot.anc-dot-away {
	background: #fbbf24;
	box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
}

.anc-root .anc-head-btn {
	position: relative;
	z-index: 1;
	background: rgba(255, 255, 255, 0.14);
	border: 0;
	color: #fff;
	cursor: pointer;
	opacity: 0.95;
	padding: 7px;
	border-radius: 10px;
	line-height: 0;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.anc-root .anc-head-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.28);
}

.anc-root .anc-head-btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

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

.anc-messages {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 18px 16px 10px;
	background:
		radial-gradient(1000px 300px at 100% 0%, rgba(11, 99, 246, 0.07), transparent 62%),
		#f6f8fc;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e1 transparent;
}

.anc-messages::-webkit-scrollbar {
	width: 8px;
}

.anc-messages::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 99px;
	border: 2px solid transparent;
	background-clip: padding-box;
}

.anc-messages::-webkit-scrollbar-thumb:hover {
	background: #94a3b8;
	background-clip: padding-box;
}

.anc-row {
	display: flex;
	margin-bottom: 10px;
	gap: 8px;
}

.anc-row.anc-row-user {
	justify-content: flex-end;
}

/*
 * The 82% width cap belongs on this wrapper ("stack"), whose width resolves
 * against the row. Putting max-width on .anc-bubble made it a percentage of a
 * shrink-to-fit parent, which collapsed short messages (e.g. "Hi") to one
 * character per line.
 */
.anc-stack {
	max-width: 82%;
	min-width: 0;
}

/*
 * Brand mark shown beside every message that is not the visitor's. Scoped with
 * .anc-root so theme button/link rules cannot restyle it.
 */
.anc-root .anc-row-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	align-self: flex-start;
	width: 28px;
	height: 28px;
	margin-top: 2px;
	border-radius: 50%;
	background: #fff;
	border: 1px solid var(--anc-line);
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
	overflow: hidden;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	color: #0b63f6;
}

.anc-root .anc-row-avatar img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 1px;
	box-sizing: border-box;
	display: block;
}

/*
 * The visitor's own mark. It starts as a neutral person icon and is repainted
 * with the visitor's initials as soon as the AI learns their name.
 *
 * row-reverse keeps the avatar on the right of the bubble. Because the main
 * axis is therefore flipped, the packing keyword must be flex-start: with
 * "flex-end" the whole row was pushed to the LEFT edge instead of the right
 * one, which put the visitor's messages on the AI's side of the chat.
 */
.anc-root .anc-row.anc-row-user {
	flex-direction: row-reverse;
	justify-content: flex-start;
}

.anc-root .anc-row-avatar-user {
	background: var(--anc-grad);
	border-color: transparent;
	color: #fff;
}

.anc-root .anc-row-avatar-user svg {
	width: 15px;
	height: 15px;
	display: block;
	opacity: 0.9;
}

.anc-bubble {
	max-width: 100%;
	padding: 11px 15px;
	border-radius: 18px;
	font-size: 14.5px;
	line-height: 1.55;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	white-space: normal;
}

.anc-root .anc-bubble a {
	color: inherit;
	text-decoration: underline;
}

.anc-row-bot .anc-bubble {
	background: var(--anc-bot-bg);
	color: var(--anc-text);
	border: 1px solid var(--anc-line);
	border-bottom-left-radius: 7px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.anc-row-user .anc-bubble {
	background: var(--anc-grad);
	color: #fff;
	border: 0;
	border-bottom-right-radius: 7px;
	box-shadow: 0 10px 20px -10px rgba(11, 99, 246, 0.7);
}

.anc-row-agent .anc-bubble {
	background: #ecfdf5;
	color: #065f46;
	border: 1px solid #a7f3d0;
	border-bottom-left-radius: 7px;
}

.anc-meta {
	font-size: 11px;
	color: var(--anc-muted);
	margin-top: 5px;
	padding: 0 4px;
}

.anc-row-user .anc-meta {
	text-align: right;
}

.anc-who {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--anc-accent);
	margin-bottom: 4px;
}

.anc-note {
	text-align: center;
	font-size: 12px;
	color: var(--anc-muted);
	margin: 12px 0;
}

/* Typing indicator */
.anc-typing .anc-bubble {
	display: inline-flex;
	gap: 5px;
	align-items: center;
	padding: 15px 16px;
}

.anc-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: anc-blink 1.2s infinite ease-in-out;
}

.anc-typing i:nth-child(2) {
	animation-delay: 0.15s;
}

.anc-typing i:nth-child(3) {
	animation-delay: 0.3s;
}

/* The human agent's bubble, so the visitor can tell who is answering. */
.anc-typing-agent .anc-bubble {
	background: #ecfdf5;
	border-color: #a7f3d0;
}

.anc-typing-agent i {
	background: #10b981;
}

.anc-typing .anc-who {
	margin-bottom: 3px;
}

@keyframes anc-blink {
	0%, 60%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	30% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* Lead form */
.anc-lead {
	padding: 18px 16px;
	background: #fff;
	border-bottom: 1px solid var(--anc-line);
}

.anc-root .anc-lead h4 {
	margin: 0 0 4px;
	font-size: 15px;
}

.anc-root .anc-lead p {
	margin: 0 0 12px;
	font-size: 13px;
	color: var(--anc-muted);
}

.anc-field {
	margin-bottom: 8px;
}

.anc-root .anc-field input {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--anc-line);
	border-radius: 12px;
	font-size: 14px;
	font-family: inherit;
	color: var(--anc-text);
	background: #f8fafc;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.anc-root .anc-field input:focus {
	outline: none;
	border-color: var(--anc-primary);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(11, 99, 246, 0.14);
}

.anc-lead-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
}

.anc-root .anc-lead-skip {
	background: none;
	border: 0;
	color: var(--anc-muted);
	cursor: pointer;
	font-size: 13px;
	text-decoration: underline;
	padding: 6px;
}

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

.anc-composer {
	flex: 0 0 auto;
	border-top: 1px solid var(--anc-line);
	background: #fff;
	padding: 10px 12px 8px;
}

.anc-composer form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	width: 100%;
}

.anc-root .anc-input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	border: 1px solid var(--anc-line);
	border-radius: 16px;
	padding: 11px 14px;
	font-size: 14.5px;
	font-family: inherit;
	line-height: 1.45;
	max-height: 130px;
	min-height: 46px;
	resize: none;
	color: var(--anc-text);
	background: #f8fafc;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.anc-root .anc-input::placeholder {
	color: #94a3b8;
}

.anc-root .anc-input:focus {
	outline: none;
	border-color: var(--anc-primary);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(11, 99, 246, 0.14);
}

.anc-root .anc-send {
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
	border: 0;
	border-radius: 50%;
	background: var(--anc-grad);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 20px -10px rgba(11, 99, 246, 0.75);
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.anc-root .anc-send:hover {
	transform: translateY(-1px);
	box-shadow: 0 14px 24px -10px rgba(11, 99, 246, 0.85);
}

.anc-root .anc-send:active {
	transform: translateY(0) scale(0.97);
}

.anc-root .anc-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

.anc-root .anc-send svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
	margin-left: -2px;
}

.anc-root .anc-lead-actions .anc-send {
	border-radius: 12px;
	width: auto;
	height: auto;
	padding: 11px 18px;
	font-size: 14px;
	font-weight: 600;
}

.anc-footer {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	text-align: center;
	font-size: 11px;
	color: var(--anc-muted);
	padding: 8px 12px 11px;
	background: #fff;
}

.anc-root .anc-footer a {
	color: var(--anc-muted);
}

/*
 * "End chat" control. Scoped to .anc-root so theme button rules cannot win.
 * Deliberately big: a full-width bar, not the tiny pill it used to be, so a
 * single confident tap is enough and the old "tap again to end" confirm -
 * which visitors kept reading as a broken button - is gone.
 */
.anc-root .anc-end {
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	color: #dc2626;
	background: #fef2f2;
	border: 1.5px solid #fecaca;
	border-radius: 12px;
	padding: 13px 18px;
	width: 100%;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(220, 38, 38, 0.06);
	transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.anc-root .anc-end:hover,
.anc-root .anc-end:focus-visible {
	color: #fff;
	background: #dc2626;
	border-color: #dc2626;
	box-shadow: 0 10px 20px -10px rgba(220, 38, 38, 0.7);
	outline: none;
}

.anc-root .anc-end:active {
	transform: scale(0.985);
}

.anc-root .anc-end:disabled {
	opacity: 0.6;
	cursor: wait;
	transform: none;
}

.anc-powered {
	flex: 0 0 auto;
}

@media (max-width: 480px) {
	.anc-root {
		bottom: 14px;
	}

	.anc-root.anc-right {
		right: 14px;
	}

	.anc-root.anc-left {
		left: 14px;
	}

	/* Full-screen panel. The left/right overrides above must not win here,
	   so the same specific selectors are repeated in this later block. */
	.anc-root .anc-panel,
	.anc-root.anc-right .anc-panel,
	.anc-root.anc-left .anc-panel {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		border-radius: 0;
	}

	.anc-stack {
		max-width: 88%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.anc-panel,
	.anc-launcher,
	.anc-launcher-label,
	.anc-pulse,
	.anc-bot,
	.anc-bot-antenna,
	.anc-bot-tip,
	.anc-bot-eyes,
	.anc-bot-mouth {
		animation: none;
		transition: none;
	}
}

.anc-screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
