/* Bale Callback Widget — all rules are scoped under #bcw-root */

#bcw-root,
#bcw-root *,
#bcw-root *::before,
#bcw-root *::after {
	box-sizing: border-box;
}

#bcw-root {
	position: fixed;
	left: var(--bcw-left, 20px);
	bottom: var(--bcw-bottom, 20px);
	z-index: 99990;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	margin: 0;
	padding: 0;
	direction: ltr;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.7;
	color: #1f2937;
	text-align: right;
	-webkit-text-size-adjust: 100%;
}

#bcw-root [hidden] {
	display: none !important;
}

/* Reset theme button styles */
#bcw-root button {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	text-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	font: inherit;
	line-height: 1.4;
	color: inherit;
	cursor: pointer;
	min-width: 0;
	min-height: 0;
	width: auto;
	height: auto;
}

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

#bcw-root .bcw-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--bcw-color, #0f766e);
	color: var(--bcw-on-color, #fff);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#bcw-root .bcw-launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

#bcw-root .bcw-launcher:focus-visible,
#bcw-root .bcw-close:focus-visible,
#bcw-root .bcw-send:focus-visible,
#bcw-root .bcw-teaser-text:focus-visible,
#bcw-root .bcw-teaser-close:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.6);
	outline-offset: 2px;
}

#bcw-root .bcw-launcher::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--bcw-color, #0f766e);
	pointer-events: none;
	animation: bcw-pulse 2.2s ease-out infinite;
}

#bcw-root.is-open .bcw-launcher::after {
	display: none;
}

#bcw-root .bcw-launcher svg {
	display: block;
	width: 28px;
	height: 28px;
}

#bcw-root .bcw-launcher .bcw-ico-close {
	display: none;
}

#bcw-root.is-open .bcw-launcher .bcw-ico-open {
	display: none;
}

#bcw-root.is-open .bcw-launcher .bcw-ico-close {
	display: block;
}

@keyframes bcw-pulse {
	0% {
		transform: scale(1);
		opacity: 0.55;
	}
	100% {
		transform: scale(1.6);
		opacity: 0;
	}
}

/* ---------- Teaser bubble ---------- */

#bcw-root .bcw-teaser {
	position: relative;
	display: flex;
	align-items: center;
	max-width: 260px;
	margin-left: 0;
	padding: 4px 6px 4px 4px;
	direction: rtl;
	background: #fff;
	color: #1f2937;
	border-radius: 14px;
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
	animation: bcw-fade-up 0.35s ease both;
}

#bcw-root .bcw-teaser::after {
	content: "";
	position: absolute;
	left: 23px;
	bottom: -6px;
	width: 14px;
	height: 14px;
	background: #fff;
	transform: rotate(45deg);
	border-radius: 2px;
}

#bcw-root .bcw-teaser-text {
	padding: 6px 12px;
	text-align: right;
	font-weight: 600;
}

#bcw-root .bcw-teaser-close {
	flex: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	font-size: 18px;
	line-height: 22px;
	text-align: center;
	color: #6b7280;
}

#bcw-root .bcw-teaser-close:hover {
	background: #f3f4f6;
}

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

#bcw-root .bcw-panel {
	display: flex;
	flex-direction: column;
	width: 340px;
	max-width: calc(100vw - (var(--bcw-left, 20px) * 2));
	direction: rtl;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
	overflow: hidden;
	transform-origin: bottom left;
	animation: bcw-pop 0.22s ease both;
}

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

@keyframes bcw-fade-up {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

#bcw-root .bcw-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--bcw-color, #0f766e);
	color: var(--bcw-on-color, #fff);
}

#bcw-root .bcw-avatar {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
}

#bcw-root .bcw-avatar svg {
	display: block;
	width: 20px;
	height: 20px;
}

#bcw-root .bcw-head-text {
	flex: 1;
	min-width: 0;
}

#bcw-root .bcw-head-title {
	display: block;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.5;
}

#bcw-root .bcw-head-sub {
	display: block;
	font-size: 12px;
	opacity: 0.9;
	line-height: 1.5;
}

#bcw-root .bcw-close {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	color: inherit;
}

#bcw-root .bcw-close:hover {
	background: rgba(255, 255, 255, 0.2);
}

#bcw-root .bcw-close svg {
	display: block;
	width: 18px;
	height: 18px;
}

#bcw-root .bcw-body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 130px;
	max-height: 300px;
	padding: 14px;
	overflow-y: auto;
	background: #f5f7fb;
}

#bcw-root .bcw-msg {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	animation: bcw-fade-up 0.25s ease both;
	white-space: pre-line;
}

#bcw-root .bcw-msg--bot {
	align-self: flex-start;
	background: #fff;
	color: #1f2937;
	border: 1px solid #e5e7eb;
	border-top-right-radius: 4px;
}

#bcw-root .bcw-msg--user {
	align-self: flex-end;
	background: var(--bcw-color, #0f766e);
	color: var(--bcw-on-color, #fff);
	border-top-left-radius: 4px;
}

#bcw-root .bcw-msg--error {
	align-self: flex-start;
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
	border-top-right-radius: 4px;
}

#bcw-root .bcw-typing {
	display: inline-flex;
	gap: 4px;
	padding: 12px 14px;
}

#bcw-root .bcw-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9ca3af;
	animation: bcw-dot 1.1s infinite ease-in-out;
}

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

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

@keyframes bcw-dot {
	0%,
	80%,
	100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* ---------- Form ---------- */

#bcw-root .bcw-form {
	display: block;
	margin: 0;
	padding: 10px 12px 12px;
	background: #fff;
	border-top: 1px solid #eef0f4;
}

#bcw-root .bcw-row {
	display: flex;
	gap: 8px;
}

#bcw-root .bcw-input {
	flex: 1;
	min-width: 0;
	height: 42px;
	margin: 0;
	padding: 0 12px;
	direction: ltr;
	text-align: left;
	font: inherit;
	font-size: 16px; /* prevents iOS zoom on focus */
	color: #111827;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	box-shadow: none;
	outline: none;
}

#bcw-root .bcw-input:focus {
	border-color: var(--bcw-color, #0f766e);
	box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

#bcw-root .bcw-input::placeholder {
	color: #9ca3af;
}

#bcw-root .bcw-send {
	flex: none;
	height: 42px;
	padding: 0 18px;
	border-radius: 10px;
	background: var(--bcw-color, #0f766e);
	color: var(--bcw-on-color, #fff);
	font-weight: 700;
	transition: opacity 0.2s ease;
}

#bcw-root .bcw-send:hover {
	opacity: 0.9;
}

#bcw-root .bcw-send:disabled,
#bcw-root .bcw-input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

#bcw-root .bcw-error {
	margin: 6px 2px 0;
	min-height: 0;
	font-size: 12.5px;
	color: #b91c1c;
}

/* Honeypot: off-screen, not display:none (so naive bots still fill it) */
#bcw-root .bcw-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
	#bcw-root {
		bottom: calc(var(--bcw-bottom, 20px) + env(safe-area-inset-bottom, 0px));
	}

	#bcw-root .bcw-panel {
		width: calc(100vw - (var(--bcw-left, 20px) * 2));
	}

	#bcw-root .bcw-body {
		max-height: 38vh;
	}

	#bcw-root .bcw-launcher {
		width: 54px;
		height: 54px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#bcw-root *,
	#bcw-root *::before,
	#bcw-root *::after {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	#bcw-root {
		display: none !important;
	}
}
