/* TPZ Smart Assist — popup + animated mascot */
.tpzsa {
	--tpzsa-accent: #0068c8;
	--tpzsa-accent-2: #0a84ff;
	--tpzsa-ink: #0f172a;
	--tpzsa-muted: #64748b;
	--tpzsa-soft: #f4f7fb;
	--tpzsa-line: #e6ebf2;
	position: fixed;
	z-index: 99990;
	right: 24px;
	bottom: 24px;
	width: 344px;
	max-width: calc(100vw - 24px);
	font-family: inherit;
	line-height: 1.4;
	pointer-events: none;
	-webkit-font-smoothing: antialiased;
}
.tpzsa[hidden] { display: none !important; }
.tpzsa.is-open { pointer-events: auto; }
.tpzsa--left { right: auto; left: 24px; }
.tpzsa *, .tpzsa *::before, .tpzsa *::after { box-sizing: border-box; }

.tpzsa-card {
	position: relative;
	background: #fff;
	color: var(--tpzsa-ink);
	border: 1px solid var(--tpzsa-line);
	border-radius: 20px;
	padding: 46px 16px 16px;
	box-shadow: 0 22px 60px rgba(15, 23, 42, .18), 0 3px 10px rgba(15, 23, 42, .06);
	opacity: 0;
	transform: translateY(26px) scale(.94);
	transform-origin: 30px 100%;
	transition: transform .5s cubic-bezier(.2, 1.35, .4, 1), opacity .25s ease;
	touch-action: pan-x;
}
.tpzsa--left .tpzsa-card, .tpzsa--rtl .tpzsa-card { transform-origin: calc(100% - 30px) 100%; }
.tpzsa--left.tpzsa--rtl .tpzsa-card { transform-origin: 30px 100%; }
.tpzsa.is-open .tpzsa-card { opacity: 1; transform: none; }
.tpzsa.is-dragging .tpzsa-card { transition: none; }

/* Avatar */
.tpzsa-avatar {
	position: absolute;
	top: -36px;
	left: 14px;
	width: 76px;
	height: 76px;
	padding: 3px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 8px 22px rgba(0, 104, 200, .28);
	transform: scale(.3) rotate(-20deg);
	opacity: 0;
	transition: transform .6s cubic-bezier(.2, 1.6, .4, 1) .08s, opacity .2s ease .08s;
}
.tpzsa.is-open .tpzsa-avatar { transform: none; opacity: 1; }
.tpzsa-avatar::after {
	content: "";
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	border: 2px solid var(--tpzsa-accent);
	opacity: 0;
	animation: tpzsa-ring 2.6s ease-out infinite 1s;
	pointer-events: none;
}
.tpzsa-mascot { display: block; width: 100%; height: 100%; border-radius: 50%; overflow: visible; }

.tpzsa-who {
	position: absolute;
	top: 11px;
	left: 100px;
	right: 44px;
	display: flex;
	flex-direction: column;
	line-height: 1.15;
}
.tpzsa-who strong { font-size: 15px; font-weight: 700; color: var(--tpzsa-ink); }
.tpzsa-who span { font-size: 12px; color: var(--tpzsa-muted); }

.tpzsa-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--tpzsa-muted);
	cursor: pointer;
	padding: 0;
	transition: background .2s, color .2s, transform .2s;
}
.tpzsa-close:hover, .tpzsa-close:focus-visible { background: var(--tpzsa-soft); color: var(--tpzsa-ink); transform: rotate(90deg); }
.tpzsa-close:focus-visible, .tpzsa-actions a:focus-visible { outline: 2px solid var(--tpzsa-accent); outline-offset: 2px; }

