/* Birdie Chat — customer widget. birdie.lv greens: accent #179252 (--bch-accent), dark #084d40 (--bch-dark), text #242424. */

#bch-root.bch-root {
	--bch-accent: #179252;
	--bch-dark: #084d40;
	--bch-ink: #242424;
	--bch-bg: #ffffff;
	--bch-soft: #f3f3f4;
	--bch-muted: #6b6b70;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	/* Exact corner + gaps come from settings (classes bch-d-*/bch-m-*, vars --bch-dx/dy/mx/my). */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	color: var(--bch-ink);
}

/*
 * Theme isolation: shop themes (Woodmart) style every button/input globally, e.g.
 * :is(.btn, .button, button, [type="button"]) with grey background, square corners,
 * uppercase text and min-height. Revert those inside the widget; every widget rule below
 * is scoped to #bch-root and therefore more specific than this reset.
 */
#bch-root :is(button, input, textarea, select) {
	all: revert;
	box-sizing: border-box;
	font: inherit;
	color: inherit;
	margin: 0;
}

#bch-root.bch-root *,
#bch-root.bch-root *::before,
#bch-root.bch-root *::after {
	box-sizing: border-box;
}

/* ---- bubble ---- */
#bch-root .bch-bubble {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--bch-accent);
	color: #fff;
	box-shadow: 0 6px 20px rgba(8, 77, 64, 0.35);
	cursor: pointer;
	transition: transform 0.15s ease;
}

#bch-root .bch-bubble:hover { transform: scale(1.05); background: var(--bch-dark); }
#bch-root .bch-bubble:focus-visible { outline: 3px solid var(--bch-accent); outline-offset: 3px; }

#bch-root .bch-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: var(--bch-dark);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 0 0 2px #fff;
}

#bch-root .bch-badge[hidden] { display: none; }

/* ---- panel ---- */
#bch-root .bch-panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	display: flex;
	flex-direction: column;
	width: 360px;
	height: 520px;
	max-height: calc(100vh - 92px - var(--bch-dy, 20px));
	overflow: hidden;
	border-radius: 14px;
	background: var(--bch-bg);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
	animation: bch-in 0.18s ease-out;
}

#bch-root .bch-panel[hidden] { display: none; }

@keyframes bch-in {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: none; }
}

#bch-root .bch-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 14px 14px 18px;
	background: var(--bch-dark);
	color: #fff;
	border-bottom: 3px solid var(--bch-accent);
}

#bch-root .bch-titles { flex: 1; min-width: 0; }
#bch-root .bch-title { font-weight: 700; font-size: 17px; }
#bch-root .bch-subtitle { font-size: 12.5px; opacity: 0.8; }

#bch-root .bch-close {
	width: 34px;
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

#bch-root .bch-close:hover,
#bch-root .bch-close:focus-visible { background: rgba(255, 255, 255, 0.12); outline: none; }

/* ---- messages ---- */
#bch-root .bch-list {
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px;
	background: var(--bch-soft);
	overscroll-behavior: contain;
}

#bch-root .bch-msg {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	margin: 0 0 10px;
}

#bch-root .bch-msg--visitor { justify-content: flex-end; }

#bch-root .bch-avatar {
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
}

#bch-root .bch-msg-bubble {
	max-width: 80%;
	padding: 8px 12px 6px;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

#bch-root .bch-msg--visitor .bch-msg-bubble {
	background: var(--bch-dark);
	color: #fff;
	border-bottom-right-radius: 4px;
}

#bch-root .bch-msg--agent .bch-msg-bubble { border-bottom-left-radius: 4px; }
#bch-root .bch-msg-author { margin-bottom: 2px; color: var(--bch-dark); font-size: 12px; font-weight: 600; }
#bch-root .bch-msg-body { white-space: pre-wrap; }
#bch-root .bch-msg-time { margin-top: 2px; font-size: 11px; opacity: 0.55; text-align: right; }
#bch-root .bch-msg-time:empty { display: none; }
#bch-root .bch-msg--pending .bch-msg-bubble { opacity: 0.7; }
#bch-root .bch-msg--failed .bch-msg-bubble { background: #5a1f1f; }

#bch-root .bch-msg-status {
	display: block;
	margin: 4px 0 0 auto;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 11.5px;
	text-align: right;
	text-decoration: underline;
	cursor: pointer;
}

#bch-root .bch-msg-status:disabled { text-decoration: none; cursor: default; }

#bch-root .bch-note {
	margin: 6px 4px 10px;
	color: var(--bch-muted);
	font-size: 12.5px;
	text-align: center;
}

/* ---- email card ---- */
#bch-root .bch-card {
	padding: 10px 12px;
	border-top: 1px solid #e6e6e8;
	background: #eef7f2;
}

#bch-root .bch-card[hidden] { display: none; }
#bch-root .bch-card-text { margin: 0 0 8px; font-size: 13px; }
#bch-root .bch-card-row { display: flex; gap: 6px; }
#bch-root .bch-card-row[hidden] { display: none; }

