/**
 * ERP Chatbot — widget del agente de ventas (estilos).
 * Ubuntu ya aplica site-wide (regla del ecomm). Colores del tema ERP.
 */

:root {
	--erpcbot-primary: #1a73e8;
	--erpcbot-primary-dark: #1557b0;
	--erpcbot-bg: #f8f9fb;
	--erpcbot-text: #1f2937;
	--erpcbot-muted: #6b7280;
	--erpcbot-border: #e5e7eb;
	--erpcbot-radius: 18px;
}

/* Burbuja flotante */
.erpcbot-bubble {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 99990;
	width: 62px; height: 62px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var(--erpcbot-primary);
	box-shadow: 0 6px 20px rgba(26, 115, 232, 0.45);
	display: flex; align-items: center; justify-content: center;
	padding: 0;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.erpcbot-bubble:hover { transform: scale(1.07); box-shadow: 0 8px 26px rgba(26, 115, 232, 0.55); }
.erpcbot-bubble.erpcbot-hidden { display: none; }
/* v1.1.3: apilado con el flotante del carrito del ecomm (right:22 bottom:22)
   — el chat va ARRIBA del carrito cuando este existe en la página.
   v1.1.4: aire generoso (28px) — antes quedaban casi pegados. */
.erpcbot-bubble.erpcbot-above-cart { bottom: 110px; }
/* v1.1.7: mecanismo CSS puro (sin depender del JS) + aire de 36px.
   :has() lo soportan todos los navegadores modernos. */
body:has(.erpc-cart-float) .erpcbot-bubble { bottom: 118px; }
/* v1.1.5: divisor entre ambos flotantes — línea sutil centrada en el aire
   para que no se mezclen visualmente. Solo existe si hay carrito. */
.erpcbot-stack-sep {
	position: fixed;
	right: 52px;
	bottom: 86px;
	width: 2px;
	height: 28px;
	background: rgba(15, 23, 42, 0.22);
	border-radius: 2px;
	z-index: 99989;
	pointer-events: none;
}
/* El divisor solo se muestra cuando hay carrito en la página. */
body:not(:has(.erpc-cart-float)) .erpcbot-stack-sep { display: none; }
.erpcbot-bubble-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #fff; }
.erpcbot-bubble-svg, .erpcbot-bubble-svg svg { width: 30px; height: 30px; color: #fff; }
.erpcbot-bubble-dot {
	position: absolute; top: 4px; right: 4px;
	width: 12px; height: 12px; border-radius: 50%;
	background: #34a853; border: 2px solid #fff;
}

/* Panel de chat */
.erpcbot-panel {
	position: fixed;
	right: 22px; bottom: 96px;
	z-index: 99991;
	width: 370px; max-width: calc(100vw - 32px);
	height: 540px; max-height: calc(100vh - 130px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
	display: none;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--erpcbot-border);
}
.erpcbot-panel.erpcbot-open { display: flex; animation: erpcbot-in 0.22s ease; }
@keyframes erpcbot-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Header con identidad */
.erpcbot-head {
	display: flex; align-items: center; gap: 10px;
	padding: 14px 16px;
	background: var(--erpcbot-primary);
	color: #fff;
}
.erpcbot-head-img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.7); }
.erpcbot-head-svg, .erpcbot-head-svg svg { width: 42px; height: 42px; color: #fff; }
.erpcbot-head-svg { background: rgba(255,255,255,.18); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.erpcbot-head-svg svg { width: 26px; height: 26px; }
.erpcbot-head-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.erpcbot-head-nombre { font-size: 0.98rem; }
.erpcbot-head-puesto { font-size: 0.74rem; opacity: 0.85; }
.erpcbot-btn-cerrar, .erpcbot-btn-phone {
	background: none; border: none; color: #fff; cursor: pointer;
	font-size: 1.35rem; line-height: 1;
	width: 34px; height: 34px; border-radius: 8px;
	display: flex; align-items: center; justify-content: center;
	opacity: 0.85;
}
.erpcbot-btn-cerrar:hover, .erpcbot-btn-phone:hover { background: rgba(255,255,255,.15); opacity: 1; }
.erpcbot-btn-phone::before { content: "📞"; font-size: 1rem; }
.erpcbot-btn-phone.erpcbot-phone-on { background: rgba(255,255,255,.25); }

/* Mensajes */
.erpcbot-msgs { flex: 1; overflow-y: auto; padding: 16px 14px; background: var(--erpcbot-bg); scrollbar-width: thin; }
.erpcbot-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.erpcbot-msg-user { justify-content: flex-end; }
.erpcbot-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.erpcbot-avatar-svg { background: var(--erpcbot-primary); color: #fff; display: flex; align-items: center; justify-content: center; }
.erpcbot-msg-bubble {
	max-width: 78%;
	padding: 10px 14px;
	border-radius: var(--erpcbot-radius);
	font-size: 0.88rem;
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
}
.erpcbot-msg-bot .erpcbot-msg-bubble { background: #fff; color: var(--erpcbot-text); border: 1px solid var(--erpcbot-border); border-bottom-left-radius: 6px; }
.erpcbot-msg-user .erpcbot-msg-bubble { background: var(--erpcbot-primary); color: #fff; border-bottom-right-radius: 6px; }
/* v1.2.0: botón "Ver en tienda" — continúa en la tienda con el filtro. */
.erpcbot-msg-bot { flex-wrap: wrap; }
.erpcbot-btn-tienda {
	display: inline-block;
	margin: 2px 0 0 36px;
	padding: 8px 16px;
	border-radius: 999px;
	background: var(--erpcbot-primary);
	color: #fff !important;
	font-size: 0.8rem;
	font-weight: 600;
	text-decoration: none;
	box-shadow: 0 3px 10px rgba(26, 115, 232, 0.35);
	transition: background 0.2s, transform 0.15s;
}
.erpcbot-btn-tienda:hover { background: var(--erpcbot-primary-dark); transform: scale(1.04); }

/* Typing */
.erpcbot-typing { display: flex; gap: 5px; padding: 0 18px 10px; background: var(--erpcbot-bg); }
.erpcbot-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--erpcbot-muted); animation: erpcbot-blink 1.2s infinite; }
.erpcbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.erpcbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes erpcbot-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Form */
.erpcbot-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--erpcbot-border); background: #fff; }
.erpcbot-input {
	flex: 1; min-width: 0;
	border: 1.5px solid var(--erpcbot-border);
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 0.88rem;
	outline: none;
	background: var(--erpcbot-bg);
}
.erpcbot-input:focus { border-color: var(--erpcbot-primary); background: #fff; }
.erpcbot-btn-mic, .erpcbot-btn-send {
	width: 42px; height: 42px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
	font-size: 1rem;
	transition: background 0.2s, transform 0.15s;
}
.erpcbot-btn-mic { background: var(--erpcbot-bg); border: 1.5px solid var(--erpcbot-border); }
.erpcbot-btn-mic::before { content: "🎤"; font-size: 1rem; }
.erpcbot-btn-mic.erpcbot-mic-on { background: #fce8e6; border-color: #ea4335; animation: erpcbot-pulse 1.4s infinite; }
.erpcbot-btn-mic.erpcbot-mic-off { opacity: 0.4; cursor: not-allowed; }
@keyframes erpcbot-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.35); } 50% { box-shadow: 0 0 0 8px rgba(234, 67, 53, 0); } }
.erpcbot-btn-send { background: var(--erpcbot-primary); color: #fff; }
.erpcbot-btn-send:hover { background: var(--erpcbot-primary-dark); transform: scale(1.06); }

/* Toast de voz */
.erpcbot-toast {
	position: fixed; bottom: 100px; right: 22px; z-index: 99992;
	background: var(--erpcbot-text); color: #fff;
	padding: 10px 16px; border-radius: 10px;
	font-size: 0.82rem; max-width: 300px;
	box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* Responsive */
@media (max-width: 480px) {
	.erpcbot-panel {
		right: 8px; left: 8px; bottom: 84px;
		width: auto; height: calc(100vh - 110px);
	}
	.erpcbot-bubble { right: 14px; bottom: 14px; width: 56px; height: 56px; }
	/* v1.1.3: en móvil el carrito está en bottom:16 (52px) → chat arriba.
	   v1.1.4: aire generoso (28px).
	   v1.1.5: divisor centrado en el aire (68..96).
	   v1.1.7: aire de 36px + :has() puro. */
	.erpcbot-bubble.erpcbot-above-cart { right: 14px; bottom: 96px; }
	body:has(.erpc-cart-float) .erpcbot-bubble { right: 14px; bottom: 104px; }
	.erpcbot-stack-sep { right: 41px; bottom: 72px; height: 28px; }
}
