/**
 * PupPooch shopping assistant widget (assets/js/chat.js) and WhatsApp button.
 *
 * Layers: above the header (50) and the sticky add-to-cart bar (90), below
 * the drawers and overlays (998-999) and the toast (1001). The back-to-top
 * paw moves to the bottom left while the chat is on (body.pp-has-chat).
 */

.pp-chat {
	--chat-brand: var(--pp-brand, #C4501F);
	--chat-brand-hover: #A9431A;
	--chat-accent: var(--pp-accent, #1F5F5B);
	--chat-ink: var(--pp-text, #1E2A32);
	--chat-muted: var(--pp-muted, #5B6670);
	--chat-line: #ECE4DA;
	--chat-bg: var(--pp-bg, #FFFBF6);
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 95;
	font-family: var(--pp-font, system-ui, sans-serif);
	font-size: 14px;
	line-height: 1.5;
	color: var(--chat-ink);
	transition: bottom 0.35s ease, opacity 0.2s ease, visibility 0.2s;
}

.pp-chat *,
.pp-chat *::before,
.pp-chat *::after {
	box-sizing: border-box;
}

.pp-chat button {
	font: inherit;
	cursor: pointer;
}

/* Stay clear of the product page's sticky add-to-cart bar, hide under drawers. */
body.pp-has-sticky-atc .pp-chat {
	bottom: 92px;
}

body.pp-drawer-open .pp-chat {
	opacity: 0;
	visibility: hidden;
}

/* The back-to-top paw moves to the bottom left. */
body.pp-has-chat .pp-totop {
	right: auto;
	left: 20px;
}

/* ===== LAUNCHER ===== */
.pp-chat__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	margin-left: auto;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--chat-brand);
	color: #FFFFFF;
	box-shadow: 0 10px 26px -8px rgba(196, 80, 31, 0.7);
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.pp-chat__launcher:hover {
	background: var(--chat-brand-hover);
	transform: scale(1.06);
}

.pp-chat__launcher::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--chat-brand);
	animation: pp-chat-pulse 2.4s ease-out infinite;
}

.pp-chat.is-open .pp-chat__launcher::before {
	animation: none;
	opacity: 0;
}

@keyframes pp-chat-pulse {
	0% { transform: scale(1); opacity: 0.7; }
	100% { transform: scale(1.5); opacity: 0; }
}

.pp-chat__dot {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 14px;
	height: 14px;
	border: 2px solid #FFFFFF;
	border-radius: 50%;
	background: #22C55E;
}

.pp-chat__dot[hidden] {
	display: none;
}

/* ===== WHATSAPP (above the launcher) ===== */
.pp-chat__wa {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin: 0 4px 12px auto;
	border-radius: 50%;
	background: #25D366;
	color: #FFFFFF !important;
	box-shadow: 0 8px 22px -6px rgba(37, 211, 102, 0.6);
	text-decoration: none !important;
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.pp-chat__wa:hover {
	background: #1EBE5B;
	transform: scale(1.07);
}

.pp-chat.is-open .pp-chat__wa {
	display: none;
}

.pp-chat--wa-only .pp-chat__wa {
	margin: 0;
}

/* ===== TEASER ===== */
.pp-chat__teaser {
	position: absolute;
	right: 0;
	bottom: 74px;
	display: flex;
	align-items: flex-start;
	gap: 4px;
	width: 270px;
	padding: 4px 4px 4px 0;
	border: 1px solid var(--chat-line);
	border-radius: 16px 16px 4px 16px;
	background: #FFFFFF;
	box-shadow: 0 14px 34px -12px rgba(30, 42, 50, 0.35);
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.pp-chat.has-wa .pp-chat__teaser {
	bottom: 138px;
}

.pp-chat__teaser.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.pp-chat__teaser-text {
	flex: 1;
	padding: 12px 6px 12px 16px;
	border: 0;
	background: none;
	color: var(--chat-ink);
	font-weight: 700;
	text-align: left;
	line-height: 1.4;
}

.pp-chat__teaser-close {
	display: flex;
	padding: 6px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--chat-muted);
}

.pp-chat__teaser-close:hover {
	background: var(--pp-alt, #F4EEE6);
}

/* ===== PANEL ===== */
.pp-chat__panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	display: flex;
	flex-direction: column;
	width: 380px;
	height: min(620px, calc(100vh - 120px));
	overflow: hidden;
	border-radius: 20px;
	background: #FFFFFF;
	box-shadow: 0 24px 60px -18px rgba(30, 42, 50, 0.45);
	animation: pp-chat-in 0.22s ease;
}

body.pp-has-sticky-atc .pp-chat__panel {
	height: min(620px, calc(100vh - 190px));
}

.pp-chat__panel[hidden] {
	display: none;
}

@keyframes pp-chat-in {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: none; }
}

.pp-chat__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 16px 18px;
	background: var(--chat-accent);
	color: #FFFFFF;
}

.pp-chat__avatar {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--chat-brand);
}

