/* Picătura Naturii — chat widget (customer-facing). Scoped under
 * #pnpdi-chat-root so it can never leak into or be affected by the
 * theme's own styles.
 *
 * v1.5.4: visual redesign requested by the store owner ("facem-l gen
 * WhatsApp"), built from a WhatsApp Web–style reference the owner
 * supplied — wallpapered thread, tailed message bubbles, neutral header,
 * pill-shaped composer with a circular send button. Brand identity
 * (site logo, name, accent green pulled from picaturanaturii.ro) is kept
 * throughout rather than switching to WhatsApp's own teal/beige palette
 * wholesale, so the widget still reads as "this store's chat", not a
 * generic WhatsApp clone. */

#pnpdi-chat-root {
	position: fixed;
	z-index: 999999;
	right: 20px;
	bottom: calc(20px + var(--pnpdi-sticky-bar-offset, 0px));
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#pnpdi-chat-root * {
	box-sizing: border-box;
}

#pnpdi-chat-root {
	--pnpdi-accent: #7cc68d;
	--pnpdi-accent-dark: #5fa873;
	--pnpdi-ink: #111b21;
	--pnpdi-muted: #667781;
	--pnpdi-line: #e2e5e9;
	--pnpdi-header-bg: #f7f9f6;
	--pnpdi-in-bg: #ffffff;
	--pnpdi-out-bg: #d9fdd3;
	--pnpdi-wallpaper: #efe7de;
	--pnpdi-shadow: rgba(11, 20, 26, 0.16);
	/* v1.5.9: kept at 0px by default; chat-widget.js measures the site's
	 * own mobile "Adaugă în coș" sticky bar (.pn-mobile-cart) live and sets
	 * this to its real height + a small gap whenever that bar is on
	 * screen, so the launcher/panel/teaser (all descendants of this root —
	 * a CSS custom property is inherited down the DOM tree regardless of
	 * `position: fixed`) always float above it instead of overlapping it. */
	--pnpdi-sticky-bar-offset: 0px;
}

.pnpdi-chat-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--pnpdi-accent);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(124, 198, 141, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	line-height: 1;
	padding: 0;
	overflow: hidden;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pnpdi-chat-bubble:hover {
	background: var(--pnpdi-accent-dark);
	transform: translateY(-1px);
	box-shadow: 0 8px 22px rgba(124, 198, 141, 0.55);
}

.pnpdi-chat-bubble img {
	width: 68%;
	height: 68%;
	object-fit: contain;
	border-radius: 50%;
	background: #fff;
}

.pnpdi-chat-bubble svg {
	width: 28px;
	height: 28px;
}

/* ---------- Proactive greeting teaser (v1.5.6, repositioned v1.5.10) ---------- */

/* v1.5.10: sits beside the launcher (not stacked above it) — bottom-aligned
 * with the 60px launcher button, right offset = launcher's own 60px width
 * + a 10px gap, so it reads as "pointing at the chat icon" rather than a
 * separate floating card. A small triangle (::after below) closes the gap
 * visually. See the matching mobile rule in the @media block below. */
.pnpdi-chat-teaser {
	position: fixed;
	right: 90px;
	bottom: calc(20px + var(--pnpdi-sticky-bar-offset, 0px));
	width: 270px;
	max-width: calc(100vw - 40px);
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 30px 12px 12px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 10px 30px rgba(30, 30, 30, 0.18);
	cursor: pointer;
	animation: pnpdi-teaser-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Small pointer on the teaser's right edge, aimed at the launcher icon. */
.pnpdi-chat-teaser::after {
	content: "";
	position: absolute;
	top: 50%;
	right: -8px;
	transform: translateY(-50%);
	width: 0;
	height: 0;
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
	border-left: 8px solid #fff;
}

@keyframes pnpdi-teaser-in {
	from {
		opacity: 0;
		transform: translateX(8px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: translateX(0) scale(1);
	}
}

.pnpdi-chat-teaser-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--pnpdi-accent);
	color: #fff;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.pnpdi-chat-teaser-avatar img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #fff;
}

.pnpdi-chat-teaser-avatar svg {
	width: 18px;
	height: 18px;
}

.pnpdi-chat-teaser-body {
	font-size: 13px;
	line-height: 1.4;
	color: var(--pnpdi-ink);
}

.pnpdi-chat-teaser-close {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--pnpdi-muted);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pnpdi-chat-teaser-close:hover {
	background: rgba(17, 27, 33, 0.06);
	color: var(--pnpdi-ink);
}

.pnpdi-chat-panel {
	position: fixed;
	right: 20px;
	bottom: calc(92px + var(--pnpdi-sticky-bar-offset, 0px));
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 510px;
	max-height: calc(100vh - 140px);
	background: var(--pnpdi-in-bg);
	border-radius: 16px;
	box-shadow: 0 14px 44px rgba(30, 30, 30, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.pnpdi-chat-panel[hidden] {
	display: none;
}

/* ---------- Header: neutral WhatsApp-style bar, not a solid brand block ---------- */

.pnpdi-chat-header {
	background: var(--pnpdi-header-bg);
	color: var(--pnpdi-ink);
	padding: 12px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	border-bottom: 1px solid var(--pnpdi-line);
}

.pnpdi-chat-header-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.pnpdi-chat-header-brand img {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	object-fit: contain;
	background: #fff;
	flex-shrink: 0;
	border: 1px solid var(--pnpdi-line);
}

.pnpdi-chat-header-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.pnpdi-chat-header-title {
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pnpdi-chat-header-subtitle {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11.5px;
	color: var(--pnpdi-muted);
}

.pnpdi-chat-header-subtitle::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--pnpdi-accent);
	flex-shrink: 0;
}

.pnpdi-chat-close {
	background: none;
	border: none;
	color: var(--pnpdi-muted);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 6px;
	border-radius: 50%;
	flex-shrink: 0;
}

.pnpdi-chat-close:hover {
	background: rgba(17, 27, 33, 0.06);
	color: var(--pnpdi-ink);
}

/* ---------- Thread: wallpapered background, day divider, tailed bubbles ---------- */

.pnpdi-chat-messages {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 14px 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	background-color: var(--pnpdi-wallpaper);
	background-image:
		radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.035) 0 2px, transparent 2px),
		radial-gradient(circle at 70% 60%, rgba(0, 0, 0, 0.03) 0 3px, transparent 3px),
		radial-gradient(circle at 45% 85%, rgba(0, 0, 0, 0.028) 0 2px, transparent 2px),
		linear-gradient(140deg, rgba(255, 255, 255, 0.5), transparent 60%);
	background-size: 120px 120px, 190px 190px, 150px 150px, 100% 100%;
}

