/*
 * Estilos del widget de chat (frontend).
 * Usa variables CSS (custom properties) para que la personalización visual
 * del panel de administración se refleje aquí sin tocar este archivo.
 * Inspirado visualmente en widgets de chat tipo Tidio: burbuja flotante,
 * ventana con cabecera de color, mensajes en burbujas redondeadas.
 */

.chatbot-faq-widget {
	--cfq-principal: #2563eb;
	--cfq-texto-mensajes: #1f2937;
	--cfq-fondo-mensajes: #ffffff;
	--cfq-fondo-panel: #f2f4f8;

	position: fixed;
	z-index: 999999;
	bottom: 24px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.4;
}

.chatbot-faq-widget.chatbot-faq-pos-derecha {
	right: 24px;
}

.chatbot-faq-widget.chatbot-faq-pos-izquierda {
	left: 24px;
}

.chatbot-faq-widget * {
	box-sizing: border-box;
}

/* --- Burbuja flotante (píldora con icono + texto) --- */

.chatbot-faq-burbuja {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: var( --cfq-principal );
	color: #ffffff;
	border: none;
	border-radius: 999px;
	padding: 14px 20px 14px 14px;
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.18 );
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chatbot-faq-widget.chatbot-faq-pos-izquierda .chatbot-faq-burbuja {
	padding: 14px 14px 14px 20px;
	flex-direction: row-reverse;
}

.chatbot-faq-burbuja:hover {
	transform: translateY( -2px );
	box-shadow: 0 10px 28px rgba( 0, 0, 0, 0.22 );
}

.chatbot-faq-burbuja-icono {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
}

.chatbot-faq-burbuja-icono svg {
	width: 100%;
	height: 100%;
}

.chatbot-faq-widget.chatbot-faq-abierto .chatbot-faq-burbuja {
	display: none;
}

/* --- Ventana del chat --- */

.chatbot-faq-ventana {
	position: absolute;
	bottom: 76px;
	width: 370px;
	max-width: calc( 100vw - 32px );
	height: 540px;
	max-height: calc( 100vh - 140px );
	background: var( --cfq-fondo-panel );
	border-radius: 18px;
	box-shadow: 0 16px 48px rgba( 0, 0, 0, 0.24 );
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY( 16px ) scale( 0.97 );
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.chatbot-faq-widget.chatbot-faq-pos-derecha .chatbot-faq-ventana {
	right: 0;
}

.chatbot-faq-widget.chatbot-faq-pos-izquierda .chatbot-faq-ventana {
	left: 0;
}

.chatbot-faq-widget.chatbot-faq-abierto .chatbot-faq-ventana {
	opacity: 1;
	transform: translateY( 0 ) scale( 1 );
	pointer-events: auto;
}

/* Versión embebida (shortcode): sin posición fija, tamaño de tarjeta normal. */

.chatbot-faq-widget.chatbot-faq-embebido {
	position: relative;
	bottom: auto;
	right: auto;
	left: auto;
	display: block;
}

.chatbot-faq-widget.chatbot-faq-embebido .chatbot-faq-ventana {
	position: relative;
	bottom: auto;
	right: auto;
	left: auto;
	width: 100%;
	max-width: 420px;
	height: 560px;
	max-height: 80vh;
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

/* --- Cabecera --- */

.chatbot-faq-cabecera {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	background: var( --cfq-principal );
	color: #ffffff;
	flex-shrink: 0;
}

.chatbot-faq-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba( 255, 255, 255, 0.25 );
	flex-shrink: 0;
}

.chatbot-faq-avatar-generico {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.25 );
	flex-shrink: 0;
}

.chatbot-faq-avatar-generico svg {
	width: 22px;
	height: 22px;
}

.chatbot-faq-cabecera-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.chatbot-faq-nombre {
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chatbot-faq-estado {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
}

.chatbot-faq-estado::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #22c55e;
}

.chatbot-faq-cerrar {
	margin-left: auto;
	background: transparent;
	border: none;
	color: #ffffff;
	opacity: 0.85;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 4px 6px;
	border-radius: 6px;
}

.chatbot-faq-cerrar:hover {
	opacity: 1;
	background: rgba( 255, 255, 255, 0.15 );
}

/* --- Mensajes --- */

.chatbot-faq-mensajes {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* --- Opciones rápidas (conversación guiada) --- */

.chatbot-faq-opciones-rapidas {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-self: flex-start;
	max-width: 100%;
}

.chatbot-faq-opcion-rapida {
	background: #ffffff;
	color: var( --cfq-principal );
	border: 1.5px solid var( --cfq-principal );
	border-radius: 999px;
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.chatbot-faq-opcion-rapida:hover {
	background: var( --cfq-principal );
	color: #ffffff;
}

.chatbot-faq-mensaje {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	word-wrap: break-word;
	white-space: pre-wrap;
}

.chatbot-faq-mensaje--bot {
	align-self: flex-start;
	background: var( --cfq-fondo-mensajes );
	color: var( --cfq-texto-mensajes );
	border-radius: 14px 14px 14px 4px;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.08 );
}

.chatbot-faq-mensaje--usuario {
	align-self: flex-end;
	background: var( --cfq-principal );
	color: #ffffff;
	border-radius: 14px 14px 4px 14px;
}

.chatbot-faq-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var( --cfq-fondo-mensajes );
	border-radius: 14px 14px 14px 4px;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.08 );
	margin: 0 16px 8px;
	width: fit-content;
}

/* El atributo "hidden" tiene menos especificidad que ".chatbot-faq-typing"
 * de arriba, así que sin esta regla el "display: flex" lo pisa y el
 * indicador de "escribiendo" nunca llega a ocultarse. */
.chatbot-faq-typing[hidden] {
	display: none;
}

.chatbot-faq-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var( --cfq-texto-mensajes );
	opacity: 0.4;
	animation: chatbot-faq-parpadeo 1.1s infinite ease-in-out;
}

.chatbot-faq-typing span:nth-child( 2 ) {
	animation-delay: 0.15s;
}

.chatbot-faq-typing span:nth-child( 3 ) {
	animation-delay: 0.3s;
}

@keyframes chatbot-faq-parpadeo {
	0%, 60%, 100% {
		opacity: 0.3;
		transform: translateY( 0 );
	}
	30% {
		opacity: 1;
		transform: translateY( -3px );
	}
}

/* --- Formulario de envío --- */

.chatbot-faq-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px;
	background: var( --cfq-fondo-mensajes );
	border-top: 1px solid rgba( 0, 0, 0, 0.08 );
	flex-shrink: 0;
}

.chatbot-faq-input {
	flex: 1;
	border: 1px solid rgba( 0, 0, 0, 0.12 );
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	background: #ffffff;
	color: var( --cfq-texto-mensajes );
}

.chatbot-faq-input:focus {
	border-color: var( --cfq-principal );
}

.chatbot-faq-enviar {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var( --cfq-principal );
	color: #ffffff;
	border: none;
	cursor: pointer;
	flex-shrink: 0;
	transition: filter 0.15s ease;
}

.chatbot-faq-enviar:hover {
	filter: brightness( 0.92 );
}

.chatbot-faq-enviar:disabled {
	opacity: 0.6;
	cursor: default;
}

.chatbot-faq-enviar svg {
	width: 16px;
	height: 16px;
}

/* --- Responsive: pantalla completa en móvil --- */

@media ( max-width: 480px ) {
	.chatbot-faq-widget:not( .chatbot-faq-embebido ) .chatbot-faq-ventana {
		position: fixed;
		inset: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}
}