.pp-chat__titles {
	flex: 1;
	min-width: 0;
}

.pp-chat__name {
	margin: 0;
	color: #FFFFFF;
	font-size: 16px;
	font-weight: 800;
	line-height: 1.25;
}

.pp-chat__sub {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 2px 0 0;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.85);
}

.pp-chat__online {
	flex: 0 0 auto;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ADE80;
}

.pp-chat__close {
	display: flex;
	padding: 8px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #FFFFFF;
}

.pp-chat__close:hover {
	background: rgba(255, 255, 255, 0.26);
}

/* ===== MESSAGES ===== */
.pp-chat__body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 14px 8px;
	background: var(--chat-bg);
	overscroll-behavior: contain;
}

.pp-chat__msg {
	display: flex;
	margin-bottom: 10px;
}

.pp-chat__msg--me {
	justify-content: flex-end;
}

.pp-chat__bubble {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 16px;
	overflow-wrap: anywhere;
}

.pp-chat__msg--bot .pp-chat__bubble {
	border: 1px solid var(--chat-line);
	border-bottom-left-radius: 4px;
	background: #FFFFFF;
}

.pp-chat__msg--me .pp-chat__bubble {
	border-bottom-right-radius: 4px;
	background: var(--chat-brand);
	color: #FFFFFF;
}

.pp-chat__text p {
	margin: 0 0 8px;
}

.pp-chat__text p:last-child,
.pp-chat__text ul:last-child {
	margin-bottom: 0;
}

.pp-chat__text ul {
	margin: 0 0 8px;
	padding-left: 18px;
	list-style: disc;
}

.pp-chat__text li {
	margin-bottom: 3px;
}

.pp-chat__text strong {
	color: var(--chat-ink);
	font-weight: 800;
}

.pp-chat__text a {
	color: var(--chat-brand);
	font-weight: 700;
	text-decoration: underline;
}

.pp-chat__text a.pp-chat__wa-link {
	color: #128C4B;
}

/* Typing dots */
.pp-chat__typing .pp-chat__bubble {
	display: flex;
	gap: 4px;
	padding: 14px 16px;
}

.pp-chat__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #B9AFA4;
	animation: pp-chat-dot 1.2s infinite ease-in-out;
}

.pp-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.pp-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pp-chat-dot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== PRODUCT CARDS ===== */
.pp-chat__products {
	display: flex;
	gap: 10px;
	margin: 0 -14px 12px;
	padding: 2px 14px 6px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
}

.pp-chat__product {
	display: flex;
	flex: 0 0 150px;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--chat-line);
	border-radius: 14px;
	background: #FFFFFF;
	color: var(--chat-ink) !important;
	text-decoration: none !important;
	scroll-snap-align: start;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.pp-chat__product:hover {
	box-shadow: 0 10px 22px -12px rgba(30, 42, 50, 0.35);
	transform: translateY(-2px);
}