.pnpdi-chat-day {
	align-self: center;
	margin: 4px 0 8px;
	padding: 4px 12px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.75);
	color: var(--pnpdi-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	box-shadow: 0 1px 2px var(--pnpdi-shadow);
}

.pnpdi-chat-row {
	display: flex;
	margin: 3px 0;
}

.pnpdi-chat-row.user {
	justify-content: flex-end;
}

.pnpdi-chat-msg {
	position: relative;
	max-width: 82%;
	padding: 7px 9px 8px 10px;
	font-size: 13.5px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	border-radius: 9px;
	background: var(--pnpdi-in-bg);
	color: var(--pnpdi-ink);
	box-shadow: 0 1px 1px var(--pnpdi-shadow);
}

.pnpdi-chat-msg::after {
	content: "";
	position: absolute;
	top: 0;
	width: 9px;
	height: 14px;
	background: inherit;
}

.pnpdi-chat-row.assistant .pnpdi-chat-msg {
	border-top-left-radius: 0;
}

.pnpdi-chat-row.assistant .pnpdi-chat-msg::after {
	left: -8px;
	clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.pnpdi-chat-row.user .pnpdi-chat-msg {
	background: var(--pnpdi-out-bg);
	border-top-right-radius: 0;
}

.pnpdi-chat-row.user .pnpdi-chat-msg::after {
	right: -8px;
	clip-path: polygon(0 0, 100% 0, 0 100%);
}

.pnpdi-chat-msg a {
	color: inherit;
	text-decoration: underline;
}

.pnpdi-chat-msg-meta {
	float: right;
	margin-left: 8px;
	margin-top: 2px;
	font-size: 10.5px;
	font-weight: 500;
	color: var(--pnpdi-muted);
	font-variant-numeric: tabular-nums;
}

.pnpdi-chat-row.system {
	justify-content: center;
	margin: 6px 0;
}

.pnpdi-chat-row.system .pnpdi-chat-msg {
	max-width: 90%;
	background: rgba(255, 255, 255, 0.82);
	color: var(--pnpdi-muted);
	font-size: 12px;
	text-align: center;
	box-shadow: none;
	border-radius: 10px;
}

.pnpdi-chat-row.system .pnpdi-chat-msg::after {
	display: none;
}

/* Typing indicator (three bouncing dots), shown while waiting for a reply. */

.pnpdi-chat-typing {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 2px 0;
}

.pnpdi-chat-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--pnpdi-muted);
	opacity: 0.6;
	animation: pnpdi-typing-bounce 1.2s infinite ease-in-out;
}

.pnpdi-chat-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.pnpdi-chat-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes pnpdi-typing-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	30% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* CTA button: a real <a> element (see chat-widget.js), styled to stand
 * out from ordinary text/links inside a message bubble. */
.pnpdi-chat-cta {
	display: block;
	clear: both;
	margin-top: 8px;
	padding: 9px 14px;
	background: var(--pnpdi-accent-dark);
	color: #fff !important;
	border-radius: 20px;
	font-weight: 600;
	font-size: 13px;
	text-align: center;
	text-decoration: none !important;
	transition: background 0.15s ease;
}

