/* Woo AI Chatbot widget. Colours, size and font come from the settings page as CSS variables. */
#wac-root {
	--wac-accent: #2563eb;
	--wac-on-accent: #fff;
	--wac-header-bg: #fff;
	--wac-header-text: #1d2327;
	--wac-panel-bg: #fff;
	--wac-ink: #1d2327;
	--wac-bot-bg: #f3f4f6;
	--wac-bot-text: #1d2327;
	--wac-radius: 16px;
	--wac-width: 380px;
	--wac-offset-x: 20px;
	--wac-offset-y: 20px;
	--wac-font: inherit;
	--wac-muted: color-mix(in srgb, var(--wac-ink) 62%, transparent);
	--wac-line: color-mix(in srgb, var(--wac-ink) 13%, transparent);
	--wac-soft: color-mix(in srgb, var(--wac-ink) 6%, transparent);
	--wac-r-sm: min(var(--wac-radius), 10px);

	position: fixed;
	bottom: var(--wac-offset-y);
	z-index: 99999;
	font-family: var(--wac-font);
	font-size: 15px;
	line-height: 1.45;
	color: var(--wac-ink);
	text-align: left;
}
#wac-root.wac-pos-right { right: var(--wac-offset-x); }
#wac-root.wac-pos-left { left: var(--wac-offset-x); }
#wac-root *, #wac-root *::before, #wac-root *::after { box-sizing: border-box; }
#wac-root button, #wac-root input, #wac-root textarea { font: inherit; letter-spacing: normal; text-transform: none; }
#wac-root button { cursor: pointer; }
#wac-root :focus-visible { outline: 2px solid var(--wac-accent); outline-offset: 2px; }
#wac-root svg { display: block; }
#wac-root p { margin: 0; }

/* ---------- Launcher ---------- */
.wac-launcher {
	display: flex; align-items: center; gap: 10px;
	border: 0; padding: 0; background: none; margin-left: auto;
}
.wac-pos-left .wac-launcher { margin-left: 0; flex-direction: row-reverse; }
.wac-launcher-icon {
	width: 58px; height: 58px; border-radius: 50%; flex: 0 0 58px;
	background: var(--wac-accent); color: var(--wac-on-accent);
	display: grid; place-items: center; overflow: hidden;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
	transition: transform .15s ease;
}
.wac-launcher:hover .wac-launcher-icon { transform: scale(1.05); }
.wac-launcher-icon > * { grid-area: 1 / 1; }
.wac-launcher-icon svg { width: 26px; height: 26px; }
.wac-launcher-icon.has-logo { background: #fff; }
.wac-launcher-icon.has-logo img { width: 100%; height: 100%; object-fit: cover; }
.wac-ico-close { display: none !important; }
.wac-open .wac-ico-chat, .wac-open .wac-launcher-icon img { display: none; }
.wac-open .wac-ico-close { display: block !important; }
.wac-open .wac-launcher-icon.has-logo { background: var(--wac-accent); }
.wac-launcher-text {
	order: -1;
	background: var(--wac-panel-bg); color: var(--wac-ink);
	padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .14); white-space: nowrap;
}
.wac-pos-left .wac-launcher-text { order: 1; }
.wac-open .wac-launcher-text { display: none; }

