/* Chatbot Catálogo y Ventas – estilos. Todo va bajo #cbc-root para no chocar con el tema. */

#cbc-root {
	--cbc-accent-dark: var(--cbc-accent);
	--cbc-ink: #172029;
	--cbc-mute: #5b6975;
	--cbc-bg: #f3f5f7;
	--cbc-card: #ffffff;
	--cbc-line: #dde3e8;
	--cbc-danger: #b3261e;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--cbc-ink);
	-webkit-text-size-adjust: 100%;
}
@supports (color: color-mix(in srgb, red, blue)) {
	#cbc-root { --cbc-accent-dark: color-mix(in srgb, var(--cbc-accent) 78%, #000); }
}
#cbc-root.cbc-pos-right { right: 20px; }
#cbc-root.cbc-pos-left { left: 20px; }

#cbc-root *, #cbc-root *::before, #cbc-root *::after { box-sizing: border-box; }
#cbc-root [hidden] { display: none !important; }
#cbc-root button, #cbc-root input, #cbc-root textarea {
	font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none; text-shadow: none;
}
#cbc-root button { cursor: pointer; }
#cbc-root a { color: var(--cbc-accent); text-decoration: underline; text-underline-offset: 2px; }
#cbc-root :focus-visible { outline: 2px solid var(--cbc-accent); outline-offset: 2px; }

#cbc-root .cbc-ico { display: inline-flex; width: 20px; height: 20px; flex: none; }
#cbc-root .cbc-ico svg { width: 100%; height: 100%; }

/* Botón flotante */
#cbc-root .cbc-launcher {
	display: flex; align-items: center; justify-content: center;
	width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%;
	background: var(--cbc-accent); color: #fff;
	box-shadow: 0 6px 20px rgba(15, 30, 45, .28);
	transition: transform .15s ease, background-color .15s ease;
}
#cbc-root .cbc-launcher:hover { background: var(--cbc-accent-dark); transform: scale(1.05); }
#cbc-root .cbc-launcher .cbc-ico { width: 26px; height: 26px; }
#cbc-root .cbc-launcher:focus-visible { outline-color: var(--cbc-ink); }
#cbc-root.is-open .cbc-launcher { display: none; }

/* Panel */
#cbc-root .cbc-panel {
	position: absolute; bottom: 0;
	width: 392px; height: min(680px, calc(100vh - 40px)); height: min(680px, calc(100dvh - 40px));
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--cbc-bg); border-radius: 18px;
	box-shadow: 0 18px 50px rgba(15, 30, 45, .3), 0 0 0 1px rgba(15, 30, 45, .06);
	visibility: hidden; opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right;
	transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
#cbc-root.cbc-pos-right .cbc-panel { right: 0; }
#cbc-root.cbc-pos-left .cbc-panel { left: 0; transform-origin: bottom left; }
#cbc-root.is-open .cbc-panel { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }

/* Encabezado */
#cbc-root .cbc-head {
	display: flex; align-items: center; gap: 6px; padding: 12px 10px 12px 14px;
	background: var(--cbc-accent); color: #fff;
}
#cbc-root .cbc-avatar {
	flex: none; display: flex; align-items: center; justify-content: center;
	width: 38px; height: 38px; border-radius: 50%;
	background: rgba(255, 255, 255, .18); font-weight: 700; font-size: 17px; margin-right: 6px;
}
#cbc-root .cbc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
#cbc-root .cbc-title strong { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cbc-root .cbc-title span { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cbc-root .cbc-hbtn {
	position: relative; display: flex; align-items: center; justify-content: center;
	width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px;
	background: transparent; color: #fff; transition: background-color .15s ease;
}
#cbc-root .cbc-hbtn:hover { background: rgba(255, 255, 255, .16); }
#cbc-root .cbc-hbtn.is-on { background: rgba(255, 255, 255, .22); }
#cbc-root .cbc-hbtn:focus-visible { outline-color: #fff; outline-offset: -2px; }
#cbc-root .cbc-badge {
	position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
	border-radius: 9px; background: #fff; color: var(--cbc-accent-dark);
	font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* Conversación */
#cbc-root .cbc-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
#cbc-root .cbc-row { display: flex; max-width: 100%; }
#cbc-root .cbc-row.cbc-bot { justify-content: flex-start; }
#cbc-root .cbc-row.cbc-me { justify-content: flex-end; }
#cbc-root .cbc-bubble {
	max-width: 86%; padding: 9px 13px; white-space: pre-line; overflow-wrap: anywhere;
	background: var(--cbc-card); border: 1px solid var(--cbc-line); border-radius: 16px 16px 16px 4px;
}
#cbc-root .cbc-me .cbc-bubble { background: var(--cbc-accent); border-color: var(--cbc-accent); color: #fff; border-radius: 16px 16px 4px 16px; }
#cbc-root .cbc-row.cbc-note { justify-content: center; }
#cbc-root .cbc-notetext { font-size: 12.5px; color: var(--cbc-mute); background: rgba(15, 30, 45, .06); padding: 4px 10px; border-radius: 999px; text-align: center; }

