/* ZD Chatbot — widget público (estilo WhatsApp) */

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

/* Neutralizar márgenes/estilos que el tema aplica a botones e inputs globalmente
   (ej: button/input { margin-bottom: 1em }), acotado solo a nuestro widget. */
.zd-chatbot button,
.zd-chatbot input,
.zd-chatbot textarea,
.zd-chatbot select {
	margin: 0;
}

/* Lanzador: cartelito (CTA) + burbuja, en fila */
.zd-chatbot-launcher {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
}

/* Cartelito "¿Necesitás ayuda?" junto a la burbuja (estilo Joinchat) */
.zd-chatbot-cta {
	background: #fff;
	color: #1f2937;
	border: none;
	padding: 10px 16px;
	border-radius: 24px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	white-space: nowrap;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	font-family: inherit;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.zd-chatbot-cta:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
.zd-chatbot.is-open .zd-chatbot-cta {
	display: none;
}

/* Botón flotante */
.zd-chatbot-toggle {
	width: 70px;
	height: 70px;
	border-radius: 50%;
	border: none;
	background: var(--zd-chatbot-color);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
	margin-left: auto;
}
.zd-chatbot-toggle:hover {
	transform: scale(1.06);
}
.zd-chatbot-icon-close {
	display: none;
}
.zd-chatbot.is-open .zd-chatbot-icon-open {
	display: none;
}
.zd-chatbot.is-open .zd-chatbot-icon-close {
	display: block;
}

/* Avatar como ícono del botón (opción del admin): fondo blanco y borde del color
   del widget mientras está cerrado; abierto vuelve al fondo de color con la X. */
.zd-chatbot.has-launcher-avatar:not(.is-open) .zd-chatbot-toggle {
	background: #fff;
	border: 2px solid var(--zd-chatbot-color);
	padding: 0;
	overflow: hidden;
}
.zd-chatbot-launcher-avatar {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
	display: block;
}

/* Panel */
.zd-chatbot-panel {
	position: absolute;
	right: 0;
	bottom: 74px;
	width: 400px;
	max-width: calc(100vw - 40px);
	height: 830px;
	max-height: calc(100vh - 120px);
	background: #efeae2;
	border-radius: 14px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}
.zd-chatbot.is-open .zd-chatbot-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Header */
.zd-chatbot-header {
	background: var(--zd-chatbot-color);
	color: #fff;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.zd-chatbot-header-info {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}
.zd-chatbot-header-info strong {
	font-size: 15px;
}
.zd-chatbot-header-info span {
	font-size: 12px;
	opacity: 0.9;
}
.zd-chatbot-header-actions {
	display: flex;
	align-items: center;
	gap: 2px;
}
.zd-chatbot-header-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	opacity: 0.9;
}
.zd-chatbot-header-close:hover {
	opacity: 1;
}
.zd-chatbot-header-end {
	background: rgba(255, 255, 255, 0.18);
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 5px 10px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	border-radius: 14px;
	opacity: 0.95;
	transition: opacity 0.15s ease, background 0.15s ease;
}
.zd-chatbot-header-end:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.3);
}
.zd-chatbot-header-end[hidden] {
	display: none;
}

/* Mensajes */
.zd-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
/* Contenedor del mensaje. La burbuja en sí es .zd-chatbot-bubble; este div solo alinea
   (izquierda el bot, derecha el visitante) y, cuando hay avatar, arma la fila cara + burbuja. */
.zd-chatbot-msg {
	display: flex;
	max-width: 85%;
}
.zd-chatbot-msg-bot {
	align-self: flex-start;
}
.zd-chatbot-msg-user {
	align-self: flex-end;
}
/* La cara ocupa una columna a la izquierda; se le da un poco más de ancho a la fila del
   bot para que la burbuja no quede tan angosta y la respuesta no se pegue al margen. */
.zd-chatbot-msg-has-avatar {
	max-width: 92%;
}