/* ---------- Panel ---------- */
.wac-panel {
	position: absolute; bottom: 72px;
	width: var(--wac-width); height: min(640px, calc(100vh - 110px - var(--wac-offset-y)));
	background: var(--wac-panel-bg);
	border: 1px solid var(--wac-line);
	border-radius: var(--wac-radius);
	box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
	display: flex; flex-direction: column; overflow: hidden;
	transform-origin: bottom right;
	animation: wac-in .18s ease-out;
}
.wac-pos-right .wac-panel { right: 0; }
.wac-pos-left .wac-panel { left: 0; transform-origin: bottom left; }
.wac-panel[hidden] { display: none; }
@keyframes wac-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.wac-header {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 12px 10px 12px 14px;
	background: var(--wac-header-bg); color: var(--wac-header-text);
	border-bottom: 1px solid var(--wac-line);
}
.wac-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wac-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: 0 0 38px; background: #fff; }
.wac-logo-initial {
	display: grid; place-items: center;
	background: var(--wac-accent); color: var(--wac-on-accent); font-weight: 700; font-size: 17px;
}
.wac-names { display: flex; flex-direction: column; min-width: 0; }
.wac-brand-name { font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wac-tagline { font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wac-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.wac-hbtn {
	background: none; border: 0; color: inherit; opacity: .75;
	width: 34px; height: 34px; border-radius: 8px; padding: 0;
	display: grid; place-items: center;
}
.wac-hbtn:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.wac-hbtn svg { width: 20px; height: 20px; }

/* ---------- Messages ---------- */
.wac-log {
	flex: 1; overflow-y: auto; padding: 16px 14px;
	display: flex; flex-direction: column; gap: 12px;
	overscroll-behavior: contain;
}
.wac-row { display: flex; gap: 8px; align-items: flex-start; }
.wac-user { justify-content: flex-end; }
.wac-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 88%; }
.wac-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: 0 0 28px; margin-top: 2px; }
.wac-bubble {
	padding: 9px 13px; border-radius: var(--wac-r-sm); overflow-wrap: anywhere;
	width: fit-content; max-width: 100%;
}
.wac-bot .wac-bubble { background: var(--wac-bot-bg); color: var(--wac-bot-text); border-top-left-radius: 4px; }
.wac-user .wac-bubble {
	background: var(--wac-accent); color: var(--wac-on-accent);
	border-top-right-radius: 4px; white-space: pre-wrap; max-width: 85%;
}
.wac-error .wac-bubble { background: #fdecec; color: #8a1f1f; white-space: pre-wrap; }
.wac-bubble p + p, .wac-bubble p + ul, .wac-bubble ul + p { margin-top: 6px; }
.wac-bubble ul { margin: 4px 0 0; padding-left: 18px; }
.wac-bubble li { margin: 2px 0; }
.wac-bubble a { color: inherit; text-decoration: underline; }
.wac-caret {
	display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
	background: currentColor; opacity: .5; animation: wac-blink 1s steps(2) infinite;
}
.wac-live .wac-bubble p:last-of-type { display: inline; }

/* Typing / status */
.wac-typing .wac-bubble { display: flex; align-items: center; gap: 8px; padding: 11px 13px; }
.wac-dots { display: flex; gap: 4px; }
.wac-dots i {
	width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .3;
	animation: wac-pulse 1.2s infinite ease-in-out;
}
.wac-dots i:nth-child(2) { animation-delay: .15s; }
.wac-dots i:nth-child(3) { animation-delay: .3s; }
.wac-status { font-size: 13px; opacity: .75; }
.wac-status:empty { display: none; }
@keyframes wac-pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }
@keyframes wac-blink { 50% { opacity: 0; } }

/* Feedback */
.wac-feedback { display: flex; align-items: center; gap: 2px; margin-top: -2px; }
.wac-fb {
	width: 28px; height: 28px; border: 0; border-radius: 6px; padding: 0;
	background: none; color: var(--wac-muted);
	display: grid; place-items: center;
}
.wac-fb svg { width: 16px; height: 16px; }
.wac-fb-down svg { transform: rotate(180deg); }
.wac-fb:hover { background: var(--wac-soft); color: var(--wac-ink); }
.wac-fb[aria-pressed="true"] { color: var(--wac-accent); }
.wac-fb[aria-pressed="true"] svg path { fill: currentColor; fill-opacity: .18; }
.wac-fb-thanks { font-size: 12px; color: var(--wac-muted); margin-left: 4px; display: none; }
.wac-thanks .wac-fb-thanks { display: inline; }

