/* Xcape Chat widget styles. RTL-first, logical properties, brand palette. */

.xchat-root {
	--xchat-red: #ec2127;
	--xchat-red-dark: #c4181d;
	--xchat-dark: #1c1d1a;
	--xchat-bg: #ffffff;
	--xchat-bubble-user: #fdeaea;
	--xchat-bubble-bot: #f1f1f2;
	--xchat-text: #1c1d1a;
	--xchat-offset: 90px;
	position: fixed;
	bottom: var(--xchat-offset);
	/* Above every other float on the site (WhatsApp is 9999999,
	   accessibility widgets go higher still) - the chat always wins. */
	z-index: 2147483000;
	font-family: inherit;
	direction: rtl;
}

.xchat-side-left  { left: 20px; }
.xchat-side-right { right: 20px; }

/* Anchor the panel to the same physical side as the launcher. */
.xchat-side-left  .xchat-panel { left: 0; }
.xchat-side-right .xchat-panel { right: 0; }

/* ------------------------------------------------- caption and teaser -- */
.xchat-caption {
	position: absolute;
	bottom: calc(100% + 6px);
	background: var(--xchat-dark);
	color: #fff;
	/* Per Yafit (31.08): bigger than the avatar it sits above - it is the
	   line people actually read before they tap. */
	font-size: 20px;
	line-height: 1;
	padding: 10px 16px;
	border-radius: 999px;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	pointer-events: none;
}
.xchat-side-left  .xchat-caption { left: 0; }
.xchat-side-right .xchat-caption { right: 0; }

.xchat-teaser {
	position: absolute;
	bottom: calc(100% + 36px);
	display: flex;
	align-items: center;
	gap: 4px;
	background: #fff;
	color: #1c1d1a;
	border-radius: 14px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
	padding: 4px 6px;
	white-space: nowrap;
	animation: xchat-teaser-in 0.3s ease;
}
.xchat-side-left  .xchat-teaser { left: 0; }
.xchat-side-right .xchat-teaser { right: 0; }
.xchat-teaser-text {
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: 14px;
	color: #1c1d1a;
	cursor: pointer;
	padding: 6px;
}
.xchat-teaser-close {
	border: none;
	background: transparent;
	font-size: 18px;
	line-height: 1;
	color: #8b8b8b;
	cursor: pointer;
	padding: 2px 6px;
}
.xchat-teaser-close:hover { color: #1c1d1a; }
@keyframes xchat-teaser-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	.xchat-teaser { animation: none; }
}
.xchat-root.xchat-open .xchat-caption,
.xchat-root.xchat-open .xchat-teaser { display: none; }

/* ------------------------------------------------------------ launcher -- */
.xchat-launcher {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border: none;
	border-radius: 50%;
	background: var(--xchat-red);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease, background 0.15s ease;
}
.xchat-launcher:hover { background: var(--xchat-red-dark); transform: scale(1.06); }
.xchat-launcher:focus-visible { outline: 3px solid var(--xchat-dark); outline-offset: 2px; }

/* Avatar launcher: the virtual host's face in a brand-red ring.
   Big and bold, per Yafit (29.08: enlarged twice - keep it prominent),
   then pulled back 20% on 31.08 - it was eating the page on a phone.
   While the panel is open it shrinks so it doesn't fight the chat window. */
.xchat-launcher.xchat-launcher-avatar {
	width: 192px;
	height: 192px;
	padding: 0;
	overflow: hidden;
	background: #fff;
	border: 5px solid var(--xchat-red);
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
}
.xchat-launcher.xchat-launcher-avatar:hover { background: #fff; }
.xchat-root.xchat-open .xchat-launcher.xchat-launcher-avatar {
	width: 64px;
	height: 64px;
	border-width: 3px;
}
.xchat-avatar-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.xchat-head-main {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.xchat-head-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--xchat-red);
	object-fit: cover;
	flex-shrink: 0;
}

/* --------------------------------------------------------------- panel -- */
.xchat-panel {
	position: absolute;
	bottom: 68px;
	width: min(370px, calc(100vw - 40px));
	height: min(520px, calc(100vh - 140px));
	display: flex;
	flex-direction: column;
	background: var(--xchat-bg);
	color: var(--xchat-text);
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}
.xchat-root.xchat-open .xchat-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}
.xchat-panel[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
	.xchat-panel, .xchat-launcher { transition: none; }
}