#bch-root .bch-card-email {
	flex: 1;
	min-width: 0;
	height: 36px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid #d3d3d8;
	border-radius: 8px;
	background: #fff;
	color: var(--bch-ink);
	font: inherit;
	font-size: 14px;
}

#bch-root .bch-card-save {
	height: 36px;
	margin: 0;
	padding: 0 14px;
	border: 0;
	border-radius: 8px;
	background: var(--bch-accent);
	color: #fff;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

#bch-root .bch-card-msg { margin: 6px 0 0; font-size: 12.5px; color: var(--bch-muted); }
#bch-root .bch-card-msg:empty { display: none; }

#bch-root .bch-card-dismiss {
	margin: 6px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--bch-muted);
	font: inherit;
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer;
}

#bch-root .bch-card-dismiss[hidden] { display: none; }

/* ---- composer ---- */
#bch-root .bch-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 10px 10px 10px 12px;
	border-top: 1px solid #e6e6e8;
	background: #fff;
}

#bch-root .bch-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
}

#bch-root .bch-input {
	flex: 1;
	min-height: 38px;
	max-height: 120px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid #d3d3d8;
	border-radius: 19px;
	background: #fff;
	color: var(--bch-ink);
	font: inherit;
	line-height: 1.35;
	resize: none;
	overflow-y: hidden;
}

#bch-root .bch-input:focus { border-color: var(--bch-accent); outline: none; box-shadow: 0 0 0 2px rgba(23, 146, 82, 0.25); }

#bch-root .bch-send {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 38px;
	width: 38px;
	height: 38px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--bch-accent);
	color: #fff;
	cursor: pointer;
}

#bch-root .bch-send:focus-visible,
#bch-root .bch-card-save:focus-visible { outline: 3px solid var(--bch-dark); outline-offset: 2px; }

/* ---- placement: corner + gap, desktop (> 480px) and mobile (<= 480px) ---- */
@media (min-width: 481px) {
	#bch-root.bch-root[class*="bch-d-"] { top: auto; right: auto; bottom: auto; left: auto; }
	#bch-root.bch-root.bch-d-bottom-right { right: var(--bch-dx); bottom: var(--bch-dy); }
	#bch-root.bch-root.bch-d-bottom-left { left: var(--bch-dx); bottom: var(--bch-dy); }
	#bch-root.bch-root.bch-d-top-right { right: var(--bch-dx); top: var(--bch-dy); }
	#bch-root.bch-root.bch-d-top-left { left: var(--bch-dx); top: var(--bch-dy); }

	/* Panel opens toward the inside of the screen. */
	#bch-root.bch-d-bottom-left .bch-panel,
	#bch-root.bch-d-top-left .bch-panel { right: auto; left: 0; }
	#bch-root.bch-d-top-right .bch-panel,
	#bch-root.bch-d-top-left .bch-panel { bottom: auto; top: 72px; }
}

@media (max-width: 480px) {
	#bch-root.bch-root[class*="bch-m-"] { top: auto; right: auto; bottom: auto; left: auto; }
	#bch-root.bch-root.bch-m-bottom-right { right: var(--bch-mx); bottom: var(--bch-my); }
	#bch-root.bch-root.bch-m-bottom-left { left: var(--bch-mx); bottom: var(--bch-my); }
	#bch-root.bch-root.bch-m-top-right { right: var(--bch-mx); top: var(--bch-my); }
	#bch-root.bch-root.bch-m-top-left { left: var(--bch-mx); top: var(--bch-my); }
	#bch-root.bch-m-top-right .bch-badge,
	#bch-root.bch-m-top-left .bch-badge { top: auto; bottom: -4px; }
}

/* ---- mobile: full screen ---- */
@media (max-width: 480px) {
	#bch-root.bch-root.bch-is-open .bch-panel {
		position: fixed;
		inset: 0;
		width: auto;
		height: auto;
		max-height: none;
		border-radius: 0;
	}

	#bch-root.bch-root.bch-is-open .bch-bubble { display: none; }
	#bch-root .bch-input { font-size: 16px; } /* avoid iOS zoom */
	html.bch-open, html.bch-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
	#bch-root .bch-panel { animation: none; }
	#bch-root .bch-bubble { transition: none; }
	#bch-root .bch-bubble:hover { transform: none; }
}

@media print {
	#bch-root.bch-root { display: none !important; }
}

/* ---- links + product cards (A.8) ---- */
#bch-root .bch-msg-col { display: flex; flex-direction: column; gap: 6px; max-width: 80%; min-width: 0; }
#bch-root .bch-msg--visitor .bch-msg-col { align-items: flex-end; }
#bch-root .bch-msg-col .bch-msg-bubble { max-width: 100%; }
#bch-root .bch-msg-body a { color: inherit; text-decoration: underline; word-break: break-all; }
#bch-root .bch-cards { display: flex; flex-direction: column; gap: 6px; width: 240px; max-width: 100%; }
#bch-root .bch-card-p {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 8px;
	border: 1px solid #e3e6e4;
	border-radius: 12px;
	background: #fff;
	color: var(--bch-ink);
	text-decoration: none;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}