#cbc-root .cbc-typing .cbc-bubble { display: flex; gap: 4px; padding: 13px 14px; }
#cbc-root .cbc-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--cbc-mute); animation: cbc-dot 1s infinite ease-in-out; }
#cbc-root .cbc-typing span:nth-child(2) { animation-delay: .15s; }
#cbc-root .cbc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cbc-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Botones rápidos */
#cbc-root .cbc-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 16px 10px; max-height: 104px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
#cbc-root .cbc-chips:empty { display: none; }
#cbc-root .cbc-chip {
	flex: none; padding: 6px 12px; border: 1px solid var(--cbc-accent); border-radius: 999px;
	background: var(--cbc-card); color: var(--cbc-accent-dark); font-size: 13.5px; font-weight: 550; white-space: nowrap;
	transition: background-color .15s ease, color .15s ease;
}
#cbc-root .cbc-chip:hover { background: var(--cbc-accent); color: #fff; }

/* Caja de texto */
#cbc-root .cbc-input { display: flex; gap: 8px; padding: 10px 12px 12px; background: var(--cbc-card); border-top: 1px solid var(--cbc-line); }
#cbc-root .cbc-text {
	flex: 1; min-width: 0; height: 44px; padding: 0 14px;
	border: 1px solid var(--cbc-line); border-radius: 12px; background: var(--cbc-bg); font-size: 16px;
}
#cbc-root .cbc-text:focus { border-color: var(--cbc-accent); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(15, 92, 122, .15); }
#cbc-root .cbc-send {
	flex: none; display: flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: var(--cbc-accent); color: #fff;
}
#cbc-root .cbc-send:hover { background: var(--cbc-accent-dark); }

/* Productos: tira deslizable a todo el ancho */
#cbc-root .cbc-row.cbc-wide { margin: 0 -16px; width: calc(100% + 32px); max-width: none; }
#cbc-root .cbc-track {
	display: flex; gap: 10px; width: 100%; padding: 2px 16px 8px; overflow-x: auto;
	scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: thin;
}
#cbc-root .cbc-card {
	flex: none; width: 210px; display: flex; flex-direction: column; overflow: hidden; scroll-snap-align: start;
	background: var(--cbc-card); border: 1px solid var(--cbc-line); border-radius: 14px;
}
#cbc-root .cbc-card-img {
	display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; overflow: hidden;
	background: #e8ecef; color: #9aa6b0;
}
#cbc-root .cbc-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#cbc-root .cbc-card-img .cbc-ico { width: 36px; height: 36px; }
#cbc-root .cbc-card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 4px; }
#cbc-root .cbc-card-title { color: var(--cbc-ink); font-weight: 600; text-decoration: none; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#cbc-root .cbc-card-title:hover { text-decoration: underline; }
#cbc-root .cbc-card-price { display: flex; align-items: baseline; gap: 6px; }
#cbc-root .cbc-card-price strong { font-size: 16px; }
#cbc-root .cbc-card-price del { color: var(--cbc-mute); font-size: 12.5px; }
#cbc-root .cbc-stock { font-size: 12px; color: var(--cbc-danger); }
#cbc-root .cbc-avail { font-size: 12px; color: #1e7a45; }
#cbc-root .cbc-card-ex { margin: 0; font-size: 12.5px; color: var(--cbc-mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#cbc-root .cbc-card-actions { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 12px; }

/* Botones */
#cbc-root .cbc-btn {
	display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px;
	border: 1px solid transparent; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: center; text-decoration: none;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
#cbc-root .cbc-btn-primary { background: var(--cbc-accent); color: #fff; }
#cbc-root .cbc-btn-primary:hover { background: var(--cbc-accent-dark); }
#cbc-root .cbc-btn-primary.is-on { background: #fff; color: var(--cbc-accent-dark); border-color: var(--cbc-accent); }
#cbc-root .cbc-btn-ghost { background: #fff; color: var(--cbc-accent-dark); border-color: var(--cbc-line); }
#cbc-root .cbc-btn-ghost:hover { border-color: var(--cbc-accent); }
#cbc-root .cbc-btn-link { background: none; color: var(--cbc-accent-dark); text-decoration: underline; text-underline-offset: 2px; padding: 0 4px; }
#cbc-root .cbc-btn[disabled] { opacity: .6; cursor: progress; }
#cbc-root .cbc-btn.is-busy::after {
	content: ''; width: 14px; height: 14px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent;
	border-radius: 50%; animation: cbc-spin .7s linear infinite;
}
@keyframes cbc-spin { to { transform: rotate(360deg); } }