/* -------------------------------------------------------------- header -- */
.xchat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	background: var(--xchat-dark);
	color: #fff;
	padding: 12px 16px;
	border-block-end: 3px solid var(--xchat-red);
}
.xchat-title { font-weight: 700; font-size: 15px; }
.xchat-subtitle { font-size: 11px; opacity: 0.75; margin-block-start: 2px; }
.xchat-close {
	border: none;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}
.xchat-close:focus-visible { outline: 2px solid #fff; }

/* ------------------------------------------------------------ messages -- */
.xchat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #fafafa;
}
.xchat-root .xchat-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 16px !important;
	line-height: 1.55;
	color: #1c1d1a !important;
	white-space: pre-wrap;
	word-break: break-word;
	unicode-bidi: plaintext;
}
.xchat-msg-assistant {
	background: var(--xchat-bubble-bot);
	align-self: flex-start;
	border-start-start-radius: 4px;
}
.xchat-msg-user {
	background: var(--xchat-bubble-user);
	align-self: flex-end;
	border-start-end-radius: 4px;
}
.xchat-link { color: var(--xchat-red); text-decoration: underline; word-break: break-all; }

/* typing dots */
.xchat-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.xchat-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9a9a9a;
	animation: xchat-blink 1.2s infinite ease-in-out;
}
.xchat-typing span:nth-child(2) { animation-delay: 0.2s; }
.xchat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes xchat-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
	.xchat-typing span { animation: none; opacity: 0.6; }
}

/* ---------------------------------------------------------------- form -- */
.xchat-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-block-start: 1px solid #e5e5e5;
	background: var(--xchat-bg);
}
/* Hardened against theme overrides (Avada styles inputs globally):
   the typed text must stay dark and visible on every device. */
