/* Triterra Bot widget — RTL, brand palette (#4a7c59), Alef. */
#tbot-root {
	--tbot-green: #4a7c59;
	--tbot-green-dark: #2d5016;
	--tbot-cream: #F4F5E9;
	--tbot-ink: #2f4f38;
	font-family: 'Alef', sans-serif;
	direction: rtl;
}

#tbot-root * { box-sizing: border-box; }

/* Floating bubble — WhatsApp-style avatar of Shlomi (image carries its own green ring). */
.tbot-bubble {
	position: fixed;
	bottom: 22px;
	left: 22px;
	right: auto;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	background: url('tbot-avatar.png') center / cover no-repeat;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
	z-index: 99998;
	transition: transform 0.18s ease, opacity 0.18s ease;
}
.tbot-bubble:hover { transform: scale(1.06); }
.tbot-hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

/* Contextual quiet opener — sits just above the launcher, left side. */
.tbot-opener {
	position: fixed;
	bottom: 92px;
	left: 22px;
	right: auto;
	max-width: 240px;
	background: #fff;
	color: var(--tbot-ink);
	padding: 11px 15px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.45;
	box-shadow: 0 6px 18px rgba(45, 80, 22, 0.18);
	cursor: pointer;
	z-index: 99998;
	border: 1px solid rgba(74, 124, 89, 0.18);
	transform-origin: bottom left;
	animation: tbot-opener-pop 0.28s ease-out;
}
/* Comic speech tail pointing down toward the avatar. */
.tbot-opener::after {
	content: '';
	position: absolute;
	left: 20px;
	bottom: -7px;
	width: 14px;
	height: 14px;
	background: #fff;
	border-right: 1px solid rgba(74, 124, 89, 0.18);
	border-bottom: 1px solid rgba(74, 124, 89, 0.18);
	transform: rotate(45deg);
}
@keyframes tbot-opener-pop {
	from { opacity: 0; transform: translateY(8px) scale(0.94); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel — opens from the bottom-left corner. */
.tbot-panel {
	position: fixed;
	bottom: 22px;
	left: 22px;
	right: auto;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 44px);
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 18px 48px rgba(45, 80, 22, 0.26);
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 99999;
}
.tbot-panel.tbot-open { display: flex; }

.tbot-head {
	background: var(--tbot-green);
	color: #fff;
	padding: 14px 16px;
	font-size: 16px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.tbot-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	line-height: 1;
}

.tbot-log {
	flex: 1;
	min-height: 0; /* CRITICAL: without this a flex:1 column child won't shrink below
	                  its content height, so overflow-y never engages and the panel
	                  clips the bottom. This is what made scroll fail on mobile+desktop. */
	overflow-y: auto;
	-webkit-overflow-scrolling: touch; /* momentum scroll on iOS */
	overscroll-behavior: contain;      /* don't chain scroll to the page behind */
	padding: 14px;
	background: var(--tbot-cream);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.tbot-msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.5;
	word-wrap: break-word;
}
.tbot-user {
	align-self: flex-start;
	background: var(--tbot-green);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.tbot-assistant {
	align-self: flex-end;
	background: #fff;
	color: var(--tbot-ink);
	border: 1px solid rgba(74, 124, 89, 0.16);
	border-bottom-left-radius: 4px;
}
.tbot-msg a { color: inherit; text-decoration: underline; }
.tbot-typing { padding: 6px 4px; background: none; box-shadow: none; }
/* Thinking mark — the real Triterra logo as a mask, with a wave of green
   energy flowing through the mycelium and a slow meditative breath. */
.tbot-think {
	width: 46px;
	height: 30px;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
	background: linear-gradient(100deg, #2d5016 0%, #4a7c59 38%, #9ed084 50%, #4a7c59 62%, #2d5016 100%);
	background-size: 260% 100%;
	animation: tbot-think-flow 2.6s ease-in-out infinite, tbot-think-breathe 3.4s ease-in-out infinite;
	transform-origin: center 70%;
}
@keyframes tbot-think-flow { 0% { background-position: 130% 0; } 100% { background-position: -130% 0; } }
@keyframes tbot-think-breathe { 0%, 100% { transform: scale(0.95); opacity: 0.85; } 50% { transform: scale(1.03); opacity: 1; } }
/* While words stream below it, the logo stays alive but smaller. */
.tbot-typing-stream { padding: 2px 4px; }
.tbot-typing-stream .tbot-think { width: 30px; height: 19px; }
/* Wave of motion sweeping over the words as they stream in. */
.tbot-msg.tbot-streaming { position: relative; overflow: hidden; }
.tbot-msg.tbot-streaming::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent 0%, rgba(74, 124, 89, 0.22) 50%, transparent 100%);
	transform: translateX(-100%);
	animation: tbot-wave 1.4s ease-in-out infinite;
	pointer-events: none;
}
@keyframes tbot-wave { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
	.tbot-think, .tbot-msg.tbot-streaming::after { animation: none; }
}

.tbot-cart {
	align-self: flex-end;
	display: flex;
	align-items: center;
	gap: 10px;
	background: #eaf2e6;
	border: 1px solid var(--tbot-green);
	border-radius: 12px;
	padding: 8px 12px;
	font-size: 13.5px;
	color: var(--tbot-green-dark);
}
.tbot-cart-link {
	background: var(--tbot-green);
	color: #fff !important;
	padding: 5px 12px;
	border-radius: 8px;
	text-decoration: none !important;
	font-weight: 700;
	white-space: nowrap;
}
/* Button variant of the cart link (AJAX add) — reset native button styling. */
button.tbot-cart-link {
	border: none;
	cursor: pointer;
	font-family: inherit;
	font-size: inherit;
	line-height: 1.4;
}
button.tbot-cart-link:disabled { opacity: 0.6; cursor: default; }
.tbot-wa { background: #25D366; }

.tbot-turnstile:empty { display: none; }
.tbot-turnstile { padding: 0 14px; }

.tbot-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(74, 124, 89, 0.14);
	background: #fff;
}
.tbot-input textarea {
	flex: 1;
	resize: none;
	border: 1px solid rgba(74, 124, 89, 0.3);
	border-radius: 12px;
	padding: 9px 12px;
	font-family: inherit;
	font-size: 14.5px;
	max-height: 110px;
	outline: none;
}
.tbot-input textarea:focus { border-color: var(--tbot-green); }
#tbot-send {
	background: var(--tbot-green);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Header actions: small WhatsApp button + close, top-left in RTL. */
.tbot-head-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}
.tbot-wa-head {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: #25D366;
	color: #fff;
	cursor: pointer;
	padding: 0;
	transition: background 0.2s ease, transform 0.15s ease;
}
.tbot-wa-head:hover { background: #1ebe5d; transform: scale(1.08); }
/* Paper-plane send icon, mirrored for RTL so it points to the text flow. */
#tbot-send svg { transform: scaleX(-1); display: block; margin: auto; }

@media (max-width: 480px) {
	.tbot-panel {
		left: 0;
		right: auto;
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
	}
}

/*
 * The bot is now the single chat entry point on the left; the floating
 * WhatsApp button is hidden. Click-to-Chat renders its float as .ht-ctc-chat.
 * (Inline WhatsApp buttons inside pages are unaffected.)
 */
.ht-ctc-chat,
#ht-ctc,
.ht-ctc { display: none !important; }

/* When the chat panel is open, the floating side-cart overlaps the input row.
   The bot flags <body> with .tbot-panel-open; hide the cart while open (all widths). */
body.tbot-panel-open .xoo-wsc-basket { display: none !important; }