#bch-root .bch-card-p:hover, #bch-root .bch-card-p:focus-visible { border-color: var(--bch-accent); outline: none; }
#bch-root .bch-card-p-img { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 8px; background: var(--bch-soft); overflow: hidden; }
#bch-root .bch-card-p-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
#bch-root .bch-card-p-info { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
#bch-root .bch-card-p-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#bch-root .bch-card-p-price { color: var(--bch-dark); font-weight: 700; }
#bch-root .bch-card-p-stock { font-size: 12px; }
#bch-root .bch-stock--instock { color: #17803d; }
#bch-root .bch-stock--onbackorder { color: #a15c00; }
#bch-root .bch-stock--outofstock { color: #b42318; }

/* ---- greeting teaser above the bubble ---- */
#bch-root .bch-teaser {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 300px;
	max-width: calc(100vw - 32px);
	animation: bch-in 0.25s ease-out;
}
#bch-root .bch-teaser-body {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	width: 100%;
	margin: 0;
	padding: 14px 16px;
	border: 0;
	border-radius: 16px;
	background: var(--bch-bg);
	color: var(--bch-ink);
	font: inherit;
	text-align: left;
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
	cursor: pointer;
}
#bch-root .bch-teaser-body:hover { box-shadow: 0 12px 36px rgba(8, 77, 64, 0.22), 0 1px 3px rgba(0, 0, 0, 0.08); }
#bch-root .bch-teaser-body:focus-visible { outline: 3px solid var(--bch-accent); outline-offset: 2px; }
#bch-root .bch-teaser-avatar {
	position: relative;
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--bch-accent);
}
#bch-root .bch-teaser-avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff; }
#bch-root .bch-teaser-initials { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #fff; font-weight: 700; font-size: 15px; }
#bch-root .bch-teaser-dot {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 12px;
	height: 12px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #22c55e;
}
#bch-root .bch-teaser-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-right: 14px; }
#bch-root .bch-teaser-name { font-size: 13px; font-weight: 700; color: var(--bch-dark); }
#bch-root .bch-teaser-text { font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
#bch-root .bch-teaser-close {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #93939d;
	cursor: pointer;
}
#bch-root .bch-teaser-close:hover, #bch-root .bch-teaser-close:focus-visible { background: var(--bch-soft); color: var(--bch-ink); outline: none; }

/* Teaser follows the bubble's corner: opens toward the inside of the screen. */
@media (min-width: 481px) {
	#bch-root.bch-d-bottom-left .bch-teaser, #bch-root.bch-d-top-left .bch-teaser { right: auto; left: 0; }
	#bch-root.bch-d-top-right .bch-teaser, #bch-root.bch-d-top-left .bch-teaser { bottom: auto; top: 72px; }
}
@media (max-width: 480px) {
	/* Compact on phones: greeting stays on one line next to a smaller logo. */
	#bch-root .bch-teaser { width: 300px; }
	#bch-root .bch-teaser-body { gap: 10px; padding: 10px 12px; border-radius: 14px; align-items: center; }
	#bch-root .bch-teaser-avatar { flex-basis: 32px; width: 32px; height: 32px; }
	#bch-root .bch-teaser-initials { font-size: 12px; }
	#bch-root .bch-teaser-dot { width: 9px; height: 9px; }
	#bch-root .bch-teaser-name { font-size: 12px; }
	#bch-root .bch-teaser-text { font-size: 14px; line-height: 1.3; }
	#bch-root .bch-teaser-content { padding-right: 18px; }
	#bch-root .bch-teaser-close { top: 4px; right: 4px; width: 22px; height: 22px; }
	#bch-root.bch-m-bottom-left .bch-teaser, #bch-root.bch-m-top-left .bch-teaser { right: auto; left: 0; }
	#bch-root.bch-m-top-right .bch-teaser, #bch-root.bch-m-top-left .bch-teaser { bottom: auto; top: 72px; }
}
@media (prefers-reduced-motion: reduce) { #bch-root .bch-teaser { animation: none; } }

/* Typing indicator: "Matīss raksta…" (spec A.10) */
#bch-root .bch-typing { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px 36px; font-size: 12.5px; color: var(--bch-muted); }
#bch-root .bch-typing-dots { position: relative; width: 26px; height: 8px; flex: none; }
#bch-root .bch-typing-dots::before { content: ''; position: absolute; left: 0; top: 1px; width: 6px; height: 6px; border-radius: 50%; background: var(--bch-accent); box-shadow: 10px 0 0 var(--bch-accent), 20px 0 0 var(--bch-accent); animation: bch-typing 1.2s infinite ease-in-out; }
@keyframes bch-typing { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #bch-root .bch-typing-dots::before { animation: none; } }