.xchat-root .xchat-input {
	flex: 1;
	min-width: 0;
	border: 1px solid #c4c4c4;
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 16px; /* גם מונע זום אוטומטי באייפון */
	font-family: inherit;
	background: #fff !important;
	color: #1c1d1a !important;
	-webkit-text-fill-color: #1c1d1a !important;
	caret-color: var(--xchat-red);
	opacity: 1 !important;
	text-shadow: none !important;
}
.xchat-root .xchat-input::placeholder {
	color: #8b8b8b !important;
	-webkit-text-fill-color: #8b8b8b !important;
	opacity: 1;
}
.xchat-root .xchat-input:focus { outline: 2px solid var(--xchat-red); border-color: transparent; }
.xchat-root .xchat-input:disabled { background: #f2f2f2 !important; }
.xchat-send {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: var(--xchat-red);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
}
.xchat-send svg { transform: scaleX(-1); }
.xchat-send:hover { background: var(--xchat-red-dark); }
.xchat-send:disabled { background: #bbb; cursor: default; }
.xchat-send:focus-visible { outline: 2px solid var(--xchat-dark); outline-offset: 2px; }

/* -------------------------------------------------------------- mobile -- */
@media (max-width: 480px) {
	.xchat-panel {
		position: fixed;
		inset-inline: 0;
		bottom: 0;
		width: 100%;
		height: min(85dvh, 640px);
		border-radius: 16px 16px 0 0;
	}
	.xchat-launcher { width: 60px; height: 60px; }
	.xchat-launcher.xchat-launcher-avatar { width: 168px; height: 168px; }
	.xchat-header { padding: 14px 16px; }
	.xchat-title { font-size: 17px; }
	.xchat-subtitle { font-size: 12px; }
	.xchat-messages { padding: 16px; gap: 10px; }
	.xchat-root .xchat-msg { font-size: 17px !important; max-width: 90%; }
	.xchat-form { padding: 12px; gap: 10px; }
	.xchat-root .xchat-input { padding: 12px 18px; font-size: 17px !important; }
	.xchat-send { width: 48px; height: 48px; }
}

/* ------------------------------------------- site floats vs. the chat -- */
/* Per Yafit (29.08): on phones the WhatsApp bubble moves out of the chat's
   way, to the left edge next to the sticky phone button.
   31.08 - she asked for it above the phone, not below. The button carries its
   own 24px top margin, so the offset is measured to the button inside the
   container: 50% - 88px puts its bottom edge ~6px over the phone, at 50%.
   Same day, later: she picked the plugin's wide "Button" layout with the
   Hebrew label, so the button is now a 40px pill, not a 44px circle. Its
   20px left margin is zeroed so it lines up with the phone tab's edge. */
@media (max-width: 480px) {
	.qlwapp__container--bottom-left {
		bottom: auto !important;
		top: calc(50% - 88px) !important;
		left: 2px !important;
		z-index: 9998 !important;
	}
	.qlwapp__container--bottom-left .qlwapp__button {
		margin-left: 0 !important;
		/* a longer label must not push the pill off the screen */
		max-width: calc(100vw - 8px) !important;
	}
	.qlwapp__container--bottom-left .qlwapp__button--bubble {
		width: 44px !important;
		height: 44px !important;
	}
}

/* The promo popup (Popups plugin, .spu-box): on phones it covered the
   whole screen. Per Yafit - keep it, but compact and out of the way. */
@media (max-width: 480px) {
	.spu-box {
		width: 280px !important;
		max-width: 80vw !important;
		top: 110px !important;
		bottom: auto !important;
		left: 50% !important;
		right: auto !important;
		transform: translateX(-50%) !important;
		z-index: 99998 !important;
	}
	.spu-box h2 { font-size: 20px !important; line-height: 1.3 !important; }
	.spu-box .spu-content { font-size: 14px !important; }
}

/* While the chat is open, nothing floats over it - on any screen.
   The accessibility widget (Elementor Ally / the old pojo-a11y naming)
   is matched by family, since its exact markup varies by version. */
body.xchat-chat-open .qlwapp__container--bottom-left,
body.xchat-chat-open #sticky-buttons-1,
body.xchat-chat-open #toTop,
body.xchat-chat-open [id*="ea11y"],
body.xchat-chat-open [class*="ea11y"],
body.xchat-chat-open #pojo-a11y-toolbar,
body.xchat-chat-open [class*="pojo-a11y"] {
	display: none !important;
}

/* --------------------------------------------- whatsapp launcher (1.0.13) -- */
/* The launcher is an <a> in this mode - keep it looking like the button. */
a.xchat-launcher {
	position: relative;
	text-decoration: none;
	box-sizing: border-box;
}
a.xchat-launcher:hover,
a.xchat-launcher:focus { text-decoration: none; }
.xchat-launcher.xchat-launcher-avatar { overflow: visible; }
.xchat-launcher.xchat-launcher-avatar .xchat-avatar-img { border-radius: 50%; }
/* Green WhatsApp badge on the ring, bottom corner, so the tap is not a surprise. */
.xchat-wa-badge {
	position: absolute;
	right: 6px;
	bottom: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #25d366;
	color: #fff;
	border: 3px solid #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.xchat-wa-badge svg { width: 26px; height: 26px; }
a.xchat-teaser-text {
	display: inline-block;
	text-decoration: none;
}
a.xchat-teaser-text:hover { text-decoration: underline; }
@media (max-width: 480px) {
	.xchat-wa-badge { width: 40px; height: 40px; right: 4px; bottom: 4px; }
	.xchat-wa-badge svg { width: 24px; height: 24px; }
}

/* 1.0.14 - WhatsApp mode: host 20% smaller than the chat-mode avatar
   (192 -> 154 desktop, 168 -> 134 phone), per Yafit after the live check. */
.xchat-wa .xchat-launcher.xchat-launcher-avatar { width: 154px; height: 154px; }
.xchat-wa .xchat-wa-badge { width: 40px; height: 40px; }
.xchat-wa .xchat-wa-badge svg { width: 24px; height: 24px; }
@media (max-width: 480px) {
	.xchat-wa .xchat-launcher.xchat-launcher-avatar { width: 134px; height: 134px; }
	.xchat-wa .xchat-wa-badge { width: 36px; height: 36px; right: 3px; bottom: 3px; }
	.xchat-wa .xchat-wa-badge svg { width: 22px; height: 22px; }
}