/* Formularios */
#cbc-root .cbc-row.cbc-formrow .cbc-bubble.cbc-formcard { width: 100%; max-width: 100%; padding: 14px; white-space: normal; border-radius: 14px; }
#cbc-root .cbc-form-title { margin: 0 0 10px; font-size: 16px; font-weight: 650; line-height: 1.3; color: var(--cbc-ink); }
#cbc-root .cbc-field { margin-bottom: 10px; }
#cbc-root .cbc-field label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--cbc-mute); }
#cbc-root .cbc-field input, #cbc-root .cbc-field textarea {
	display: block; width: 100%; padding: 9px 11px; border: 1px solid var(--cbc-line); border-radius: 10px;
	background: #fff; font-size: 16px; line-height: 1.35;
}
#cbc-root .cbc-field textarea { resize: vertical; min-height: 64px; }
#cbc-root .cbc-field input:focus, #cbc-root .cbc-field textarea:focus { border-color: var(--cbc-accent); outline: none; box-shadow: 0 0 0 3px rgba(15, 92, 122, .15); }
#cbc-root .cbc-check { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 10px; font-size: 13px; color: var(--cbc-mute); }
#cbc-root .cbc-check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--cbc-accent); }
#cbc-root .cbc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
#cbc-root .cbc-err { min-height: 0; margin-bottom: 8px; color: var(--cbc-danger); font-size: 13.5px; font-weight: 550; }
#cbc-root .cbc-err:empty { display: none; }
#cbc-root .cbc-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#cbc-root .cbc-form-actions .cbc-btn-primary { flex: 1 1 auto; }

/* Formulario ya abierto: destello para indicar dónde está */
#cbc-root .cbc-formcard.cbc-pulse, #cbc-root .cbc-pulse .cbc-formcard { animation: cbc-pulse 1s ease; }
@keyframes cbc-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(15, 92, 122, 0); } 30% { box-shadow: 0 0 0 4px rgba(15, 92, 122, .35); } }

/* Lista de cotización */
#cbc-root .cbc-qlist { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--cbc-line); border-radius: 12px; overflow: hidden; }
#cbc-root .cbc-qitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
#cbc-root .cbc-qitem + .cbc-qitem { border-top: 1px solid var(--cbc-line); }
#cbc-root .cbc-qthumb { flex: none; width: 46px; height: 46px; border-radius: 8px; overflow: hidden; background: #e8ecef; color: #9aa6b0; display: flex; align-items: center; justify-content: center; }
#cbc-root .cbc-qthumb img { width: 100%; height: 100%; object-fit: cover; }
#cbc-root .cbc-qmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#cbc-root .cbc-qtitle { color: var(--cbc-ink); font-size: 13.5px; font-weight: 600; line-height: 1.25; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#cbc-root .cbc-qprice { font-size: 12.5px; color: var(--cbc-mute); }
#cbc-root .cbc-qty { flex: none; display: flex; align-items: center; border: 1px solid var(--cbc-line); border-radius: 8px; overflow: hidden; }
#cbc-root .cbc-qty button { width: 28px; height: 30px; padding: 0; border: 0; background: #fff; font-size: 16px; line-height: 1; }
#cbc-root .cbc-qty button:hover { background: var(--cbc-bg); }
#cbc-root .cbc-qty-n { min-width: 26px; text-align: center; font-size: 13.5px; font-weight: 600; }
#cbc-root .cbc-x { flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--cbc-mute); display: flex; align-items: center; justify-content: center; }
#cbc-root .cbc-x:hover { color: var(--cbc-danger); background: var(--cbc-bg); }
#cbc-root .cbc-qempty { padding: 12px; color: var(--cbc-mute); font-size: 13.5px; }

/* Móvil: pantalla completa */
@media (max-width: 520px) {
	#cbc-root { bottom: 14px; }
	#cbc-root.cbc-pos-right { right: 14px; }
	#cbc-root.cbc-pos-left { left: 14px; }
	#cbc-root .cbc-panel {
		position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none;
		transform: translateY(20px);
	}
	#cbc-root .cbc-head { padding-top: max(12px, env(safe-area-inset-top)); }
	#cbc-root .cbc-input { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
	#cbc-root .cbc-bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
	#cbc-root *, #cbc-root *::before, #cbc-root *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
