/*
 * Site Assistant widget.
 *
 * Everything is namespaced under .wda- and scoped to the mount point, because
 * this drops onto client themes we do not control. No resets, no global
 * selectors, no !important except where a theme is known to fight back.
 */

#wda-assistant-root {
	--wda-accent: #1f6feb;
	--wda-accent-2: var(--wda-accent);
	--wda-accent-ink: #ffffff;
	--wda-surface: #ffffff;
	--wda-surface-2: #f4f6f9;
	--wda-ink: #16202c;
	--wda-ink-soft: #5b6878;
	--wda-line: #e3e8ef;
	--wda-radius: 16px;
	--wda-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .14);
	--wda-font: inherit;

	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: var(--wda-font);
	line-height: 1.45;
}

#wda-assistant-root[data-position="right"] { right: 20px; }
#wda-assistant-root[data-position="left"] { left: 20px; }

#wda-assistant-root *,
#wda-assistant-root *::before,
#wda-assistant-root *::after { box-sizing: border-box; }

/* ---- Launcher ---------------------------------------------------------- */

.wda-launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px 12px 14px;
	border: 0;
	border-radius: 999px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	cursor: pointer;
	box-shadow: var(--wda-shadow);
	transition: transform .18s ease, box-shadow .18s ease;
}

.wda-launcher:hover { transform: translateY(-2px); }
.wda-launcher:focus-visible { outline: 3px solid var(--wda-accent); outline-offset: 3px; }
.wda-launcher[hidden] { display: none; }

.wda-launcher svg { width: 20px; height: 20px; flex: none; }

.wda-launcher-dot {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #ff4d4f;
	border: 2px solid var(--wda-surface);
}

/* ---- Proactive bubble -------------------------------------------------- */

.wda-nudge {
	position: absolute;
	bottom: 68px;
	width: 268px;
	padding: 14px 16px;
	border-radius: var(--wda-radius);
	background: var(--wda-surface);
	color: var(--wda-ink);
	font-size: 14px;
	box-shadow: var(--wda-shadow);
	animation: wda-rise .28s ease both;
}

#wda-assistant-root[data-position="right"] .wda-nudge { right: 0; }
#wda-assistant-root[data-position="left"] .wda-nudge { left: 0; }

.wda-nudge-close {
	position: absolute;
	top: 6px;
	right: 8px;
	border: 0;
	background: none;
	color: var(--wda-ink-soft);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 4px;
}

/* ---- Welcome introduction ----------------------------------------------

   Arrives raised and offset from the corner, holds while it is read, then
   travels down into the launcher. The travel is what makes it read as the
   assistant taking up its position rather than a banner disappearing.      */

.wda-welcome {
	position: absolute;
	bottom: 78px;
	width: 300px;
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 15px 17px;
	border-radius: var(--wda-radius);
	background: var(--wda-surface);
	color: var(--wda-ink);
	box-shadow: var(--wda-shadow);
	border-bottom: 2px solid var(--wda-accent-2);
	cursor: pointer;
	transform-origin: bottom right;
	animation: wda-welcome-in .62s cubic-bezier(.22, 1.2, .36, 1) both;
}

#wda-assistant-root[data-position="right"] .wda-welcome { right: 4px; }
#wda-assistant-root[data-position="left"]  .wda-welcome { left: 4px; transform-origin: bottom left; }

.wda-welcome-avatar {
	width: 36px;
	height: 36px;
	border-radius: 10px;
	flex: none;
	background: var(--wda-accent-2);
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 15px;
	color: var(--wda-accent-ink);
	overflow: hidden;
}

.wda-welcome-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 3px; background: #fff; }

.wda-welcome-body { min-width: 0; flex: 1; }
.wda-welcome-name { font-weight: 650; font-size: 13.5px; margin-bottom: 2px; }

.wda-welcome-text {
	font-size: 14px;
	line-height: 1.4;
	transition: opacity .3s ease;
}

.wda-welcome-text[data-swapping="1"] { opacity: 0; }

.wda-welcome-close {
	position: absolute;
	top: 6px;
	right: 8px;
	border: 0;
	background: none;
	color: var(--wda-ink-soft);
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 5px;
	border-radius: 6px;
}

