#atelie-chatbot-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

#atelie-chatbot-toggle {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	background: #b5495b;
	color: #fff;
	font-size: 26px;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	/* Forces its own GPU compositing layer so iOS/Android Safari don't
	   drop this fixed-position button mid-scroll (a well-known mobile
	   Safari rendering bug). Kept off #atelie-chatbot-root itself because
	   a transform there would redefine the containing block for the
	   chat window's own fixed positioning on mobile (see below). */
	transform: translateZ(0);
	-webkit-transform: translateZ(0);
	will-change: transform;
}

#atelie-chatbot-toggle:hover {
	background: #963a4a;
}

#atelie-chatbot-toggle:focus-visible,
#atelie-chatbot-close:focus-visible,
#atelie-chatbot-send:focus-visible,
#atelie-chatbot-input:focus-visible {
	outline: 2px solid #f7c9d0;
	outline-offset: 2px;
}

#atelie-chatbot-window {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 340px;
	max-width: calc(100vw - 24px);
	height: 460px;
	max-height: calc(100vh - 110px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#atelie-chatbot-window[hidden] {
	display: none;
}

@media (max-width: 600px) {
	/* True viewport-fixed positioning (not relative to #atelie-chatbot-root)
	   so JS can pin it exactly to window.visualViewport — CSS dvh alone
	   does not reliably shrink for the on-screen keyboard, which is what
	   was pushing the header off-screen. JS sets top/left/width/height
	   inline once the chat opens; these are just the initial/fallback
	   values before that runs. */
	#atelie-chatbot-window {
		position: fixed;
		top: 0;
		left: 0;
		right: auto;
		bottom: auto;
		width: 100vw;
		max-width: 100vw;
		height: 100vh;
		height: 100dvh;
		max-height: 100vh;
		max-height: 100dvh;
		border-radius: 0;
	}

	.atelie-chatbot-header {
		padding-top: calc(12px + env(safe-area-inset-top));
	}

	#atelie-chatbot-form {
		padding-bottom: calc(8px + env(safe-area-inset-bottom));
	}
}

.atelie-chatbot-header {
	background: #b5495b;
	color: #fff;
	padding: 12px 14px;
	font-size: 15px;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 2;
	flex-shrink: 0;
}

#atelie-chatbot-close {
	width: 44px;
	height: 44px;
	background: none;
	border: none;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	margin-right: -10px;
}

#atelie-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f7f4f2;
}

.atelie-chatbot-msg {
	max-width: 85%;
	padding: 8px 12px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.4;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.atelie-chatbot-msg.user {
	align-self: flex-end;
	background: #b5495b;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.atelie-chatbot-msg.assistant {
	align-self: flex-start;
	background: #fff;
	color: #222;
	border: 1px solid #e4dedb;
	border-bottom-left-radius: 4px;
}

.atelie-chatbot-msg.error {
	align-self: flex-start;
	background: #fde7e7;
	color: #8a1f1f;
	border: 1px solid #f3c2c2;
}

.atelie-chatbot-msg a {
	color: #b5495b;
	text-decoration: underline;
	word-break: break-all;
}

.atelie-chatbot-msg.error a {
	color: #8a1f1f;
}

.atelie-chatbot-social-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	white-space: normal;
	gap: 6px;
	margin: 4px 0;
}

.atelie-chatbot-social {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	color: #fff !important;
	text-decoration: none !important;
	vertical-align: middle;
	flex-shrink: 0;
}

.atelie-chatbot-social svg {
	width: 36px;
	height: 36px;
}

.atelie-chatbot-social-vk {
	background: #0077ff;
}

.atelie-chatbot-social-telegram {
	background: #229ed9;
}

.atelie-chatbot-social-whatsapp {
	background: #25d366;
}

.atelie-chatbot-msg.pending {
	align-self: flex-start;
	background: #fff;
	color: #999;
	border: 1px solid #e4dedb;
	font-style: italic;
}

#atelie-chatbot-form {
	display: flex;
	border-top: 1px solid #e4dedb;
	padding: 8px;
	gap: 6px;
	background: #fff;
}

#atelie-chatbot-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 8px 14px;
	font-size: 16px;
	outline: none;
}

#atelie-chatbot-input:focus {
	border-color: #b5495b;
}

#atelie-chatbot-send {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: #b5495b;
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#atelie-chatbot-send:disabled {
	background: #ccc;
	cursor: default;
	opacity: 0.6;
}