/* Speech bubble */
.tpzsa-bubble {
	position: relative;
	margin-top: 6px;
	padding: 12px;
	border-radius: 16px;
	background: var(--tpzsa-soft);
}
.tpzsa-bubble::before {
	content: "";
	position: absolute;
	top: -7px;
	left: 40px;
	width: 14px;
	height: 14px;
	background: var(--tpzsa-soft);
	transform: rotate(45deg);
	border-radius: 3px;
}
.tpzsa-product { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tpzsa-img {
	flex: 0 0 52px;
	width: 52px;
	height: 52px;
	object-fit: contain;
	background: #fff;
	border-radius: 12px;
	padding: 4px;
	border: 1px solid var(--tpzsa-line);
}
.tpzsa-img[hidden] { display: none; }
.tpzsa-meta { min-width: 0; }
.tpzsa-name {
	font-size: 13.5px;
	font-weight: 650;
	color: var(--tpzsa-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.tpzsa-price { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.tpzsa-now { font-size: 14px; font-weight: 800; color: var(--tpzsa-accent); }
.tpzsa-save {
	font-size: 11.5px;
	font-weight: 700;
	color: #0f7a3d;
	background: #e3f7eb;
	padding: 2px 8px;
	border-radius: 999px;
	animation: tpzsa-pop .5s cubic-bezier(.2, 1.6, .4, 1) .45s both;
}
.tpzsa-save:empty { display: none; }

.tpzsa-summary { margin: 0; font-size: 14px; font-weight: 600; color: var(--tpzsa-ink); }
.tpzsa-question { margin: 8px 0 0; font-size: 13.5px; color: #334155; }
.tpzsa-question:empty { display: none; }
.tpzsa-rest { color: transparent; }
.tpzsa-caret {
	display: inline-block;
	width: 2px;
	height: 1em;
	margin: 0 1px -2px;
	background: var(--tpzsa-accent);
	animation: tpzsa-caret .8s steps(1) infinite;
}

.tpzsa-specs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.tpzsa-specs:empty { display: none; }
.tpzsa-specs li {
	margin: 0;
	font-size: 11.5px;
	font-weight: 600;
	color: #1e293b;
	background: #fff;
	border: 1px solid #dfe6ef;
	border-radius: 999px;
	padding: 3px 9px;
	opacity: 0;
	transform: translateY(6px);
}
.tpzsa.is-open .tpzsa-specs li { animation: tpzsa-chip .4s ease forwards; animation-delay: calc(.35s + var(--i, 0) * .09s); }

/* Actions */
.tpzsa-actions { display: flex; gap: 8px; margin-top: 12px; }
.tpzsa-actions a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 42px;
	padding: 0 14px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 700;
	text-decoration: none !important;
	transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
	white-space: nowrap;
}
.tpzsa-shop {
	flex: 1;
	color: #fff !important;
	background: linear-gradient(135deg, var(--tpzsa-accent), var(--tpzsa-accent-2));
	box-shadow: 0 6px 16px rgba(0, 104, 200, .28);
}
.tpzsa-shop:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0, 104, 200, .34); }
.tpzsa-shop .tpzsa-arrow { transition: transform .2s ease; }
.tpzsa-shop:hover .tpzsa-arrow { transform: translateX(3px); }
.tpzsa-wa { color: #128c4a !important; background: #e7f8ee; }
.tpzsa-wa:hover { background: #d6f3e2; transform: translateY(-1px); }
.tpzsa-wa[hidden] { display: none; }

/* Auto-hide progress */
.tpzsa-timer { position: absolute; left: 20px; right: 20px; bottom: 6px; height: 3px; border-radius: 3px; background: var(--tpzsa-line); overflow: hidden; }
.tpzsa-timer[hidden] { display: none; }
.tpzsa-timer i { display: block; height: 100%; background: var(--tpzsa-accent); opacity: .55; transform-origin: left; }
.tpzsa.is-timing .tpzsa-timer i { animation: tpzsa-timer var(--tpzsa-hide, 8s) linear forwards; }
.tpzsa.is-paused .tpzsa-timer i { animation-play-state: paused; }

/* Product card highlight */
.tpzsa-glow { outline: 2px solid var(--tpzsa-glow, rgba(0, 104, 200, .35)) !important; outline-offset: 3px; border-radius: 12px; transition: outline-color .3s ease; }

/* RTL */
.tpzsa--rtl { direction: rtl; }
.tpzsa--rtl .tpzsa-avatar { left: auto; right: 14px; }
.tpzsa--rtl .tpzsa-who { left: 44px; right: 100px; }
.tpzsa--rtl .tpzsa-close { right: auto; left: 8px; }
.tpzsa--rtl .tpzsa-bubble::before { left: auto; right: 40px; }
.tpzsa--rtl .tpzsa-shop .tpzsa-arrow { transform: scaleX(-1); }
.tpzsa--rtl .tpzsa-shop:hover .tpzsa-arrow { transform: scaleX(-1) translateX(3px); }
.tpzsa--rtl .tpzsa-timer i { transform-origin: right; }

/* Mascot animation */
.tpzsa-mascot .tpzsa-m-head { transform-box: view-box; transform-origin: 60px 104px; animation: tpzsa-bob 3.4s ease-in-out infinite; }
.tpzsa-mascot .tpzsa-m-hello { transform-box: view-box; transform-origin: 60px 110px; }
.tpzsa.is-hello .tpzsa-m-hello { animation: tpzsa-hello 1.1s cubic-bezier(.3, 1.4, .5, 1) .25s; }
.tpzsa-mascot .tpzsa-m-eyes { transform-box: fill-box; transform-origin: center; animation: tpzsa-blink 4.8s ease-in-out infinite; }
.tpzsa-mascot .tpzsa-m-brows { transform-box: fill-box; transform-origin: center; }
.tpzsa.is-hello .tpzsa-m-brows { animation: tpzsa-brows .5s ease-in-out .35s 2 alternate; }
.tpzsa-mascot .tpzsa-m-talk { opacity: 0; transform-box: fill-box; transform-origin: center top; }
.tpzsa-mascot .tpzsa-m-smile { transition: opacity .1s; }
.tpzsa.is-talking .tpzsa-m-smile { opacity: 0; }
.tpzsa.is-talking .tpzsa-m-talk { opacity: 1; animation: tpzsa-talk .19s ease-in-out infinite alternate; }
.tpzsa-mascot .tpzsa-m-spark circle { transform-box: fill-box; transform-origin: center; animation: tpzsa-twinkle 2.4s ease-in-out infinite; }
.tpzsa-mascot .tpzsa-m-spark circle:nth-child(2) { animation-delay: .6s; }
.tpzsa-mascot .tpzsa-m-spark circle:nth-child(3) { animation-delay: 1.2s; }
.tpzsa-mascot .tpzsa-m-spark circle:nth-child(4) { animation-delay: 1.8s; }

@keyframes tpzsa-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-1.8px) rotate(-1.2deg); } }
@keyframes tpzsa-hello { 0% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 55% { transform: rotate(7deg); } 80% { transform: rotate(-3deg); } 100% { transform: rotate(0); } }
@keyframes tpzsa-blink { 0%, 90%, 100% { transform: scaleY(1); } 93% { transform: scaleY(.08); } 96% { transform: scaleY(1); } }
@keyframes tpzsa-brows { to { transform: translateY(-2px); } }
@keyframes tpzsa-talk { from { transform: scaleY(.3); } to { transform: scaleY(1.05); } }
@keyframes tpzsa-twinkle { 0%, 100% { transform: scale(.6); opacity: .3; } 50% { transform: scale(1.2); opacity: 1; } }
@keyframes tpzsa-ring { 0% { transform: scale(.95); opacity: .55; } 80%, 100% { transform: scale(1.22); opacity: 0; } }
@keyframes tpzsa-chip { to { opacity: 1; transform: none; } }
@keyframes tpzsa-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes tpzsa-caret { 50% { opacity: 0; } }
@keyframes tpzsa-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Mobile: bottom sheet that slides up, swipe down to close */
@media (max-width: 767px) {
	.tpzsa, .tpzsa--left { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; }
	.tpzsa-card { padding: 42px 14px 16px; border-radius: 22px; transform: translateY(120%); }
	.tpzsa-card::before {
		content: "";
		position: absolute;
		top: 7px;
		left: 50%;
		width: 38px;
		height: 4px;
		margin-left: -19px;
		border-radius: 4px;
		background: #d8dee8;
	}
	.tpzsa-avatar { width: 64px; height: 64px; top: -30px; }
	.tpzsa-who { top: 14px; left: 88px; }
	.tpzsa--rtl .tpzsa-who { left: 44px; right: 88px; }
	.tpzsa-actions a { min-height: 44px; font-size: 14.5px; }
}

@media (prefers-reduced-motion: reduce) {
	.tpzsa-card, .tpzsa-avatar, .tpzsa-specs li, .tpzsa-save, .tpzsa-actions a, .tpzsa-close { transition: none !important; animation: none !important; }
	.tpzsa-specs li { opacity: 1; transform: none; }
	.tpzsa-mascot *, .tpzsa-avatar::after, .tpzsa-caret { animation: none !important; }
	.tpzsa.is-talking .tpzsa-m-smile { opacity: 1; }
	.tpzsa.is-talking .tpzsa-m-talk { opacity: 0; }
}