.wda-welcome-close:hover { background: var(--wda-surface-2); }

/* Into the corner. Ends tiny and faded, right where the launcher sits. */
.wda-welcome[data-leaving="1"] {
	animation: wda-welcome-out .52s cubic-bezier(.5, 0, .75, 0) forwards;
	pointer-events: none;
}

@keyframes wda-welcome-in {
	from { opacity: 0; transform: translate(26px, 34px) scale(.72); }
	to   { opacity: 1; transform: translate(0, 0) scale(1); }
}

@keyframes wda-welcome-out {
	from { opacity: 1; transform: translate(0, 0) scale(1); }
	to   { opacity: 0; transform: translate(40px, 86px) scale(.18); }
}

/* Held back while the welcome is on screen, so the assistant appears to
   arrive and then take up its position, rather than the card being a
   notice floating above a button that was already there. */
.wda-launcher[data-waiting="1"] {
	opacity: 0;
	transform: scale(.5);
	pointer-events: none;
}

/* The launcher answers the arrival once, so the eye follows it down. */
.wda-launcher[data-arriving="1"] { animation: wda-launcher-land .6s cubic-bezier(.22, 1.4, .36, 1) both; }

@keyframes wda-launcher-land {
	0%   { transform: scale(.6); opacity: .25; }
	60%  { transform: scale(1.09); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
	.wda-welcome { width: calc(100vw - 36px); }
}

/* ---- Panel ------------------------------------------------------------- */

.wda-panel {
	display: flex;
	flex-direction: column;
	width: 384px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 96px);
	border-radius: 20px;
	background: var(--wda-surface);
	color: var(--wda-ink);
	box-shadow: var(--wda-shadow);
	overflow: hidden;
	animation: wda-rise .22s ease both;
}

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

@keyframes wda-rise {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: translateY(0); }
}

.wda-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
}

.wda-header-text { flex: 1; min-width: 0; }
.wda-header-name { font-weight: 650; font-size: 15px; }
.wda-header-sub { font-size: 12px; opacity: .85; }

.wda-header-btn {
	border: 0;
	background: rgba(255, 255, 255, .18);
	color: inherit;
	width: 30px;
	height: 30px;
	flex: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 17px;
	line-height: 1;
	display: grid;
	place-items: center;
}

.wda-header-btn:hover { background: rgba(255, 255, 255, .3); }

.wda-header-btn:focus-visible {
	outline: 2px solid var(--wda-accent-ink);
	outline-offset: 2px;
}

.wda-header-home svg { width: 16px; height: 16px; }

/* The header gap is sized for avatar-to-text, which is too wide between
   two small buttons. */
.wda-header-home + .wda-header-close { margin-left: -6px; }

.wda-header-btn[hidden] { display: none; }

.wda-avatar {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background: var(--wda-accent-2);
	display: grid;
	place-items: center;
	flex: none;
	font-weight: 700;
	font-size: 14px;
	overflow: hidden;
}

.wda-avatar-logo { background: #fff; }
.wda-avatar-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

/* A hairline of the secondary colour under the header, so a two-colour
   brand reads as itself rather than as one flat block. */
.wda-header { border-bottom: 2px solid var(--wda-accent-2); }

/* ---- Message log ------------------------------------------------------- */

.wda-log {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--wda-surface-2);
	scrollbar-width: thin;
}

.wda-msg {
	max-width: 86%;
	padding: 11px 14px;
	border-radius: 14px;
	font-size: 14.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: wda-rise .18s ease both;
}

.wda-msg-bot {
	align-self: flex-start;
	background: var(--wda-surface);
	border: 1px solid var(--wda-line);
	border-bottom-left-radius: 5px;
}

.wda-msg-user {
	align-self: flex-end;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
	border-bottom-right-radius: 5px;
}

.wda-msg-note {
	align-self: center;
	background: transparent;
	color: var(--wda-ink-soft);
	font-size: 12.5px;
	text-align: center;
	max-width: 100%;
	padding: 2px;
}