.pp-chat__product-img {
	display: block;
	aspect-ratio: 1;
	background: var(--pp-alt, #F4EEE6);
}

.pp-chat__product-img img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pp-chat__product-title {
	display: -webkit-box;
	margin: 8px 10px 4px;
	overflow: hidden;
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.35;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.pp-chat__product-price {
	margin: 0 10px;
	font-weight: 800;
	color: var(--chat-brand);
}

.pp-chat__product-cta {
	margin: auto 10px 10px;
	padding-top: 8px;
	font-size: 12px;
	font-weight: 700;
	color: var(--chat-accent);
}

.pp-chat__product--more {
	align-items: center;
	justify-content: center;
	padding: 14px;
	border-style: dashed;
	font-weight: 800;
	text-align: center;
	color: var(--chat-brand) !important;
}

/* ===== CHIPS + INPUT ===== */
.pp-chat__chips {
	display: flex;
	gap: 8px;
	padding: 10px 14px 4px;
	overflow-x: auto;
	border-top: 1px solid var(--chat-line);
	background: #FFFFFF;
	scrollbar-width: none;
}

.pp-chat__chips::-webkit-scrollbar {
	display: none;
}

.pp-chat__chip {
	flex: 0 0 auto;
	padding: 6px 13px;
	border: 1px solid var(--pp-border-strong, rgba(0, 0, 0, 0.2));
	border-radius: 999px;
	background: #FFFFFF;
	color: var(--chat-ink);
	font-size: 12.5px;
	font-weight: 700;
	white-space: nowrap;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.pp-chat__chip:hover {
	border-color: var(--chat-brand);
	background: var(--pp-surface, #FCEFE3);
}

.pp-chat__form {
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 8px 14px 14px;
	background: #FFFFFF;
}

.pp-chat__input {
	flex: 1;
	min-width: 0;
	height: 46px;
	margin: 0;
	padding: 0 16px;
	border: 1.5px solid var(--pp-border-strong, rgba(0, 0, 0, 0.2));
	border-radius: 24px;
	background: #FFFFFF;
	color: var(--chat-ink);
	font: inherit;
	font-size: 16px; /* 16px stops iOS zooming in on focus. */
	outline: none;
}

.pp-chat .pp-chat__input:focus,
.pp-chat .pp-chat__input:focus-visible {
	border-color: var(--chat-brand);
	box-shadow: 0 0 0 3px rgba(196, 80, 31, 0.15);
	outline: none !important; /* The orange ring replaces the theme's blue focus outline here. */
}

.pp-chat__send {
	display: flex;
	flex: 0 0 46px;
	align-items: center;
	justify-content: center;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--chat-accent);
	color: #FFFFFF;
	transition: background-color 0.2s ease;
}

.pp-chat__send:hover {
	background: var(--chat-brand);
}

.pp-chat :focus-visible {
	outline: 2px solid var(--pp-focus, #378ADD);
	outline-offset: 2px;
}

/* ===== PHONES ===== */
@media (max-width: 760px) {
	.pp-chat {
		right: 14px;
		bottom: 14px;
	}

	body.pp-has-sticky-atc .pp-chat {
		bottom: 84px;
	}

	body.pp-has-chat .pp-totop {
		right: auto;
		left: 14px;
	}

	.pp-chat__launcher {
		width: 54px;
		height: 54px;
	}

	.pp-chat__wa {
		width: 48px;
		height: 48px;
		margin: 0 3px 10px auto;
	}

	.pp-chat__teaser {
		bottom: 66px;
		width: min(270px, calc(100vw - 28px));
	}

	.pp-chat.has-wa .pp-chat__teaser {
		bottom: 124px;
	}
}

/* Full-screen chat on small phones. */
@media (max-width: 480px) {
	.pp-chat__panel,
	body.pp-has-sticky-atc .pp-chat__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
	}

	.pp-chat.is-open {
		z-index: 1000;
	}

	.pp-chat.is-open .pp-chat__launcher {
		display: none;
	}

	body.pp-chat-open {
		overflow: hidden;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pp-chat *,
	.pp-chat *::before {
		animation: none !important;
		transition: none !important;
	}
}