/* La burbuja: lo que antes era .zd-chatbot-msg. */
.zd-chatbot-bubble {
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 16px;
	line-height: 1.4;
	word-wrap: break-word;
	white-space: pre-wrap;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.zd-chatbot-msg-bot .zd-chatbot-bubble {
	background: #fff;
	border-top-left-radius: 2px;
}
.zd-chatbot-msg-user .zd-chatbot-bubble {
	background: #d9fdd3;
	border-top-right-radius: 2px;
}
.zd-chatbot-bubble a {
	color: #0a7cff;
	text-decoration: underline;
	word-break: break-all;
}
.zd-chatbot-msg-user .zd-chatbot-bubble a {
	color: #047857;
}

/* Avatar del bot: columna fija a la izquierda de la burbuja. La cara se alinea arriba,
   a la altura de la primera línea del mensaje. El ancho se reserva siempre; el <img> solo
   se pinta en el primer mensaje de una tanda (lo decide el JS), así respuestas seguidas
   quedan alineadas sin repetir la cara. */
.zd-chatbot-msg-has-avatar {
	align-items: flex-start;
	gap: 8px;
}
.zd-chatbot-avatar {
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
}
.zd-chatbot-avatar img {
	width: 36px;
	/* height: 36px; */
	border-radius: 50%;
	object-fit: contain;
	display: block;
}

/* Indicador de "escribiendo" */
.zd-chatbot-typing {
	align-self: flex-start;
	background: #fff;
	padding: 10px 14px;
	border-radius: 8px;
	border-top-left-radius: 2px;
	display: inline-flex;
	gap: 4px;
}
.zd-chatbot-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9aa0a6;
	animation: zd-chatbot-bounce 1.2s infinite ease-in-out;
}
.zd-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.zd-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes zd-chatbot-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* Formulario */
.zd-chatbot-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	background: #f0f0f0;
	flex-shrink: 0;
}
.zd-chatbot-input {
	flex: 1;
	border: none;
	border-radius: 20px;
	padding: 10px 14px;
	font-size: 16px;
	outline: none;
	background: #fff;
}
.zd-chatbot-send {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	border: none;
	background: var(--zd-chatbot-color);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.zd-chatbot-send:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Botones de motivo de contacto (respuesta rápida al iniciar la charla). */
.zd-chatbot-motivos {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 4px 0 8px;
}
.zd-chatbot-motivos-title {
	width: 100%;
	font-size: 13px;
	color: #555;
	margin-bottom: 2px;
}
.zd-chatbot-motivo {
	background: #fff;
	border: 1.5px solid var(--zd-chatbot-color);
	color: var(--zd-chatbot-color);
	border-radius: 14px;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}
.zd-chatbot-motivo:hover {
	background: var(--zd-chatbot-color);
	color: #fff !important;
}

/* Botón de contacto por WhatsApp dentro de un mensaje del bot. */
.zd-chatbot-wa-btn {
	display: inline-block;
	margin: 6px 0 2px;
	padding: 9px 16px;
	background: #25d366;
	color: #fff !important;
	border-radius: 20px;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.2;
	text-decoration: none !important;
	transition: background 0.15s ease;
	/* Evitar que el contenedor (que corta palabras largas para las URLs) parta
	   "WhatsApp" a la mitad: puede saltar de renglón entre palabras, no dentro. */
	word-break: keep-all;
	overflow-wrap: normal;
}
.zd-chatbot-wa-btn::before {
	content: "💬 ";
}
.zd-chatbot-wa-btn:hover,
.zd-chatbot-wa-btn:focus {
	background: #1ebe57;
	color: #fff !important;
}

@media screen and (max-width: 480px) {
	.zd-chatbot { right: 14px; bottom: 14px; }
	.zd-chatbot-panel {
		width: calc(100vw - 28px);
		height: calc(100vh - 100px);
	}
}