.wda-msg a { color: inherit; text-decoration: underline; }
.wda-msg-bot a { color: var(--wda-accent); }

/* Typing */

.wda-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }
.wda-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--wda-ink-soft);
	animation: wda-bounce 1.1s infinite ease-in-out;
}
.wda-typing span:nth-child(2) { animation-delay: .15s; }
.wda-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes wda-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .45; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- Feedback ---------------------------------------------------------- */

.wda-feedback {
	display: flex;
	gap: 6px;
	align-self: flex-start;
	margin-top: -6px;
}

.wda-feedback button {
	border: 1px solid var(--wda-line);
	background: var(--wda-surface);
	border-radius: 8px;
	padding: 3px 8px;
	font-size: 13px;
	cursor: pointer;
	color: var(--wda-ink-soft);
	line-height: 1.3;
}

.wda-feedback button:hover { border-color: var(--wda-accent); color: var(--wda-accent); }
.wda-feedback[data-done="1"] { opacity: .55; pointer-events: none; }

/* ---- Product cards ----------------------------------------------------- */

.wda-cards {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-self: stretch;
}

.wda-card {
	display: flex;
	gap: 12px;
	padding: 10px;
	border: 1px solid var(--wda-line);
	border-radius: 12px;
	background: var(--wda-surface);
	text-decoration: none;
	color: inherit;
	transition: border-color .15s ease, transform .15s ease;
}

.wda-card:hover { border-color: var(--wda-accent); transform: translateY(-1px); }

.wda-card-thumb {
	width: 54px;
	height: 54px;
	border-radius: 9px;
	object-fit: cover;
	background: var(--wda-surface-2);
	flex: none;
}

.wda-card-body { min-width: 0; flex: 1; }
.wda-card-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.wda-card-meta { font-size: 13px; color: var(--wda-ink-soft); }
.wda-card-stock { font-size: 12px; color: #b4231f; }

/* ---- Comparison -------------------------------------------------------- */

.wda-compare {
	align-self: stretch;
	overflow-x: auto;
	border: 1px solid var(--wda-line);
	border-radius: 12px;
	background: var(--wda-surface);
}

.wda-compare-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.wda-compare-table th,
.wda-compare-table td {
	padding: 9px 11px;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--wda-line);
}

.wda-compare-table tr:last-child th,
.wda-compare-table tr:last-child td { border-bottom: 0; }

.wda-compare-table tr:first-child th {
	font-weight: 600;
	background: var(--wda-surface-2);
}

.wda-compare-table th:first-child {
	color: var(--wda-ink-soft);
	font-weight: 500;
	white-space: nowrap;
}

.wda-compare-table a { color: var(--wda-accent); text-decoration: none; }
.wda-compare-table a:hover { text-decoration: underline; }

/* ---- Chips and forms --------------------------------------------------- */

.wda-chips { display: flex; flex-wrap: wrap; gap: 7px; align-self: stretch; }

.wda-chip {
	border: 1px solid var(--wda-accent-2);
	background: var(--wda-surface);
	color: var(--wda-accent);
	border-radius: 999px;
	padding: 7px 13px;
	font: inherit;
	font-size: 13.5px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}

.wda-chip:hover { background: var(--wda-accent-2); color: var(--wda-accent-ink); }

.wda-form {
	align-self: stretch;
	background: var(--wda-surface);
	border: 1px solid var(--wda-line);
	border-radius: 12px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 9px;
}

.wda-form-title { font-weight: 600; font-size: 14px; }
.wda-form label { font-size: 12.5px; color: var(--wda-ink-soft); display: block; margin-bottom: 3px; }

.wda-form input,
.wda-form textarea,
.wda-form select {
	width: 100%;
	padding: 9px 11px;
	border: 1px solid var(--wda-line);
	border-radius: 9px;
	font: inherit;
	font-size: 14px;
	color: var(--wda-ink);
	background: var(--wda-surface);
}

.wda-form input:focus,
.wda-form textarea:focus {
	outline: none;
	border-color: var(--wda-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wda-accent) 18%, transparent);
}

.wda-form-actions { display: flex; gap: 8px; margin-top: 2px; }