/* Product cards */
.wac-cards {
	display: flex; gap: 10px; overflow-x: auto;
	padding: 2px 2px 6px; scroll-snap-type: x mandatory;
}
.wac-card {
	flex: 0 0 146px; scroll-snap-align: start;
	display: flex; flex-direction: column; gap: 3px;
	border: 1px solid var(--wac-line); border-radius: var(--wac-r-sm);
	padding: 8px; background: var(--wac-panel-bg);
	color: var(--wac-ink); text-decoration: none;
}
.wac-card:hover { border-color: var(--wac-accent); }
.wac-card img {
	width: 100%; aspect-ratio: 1; object-fit: cover;
	border-radius: calc(var(--wac-r-sm) - 3px); background: var(--wac-soft); margin-bottom: 4px;
}
.wac-card-name {
	font-size: 13px; line-height: 1.3;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wac-card-price { font-size: 13px; font-weight: 600; }
.wac-card-stock { font-size: 12px; color: #b23b3b; }

/* Suggestions */
.wac-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.wac-chip {
	background: var(--wac-panel-bg); color: var(--wac-ink);
	border: 1px solid var(--wac-line); border-radius: 999px;
	padding: 6px 12px; font-size: 13px;
}
.wac-chip:hover { border-color: var(--wac-accent); color: var(--wac-accent); }

/* Notes (handoff confirmation etc.) */
.wac-note {
	align-self: stretch; text-align: center; font-size: 13.5px;
	padding: 10px 12px; border-radius: var(--wac-r-sm);
	border: 1px dashed var(--wac-line); color: var(--wac-muted);
	display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* ---------- Forms (lead + handoff) ---------- */
.wac-card-form {
	border: 1px solid var(--wac-line); border-radius: var(--wac-r-sm);
	padding: 14px; background: var(--wac-panel-bg);
	display: flex; flex-direction: column; gap: 10px; margin: 0;
}
.wac-form-title { font-weight: 600; font-size: 14.5px; }
.wac-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.wac-label { font-size: 13px; color: var(--wac-muted); }
.wac-field input, .wac-field textarea {
	width: 100%; margin: 0; padding: 8px 10px; font-size: 15px;
	border: 1px solid var(--wac-line); border-radius: 8px;
	background: var(--wac-panel-bg); color: var(--wac-ink); box-shadow: none; min-height: 0;
}
.wac-field textarea { resize: vertical; min-height: 64px; }
.wac-field input:focus, .wac-field textarea:focus { outline: none; border-color: var(--wac-accent); }
.wac-field [aria-invalid="true"] { border-color: #c62828; }
.wac-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--wac-muted); margin: 0; }
.wac-consent input { margin: 3px 0 0; flex: 0 0 auto; }
.wac-form-error { color: #c62828; font-size: 13px; }
.wac-form-error:empty { display: none; }
.wac-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wac-btn {
	border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
	font-size: 14px; font-weight: 600; text-decoration: none; line-height: 1.3;
	display: inline-flex; align-items: center; gap: 6px;
}
.wac-btn-primary { background: var(--wac-accent); color: var(--wac-on-accent); }
.wac-btn-primary:disabled { opacity: .6; }
.wac-btn-ghost { background: none; color: var(--wac-muted); }
.wac-btn-ghost:hover { color: var(--wac-ink); background: var(--wac-soft); }
.wac-btn-wa { background: #25d366; color: #fff; }
.wac-btn-wa svg { width: 18px; height: 18px; }

/* ---------- Composer ---------- */
.wac-form {
	display: flex; align-items: flex-end; gap: 8px;
	padding: 10px 12px 12px; border-top: 1px solid var(--wac-line); margin: 0;
}
.wac-form.is-disabled { opacity: .5; }
.wac-input {
	flex: 1; resize: none; min-height: 40px; max-height: 120px;
	border: 1px solid var(--wac-line); border-radius: var(--wac-r-sm);
	padding: 9px 12px; font-size: 15px; color: var(--wac-ink);
	background: var(--wac-panel-bg); margin: 0; box-shadow: none;
}
.wac-input::placeholder { color: var(--wac-muted); }
.wac-input:focus { outline: none; border-color: var(--wac-accent); }
.wac-send {
	width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: var(--wac-r-sm);
	background: var(--wac-accent); color: var(--wac-on-accent);
	display: grid; place-items: center; padding: 0;
}
.wac-send:disabled { opacity: .5; cursor: default; }
.wac-send svg { width: 20px; height: 20px; }
.wac-footer { font-size: 11.5px; color: var(--wac-muted); text-align: center; padding: 0 12px 10px; margin-top: -4px; }
.wac-footer[hidden] { display: none; }

/* ---------- Phones: full-screen panel ---------- */
@media (max-width: 600px) {
	#wac-root:not(.wac-preview) { bottom: min(var(--wac-offset-y), 16px); }
	#wac-root.wac-pos-right:not(.wac-preview) { right: min(var(--wac-offset-x), 16px); }
	#wac-root.wac-pos-left:not(.wac-preview) { left: min(var(--wac-offset-x), 16px); }
	#wac-root:not(.wac-preview) .wac-panel {
		position: fixed; inset: 0; width: auto; height: 100%;
		border-radius: 0; border: 0;
		padding-top: env(safe-area-inset-top, 0);
		padding-bottom: env(safe-area-inset-bottom, 0);
	}
	#wac-root:not(.wac-preview).wac-open .wac-launcher { display: none; }
	.wac-launcher-text { display: none; }
	.wac-input, .wac-field input, .wac-field textarea { font-size: 16px; } /* stops iOS zoom */
}

@media (prefers-reduced-motion: reduce) {
	.wac-panel, .wac-dots i, .wac-caret { animation: none; }
	.wac-launcher-icon { transition: none; }
}