.pnpdi-chat-cta:hover {
	background: #4c8a5d;
}

/* ---------- Product card (v1.5.11) ----------
 * Rendered from a [[PRODUCT:sku]] token (see chat-widget.js) — image, name,
 * price and stock are fetched live from the public read-only Canonical
 * REST API (the same one external AI agents use), never from anything the
 * assistant itself typed, so the numbers shown are always the real,
 * current WooCommerce data. */
.pnpdi-chat-product {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 10px;
	clear: both;
	margin-top: 8px;
	padding: 10px;
	background: #fff;
	border: 1px solid var(--pnpdi-line);
	border-radius: 12px;
}

.pnpdi-chat-product-loading {
	font-size: 12px;
	color: var(--pnpdi-muted);
	padding: 2px 0;
}

.pnpdi-chat-product-img {
	width: 56px;
	height: 56px;
	object-fit: contain;
	border-radius: 8px;
	background: #fff;
	border: 1px solid var(--pnpdi-line);
	flex-shrink: 0;
}

.pnpdi-chat-product-body {
	flex: 1 1 120px;
	min-width: 120px;
}

.pnpdi-chat-product-name {
	font-weight: 600;
	font-size: 13px;
	line-height: 1.3;
	margin-bottom: 3px;
}

.pnpdi-chat-product-price {
	font-size: 13px;
	margin-bottom: 3px;
}

.pnpdi-chat-product-price-old {
	text-decoration: line-through;
	color: var(--pnpdi-muted);
	margin-right: 6px;
	font-size: 12px;
}

.pnpdi-chat-product-price-new {
	color: var(--pnpdi-accent-dark);
	font-weight: 700;
}

.pnpdi-chat-product-stock {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--pnpdi-muted);
}

.pnpdi-chat-product-stock-instock {
	color: var(--pnpdi-accent-dark);
}

.pnpdi-chat-product-stock-onbackorder {
	color: #a3760a;
}

.pnpdi-chat-product-stock-outofstock {
	color: #c0392b;
}

.pnpdi-chat-product-add {
	display: block;
	width: 100%;
	flex-basis: 100%;
	margin-top: 2px;
	padding: 8px 12px;
	background: var(--pnpdi-accent-dark);
	color: #fff !important;
	border: none;
	border-radius: 20px;
	font-weight: 600;
	font-size: 12.5px;
	font-family: inherit;
	text-align: center;
	text-decoration: none !important;
	cursor: pointer;
	transition: background 0.15s ease;
}

.pnpdi-chat-product-add:hover {
	background: #4c8a5d;
}

/* v1.5.13: the add-to-cart affordance is now a real <button> (AJAX add to
   cart, no page navigation — see appendProductCard()/renderProductCardContent()
   in chat-widget.js), so it needs its own disabled/in-flight state instead of
   relying on an <a>'s always-clickable nature. */
.pnpdi-chat-product-add:disabled {
	opacity: 0.7;
	cursor: default;
}

.pnpdi-chat-product-add-error {
	display: block;
	margin-top: 6px;
	font-size: 11.5px;
	color: #c0392b;
}

.pnpdi-chat-product-add-error a {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Composer: pill input + circular accent send button ---------- */

.pnpdi-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--pnpdi-line);
	background: var(--pnpdi-header-bg);
}

.pnpdi-chat-form input {
	flex: 1;
	border: 1px solid var(--pnpdi-line);
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 13.5px;
	outline: none;
	font-family: inherit;
	background: #fff;
	color: var(--pnpdi-ink);
}

.pnpdi-chat-form input:focus {
	border-color: var(--pnpdi-accent);
}

.pnpdi-chat-form button {
	background: var(--pnpdi-accent);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 38px;
	height: 38px;
	flex-shrink: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, background 0.15s ease;
}

.pnpdi-chat-form button svg {
	width: 17px;
	height: 17px;
	margin-left: 1px;
}

.pnpdi-chat-form button:not(:disabled):hover {
	background: var(--pnpdi-accent-dark);
	transform: scale(1.06);
}

.pnpdi-chat-form button:disabled {
	opacity: 0.5;
	cursor: default;
}

@media (max-width: 420px) {
	.pnpdi-chat-panel {
		right: 10px;
		left: 10px;
		width: auto;
		bottom: calc(86px + var(--pnpdi-sticky-bar-offset, 0px));
	}
	.pnpdi-chat-teaser {
		/* Beside the launcher (right:10px + 60px wide + 10px gap = 80px),
		 * not stacked above it — same reasoning as the base rule above. */
		right: 80px;
		left: 10px;
		width: auto;
		bottom: calc(10px + var(--pnpdi-sticky-bar-offset, 0px));
	}
	#pnpdi-chat-root {
		right: 10px;
		bottom: calc(10px + var(--pnpdi-sticky-bar-offset, 0px));
	}
}