.wda-btn {
	border: 0;
	border-radius: 9px;
	padding: 9px 15px;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
}

.wda-btn-ghost {
	background: transparent;
	color: var(--wda-ink-soft);
	border: 1px solid var(--wda-line);
	font-weight: 500;
}

.wda-form-error { font-size: 13px; color: #b4231f; }

/* ---- Composer ---------------------------------------------------------- */

.wda-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--wda-line);
	background: var(--wda-surface);
}

.wda-input {
	flex: 1;
	resize: none;
	max-height: 110px;
	min-height: 42px;
	padding: 11px 13px;
	border: 1px solid var(--wda-line);
	border-radius: 11px;
	font: inherit;
	font-size: 14.5px;
	color: var(--wda-ink);
	background: var(--wda-surface);
}

.wda-input:focus {
	outline: none;
	border-color: var(--wda-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wda-accent) 18%, transparent);
}

.wda-icon-btn {
	width: 42px;
	height: 42px;
	flex: none;
	border: 0;
	border-radius: 11px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
	cursor: pointer;
	display: grid;
	place-items: center;
}

.wda-icon-btn[disabled] { opacity: .45; cursor: default; }
.wda-icon-btn svg { width: 19px; height: 19px; }

.wda-mic {
	background: var(--wda-surface-2);
	color: var(--wda-ink-soft);
	border: 1px solid var(--wda-line);
}

.wda-mic[data-listening="1"] { background: #b4231f; color: #fff; border-color: #b4231f; }

.wda-disclaimer {
	padding: 0 14px 10px;
	font-size: 11.5px;
	color: var(--wda-ink-soft);
	text-align: center;
	background: var(--wda-surface);
}

/* ---- Phone ------------------------------------------------------------- */

@media (max-width: 480px) {
	#wda-assistant-root { bottom: 14px; }
	#wda-assistant-root[data-position="right"] { right: 14px; }
	#wda-assistant-root[data-position="left"] { left: 14px; }

	.wda-panel {
		position: fixed;
		inset: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
	}

	.wda-launcher span { display: none; }
	.wda-launcher { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	#wda-assistant-root *, #wda-assistant-root *::before { animation: none !important; transition: none !important; }
}


/* ------------------------------------------------------------------ theme defence
   Themes and page builders reset `button`, `[type="button"]`, `input` and `a`
   globally. Those selectors carry the same specificity as our single-class
   rules, so the winner comes down to which stylesheet loads last — and that
   order is not ours to rely on: it shifts with other plugins, with caching
   layers that recombine assets, and from one request to the next. Hello
   Elementor's reset.css was repainting the chips, icons and launcher in the
   theme's pink. Restating only the properties those resets touch, scoped to
   the mount id, settles it on specificity instead of luck. Scoped to the id,
   so nothing here can leak into the surrounding page. */

#wda-assistant-root .wda-launcher {
	border: 0;
	border-radius: 999px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
}

#wda-assistant-root .wda-chip {
	border: 1px solid var(--wda-accent-2);
	border-radius: 999px;
	background: var(--wda-surface);
	color: var(--wda-accent);
}

#wda-assistant-root .wda-chip:hover {
	background: var(--wda-accent-2);
	color: var(--wda-accent-ink);
}

#wda-assistant-root .wda-icon-btn {
	border: 0;
	border-radius: 11px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
}

#wda-assistant-root .wda-header-btn {
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, .18);
	color: inherit;
}

#wda-assistant-root .wda-header-btn:hover { background: rgba(255, 255, 255, .3); }

#wda-assistant-root .wda-btn {
	border: 0;
	border-radius: 9px;
	background: var(--wda-accent);
	color: var(--wda-accent-ink);
}

#wda-assistant-root .wda-feedback button {
	border: 1px solid var(--wda-line);
	border-radius: 8px;
	background: var(--wda-surface);
	color: var(--wda-ink-soft);
}

#wda-assistant-root .wda-input {
	border: 1px solid var(--wda-line);
	border-radius: 11px;
	background: var(--wda-surface);
	color: var(--wda-ink);
}
