/* Guided negotiation chat. Colours follow the theme (Blocksy palette / WordPress presets) with neutral fallbacks. */
.swa-fab,
.swa-chat {
	--swa-accent: var(--theme-button-background-initial-color, var(--theme-palette-color-1, var(--wp--preset--color--primary, #333)));
	--swa-accent-text: var(--theme-button-text-initial-color, #fff);
	--swa-text: var(--theme-text-color, var(--theme-palette-color-3, #222));
	--swa-bg: var(--theme-palette-color-8, #fff);
	--swa-soft: var(--theme-palette-color-6, #f4f4f4);
	--swa-border: var(--theme-border-color, rgba(0, 0, 0, .12));
}

/* ---- small floating button */
.swa-fab {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 99998;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: var(--swa-accent);
	color: var(--swa-accent-text);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
	cursor: pointer;
	transition: transform .15s ease;
}
.swa-fab:hover { transform: translateY(-2px); }
.swa-fab:focus-visible { outline: 3px solid var(--swa-text); outline-offset: 2px; }
.swa-fab--left { left: calc(20px + env(safe-area-inset-left, 0px)); }
.swa-fab--right { right: calc(20px + env(safe-area-inset-right, 0px)); }
.swa-fab[hidden] { display: none; }

/* ---- panel */
.swa-chat {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 2147483000; /* above other floating chat/call bubbles while open */
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 40px);
	display: flex;
	flex-direction: column;
	background: var(--swa-bg);
	color: var(--swa-text);
	border: 1px solid var(--swa-border);
	border-radius: 16px;
	box-shadow: 0 14px 44px rgba(0, 0, 0, .2);
	font: inherit;
	overflow: hidden;
}
.swa-chat--left { left: 20px; }
.swa-chat--right { right: 20px; }
.swa-chat[hidden] { display: none; }
.swa-chat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px 12px 16px;
	border-bottom: 1px solid var(--swa-border);
	font-size: 15px;
}
.swa-chat__close {
	background: none;
	border: 0;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	min-height: 0;
	min-width: 44px;
}
.swa-chat__log {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 14px;
	background: var(--swa-soft);
	font-size: 14px;
	line-height: 1.45;
}
.swa-msg { display: flex; margin: 6px 0; }
.swa-msg--you { justify-content: flex-end; }
.swa-msg__bubble {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 14px;
	background: var(--swa-bg);
	border: 1px solid var(--swa-border);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.swa-msg--you .swa-msg__bubble { background: var(--swa-accent); color: var(--swa-accent-text); border-color: transparent; }
.swa-msg__who { display: block; opacity: .7; font-size: 11px; }
.swa-typing .swa-msg__bubble { letter-spacing: 2px; opacity: .6; }
.swa-deal {
	margin: 10px 0;
	padding: 12px;
	border-radius: 14px;
	background: var(--swa-bg);
	border: 2px solid var(--swa-accent);
	text-align: center;
}
.swa-deal__price { font-weight: 600; margin-bottom: 4px; }
.swa-deal__valid { font-size: 12px; opacity: .75; margin-bottom: 10px; }
.swa-deal__btn { display: block; width: 100%; text-align: center; }

/* ---- tap-to-reply buttons + call-back form */
.swa-chat__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--swa-border);
}
.swa-chat__actions:empty { display: none; }
.swa-chip {
	flex: 1 1 auto;
	min-height: 40px;
	padding: 8px 14px;
	border: 1px solid var(--swa-accent);
	border-radius: 999px;
	background: var(--swa-bg);
	color: var(--swa-text);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}
.swa-chip:hover { background: var(--swa-soft); }
.swa-chip--primary,
.swa-chip--primary:hover { background: var(--swa-accent); color: var(--swa-accent-text); border-color: transparent; }
.swa-lead { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.swa-lead input {
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid var(--swa-border);
	border-radius: 10px;
	font: inherit;
	font-size: 16px; /* 16px stops iOS zooming into the field */
	background: var(--swa-bg);
	color: inherit;
	box-sizing: border-box;
}
.swa-lead .button { width: 100%; min-height: 44px; }
.swa-lead__err { color: #c0392b; font-size: 13px; }
.swa-offer-wrap { margin: 10px 0; }

/* ---- mobile: compact button, chat as a bottom sheet */
@media (max-width: 600px) {
	.swa-fab { padding: 9px 14px; font-size: 13px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
	.swa-fab--left { left: calc(12px + env(safe-area-inset-left, 0px)); }
	.swa-fab--right { right: calc(12px + env(safe-area-inset-right, 0px)); }
	.swa-chat,
	.swa-chat--left,
	.swa-chat--right {
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 80vh;
		height: 80dvh;
		max-height: 80dvh;
		border-radius: 16px 16px 0 0;
		border-bottom: 0;
	}
	.swa-chip { flex: 1 1 100%; }
	html.swa-chat-open { overflow: hidden; }
	/* Hide the site's other floating bubbles (call button, WhatsApp chat) while the negotiation sheet is open. */
	html.swa-chat-open .floating-call,
	html.swa-chat-open .qlwapp__container,
	html.swa-chat-open .qlwapp { visibility: hidden !important; }
}
