/* Ecollantas Chat – estilos del widget (branding Ecollantas: verde / verde oscuro) */
:root {
	--ecochat-color: #408018;      /* verde del logo: botones, acentos */
	--ecochat-dark: #1f5a0c;       /* verde oscuro: cabecera, launcher, burbuja cliente */
	--ecochat-bg: #ffffff;
	--ecochat-body: #f3f8f3;       /* fondo del hilo, verde muy claro */
	--ecochat-bot: #ffffff;
	--ecochat-text: #14261a;
	--ecochat-muted: #5f7264;
	--ecochat-line: #dbe7dc;
	--ecochat-radius: 18px;
	--ecochat-shadow: 0 14px 44px rgba(20, 83, 45, .22);
	--ecochat-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#ecochat-root, .ecochat-inline { font-family: var(--ecochat-font); font-size: 15px; line-height: 1.45; color: var(--ecochat-text); }
#ecochat-root *, .ecochat-inline * { box-sizing: border-box; }

/* Botón flotante */
.ecochat-launcher {
	position: fixed; bottom: 24px; z-index: 99998;
	width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
	background: linear-gradient(145deg, var(--ecochat-color), var(--ecochat-dark));
	color: #fff;
	box-shadow: 0 8px 24px rgba(20, 83, 45, .35);
	display: flex; align-items: center; justify-content: center;
	transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.ecochat-launcher::after {
	content: ""; position: absolute; inset: -4px; border-radius: 50%;
	border: 2px solid var(--ecochat-color); opacity: .35;
	animation: ecochat-pulse 2.4s ease-out infinite;
}
@keyframes ecochat-pulse { 0% { transform: scale(.9); opacity: .5; } 100% { transform: scale(1.35); opacity: 0; } }
.ecochat-launcher.ecochat-right { right: 24px; }
.ecochat-launcher.ecochat-left { left: 24px; }
.ecochat-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(20, 83, 45, .45); }
.ecochat-launcher.ecochat-hidden { opacity: 0; pointer-events: none; transform: scale(.6); }
.ecochat-launcher--logo { background: #fff; border: 3px solid var(--ecochat-color); width: 66px; height: 66px; }
.ecochat-launcher--logo img { width: 80%; height: 80%; object-fit: contain; display: block; }
.ecochat-launcher-badge {
	position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%;
	background: var(--ecochat-color); color: #fff; border: 2px solid #fff;
	display: flex; align-items: center; justify-content: center;
}

/* Panel */
.ecochat-panel {
	position: fixed; bottom: 24px; z-index: 99999;
	width: 390px; max-width: calc(100vw - 32px); height: 620px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
	background: var(--ecochat-bg); border-radius: var(--ecochat-radius); box-shadow: var(--ecochat-shadow);
	display: flex; flex-direction: column; overflow: hidden;
	opacity: 0; pointer-events: none; transform: translateY(16px) scale(.98);
	transition: opacity .18s ease, transform .18s ease;
}
.ecochat-panel.ecochat-right { right: 24px; }
.ecochat-panel.ecochat-left { left: 24px; }
.ecochat-panel.ecochat-open { opacity: 1; pointer-events: auto; transform: none; }
.ecochat-panel--inline { position: static; width: 100%; max-width: 720px; height: 620px; margin: 0 auto; box-shadow: 0 2px 16px rgba(20,83,45,.10); border: 1px solid var(--ecochat-line); }

/* Cabecera */
.ecochat-head {
	display: flex; align-items: center; gap: 12px; padding: 14px 14px 13px;
	background: var(--ecochat-dark);
	background: linear-gradient(120deg, var(--ecochat-dark) 0%, color-mix(in srgb, var(--ecochat-dark) 55%, var(--ecochat-color)) 100%);
	color: #fff;
}
.ecochat-avatar {
	width: 40px; height: 40px; border-radius: 50%; flex: none;
	background: #fff; color: var(--ecochat-color);
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 0 0 3px rgba(255,255,255,.22);
	overflow: hidden;
}
.ecochat-avatar img { width: 84%; height: 84%; object-fit: contain; display: block; }
.ecochat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ecochat-title strong { font-size: 15px; font-weight: 700; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ecochat-title span { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.ecochat-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7ee787; box-shadow: 0 0 0 2px rgba(126,231,135,.3); }
.ecochat-icon { background: transparent; border: 0; color: #fff; opacity: .85; cursor: pointer; padding: 6px; border-radius: 8px; display: flex; }
.ecochat-icon:hover { background: rgba(255,255,255,.15); opacity: 1; }

/* Cuerpo */
.ecochat-body { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--ecochat-body); }
.ecochat-body::-webkit-scrollbar { width: 6px; }
.ecochat-body::-webkit-scrollbar-thumb { background: var(--ecochat-line); border-radius: 3px; }
.ecochat-msg { display: flex; flex-direction: column; max-width: 100%; }
.ecochat-msg--user { align-items: flex-end; }
.ecochat-msg--bot { align-items: flex-start; }
.ecochat-bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; word-wrap: break-word; }
.ecochat-msg--user .ecochat-bubble { background: var(--ecochat-dark); color: #fff; border-bottom-right-radius: 4px; }
.ecochat-msg--bot .ecochat-bubble { background: var(--ecochat-bot); color: var(--ecochat-text); border: 1px solid var(--ecochat-line); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(20,83,45,.05); }
.ecochat-bubble strong { color: var(--ecochat-dark); }
.ecochat-bubble ul { margin: 6px 0 6px 18px; padding: 0; }
.ecochat-bubble li { margin: 2px 0; }

/* Indicador escribiendo */
.ecochat-typing { color: var(--ecochat-muted); font-size: 13px; }
.ecochat-typing span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--ecochat-color); animation: ecochat-blink 1.2s infinite; }
.ecochat-typing span:nth-child(2) { animation-delay: .2s; }
.ecochat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ecochat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Tarjetas de producto */
.ecochat-cards { display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 6px; margin-top: 4px; max-width: 100%; scroll-snap-type: x mandatory; }
.ecochat-cards::-webkit-scrollbar { height: 6px; }
.ecochat-cards::-webkit-scrollbar-thumb { background: var(--ecochat-line); border-radius: 3px; }
.ecochat-card {
	flex: none; width: 196px; scroll-snap-align: start;
	background: #fff; border: 1px solid var(--ecochat-line); border-radius: 14px; overflow: hidden;
	text-decoration: none !important; color: inherit; display: flex; flex-direction: column;
	transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.ecochat-card:hover { box-shadow: 0 8px 20px rgba(20,83,45,.16); transform: translateY(-2px); border-color: var(--ecochat-color); }
.ecochat-card-img { aspect-ratio: 1 / 1; background: #eef4ee; }
.ecochat-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ecochat-card-body { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ecochat-card-name { font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--ecochat-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ecochat-card-specs { font-size: 11.5px; color: var(--ecochat-muted); }
.ecochat-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 8px; }
.ecochat-card-price { font-weight: 800; font-size: 15px; color: var(--ecochat-dark); }
.ecochat-card-btn { font-size: 12px; font-weight: 700; color: #fff; background: var(--ecochat-color); padding: 6px 10px; border-radius: 9px; white-space: nowrap; }
.ecochat-card:hover .ecochat-card-btn { background: var(--ecochat-dark); }

/* Formulario */
.ecochat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--ecochat-line); background: #fff; }
.ecochat-input {
	flex: 1; resize: none; border: 1px solid var(--ecochat-line); border-radius: 12px; padding: 10px 12px;
	font: inherit; font-size: 15px; line-height: 1.4; max-height: 120px; outline: none; background: #fff; color: var(--ecochat-text);
}
.ecochat-input::placeholder { color: #8a9a8d; }
.ecochat-input:focus { border-color: var(--ecochat-color); box-shadow: 0 0 0 3px rgba(58,170,53,.18); }
.ecochat-send { width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: var(--ecochat-color); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s ease; }
.ecochat-send:hover { background: var(--ecochat-dark); }
.ecochat-send:disabled { opacity: .5; cursor: default; }

/* Enlaces dentro de las burbujas */
.ecochat-msg--bot .ecochat-bubble a { color: var(--ecochat-dark); font-weight: 600; text-decoration: underline; }
.ecochat-msg--user .ecochat-bubble a { color: #fff; }

/* ── Móvil y tablet (1.2.0, 29-09-2026) ──────────────────────────────────────────
   chat.js mide lo que queda visible con el teclado abierto (visualViewport) y lo deja
   en --ecochat-vvh / --ecochat-vvtop del panel, más la clase .ecochat-kb. */

/* Barra inferior fija del tema en móvil y tablet (.header-mobile-fixed, ≤1180px): chat.js
   mide su alto en --ecochat-bar y el botón y el panel flotante se quedan encima de ella
   (antes el botón tapaba «Wishlist» y el panel abierto se comía la barra). */
.ecochat-launcher { bottom: calc(24px + var(--ecochat-bar, 0px)); }
.ecochat-panel:not(.ecochat-panel--inline) {
	bottom: calc(24px + var(--ecochat-bar, 0px));
	max-height: calc(100vh - 48px - var(--ecochat-bar, 0px)); max-height: calc(100dvh - 48px - var(--ecochat-bar, 0px));
}

/* Tablet con el teclado abierto: el panel sube por encima de él y cabe en lo visible. */
.ecochat-panel.ecochat-kb:not(.ecochat-panel--inline) {
	--ecochat-h: min(620px, calc(var(--ecochat-vvh, 100vh) - 24px));
	top: calc(var(--ecochat-vvtop, 0px) + var(--ecochat-vvh, 100vh) - var(--ecochat-h) - 12px);
	bottom: auto; height: var(--ecochat-h); max-height: none;
}

/* Móvil (y móvil apaisado): pantalla completa, ajustada al hueco que deja el teclado.
   Antes era height:100% fijo y, con el teclado, iOS desplazaba la página para enseñar
   el campo: la cabecera se salía por arriba y al cerrarlo todo quedaba descolocado. */
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
	.ecochat-panel:not(.ecochat-panel--inline),
	.ecochat-panel.ecochat-kb:not(.ecochat-panel--inline) {
		top: var(--ecochat-vvtop, 0px); bottom: auto; right: 0 !important; left: 0 !important;
		width: 100%; max-width: 100%; height: var(--ecochat-vvh, 100%); max-height: none; border-radius: 0;
	}
	html.ecochat-lock, html.ecochat-lock body { overflow: hidden; }
	.ecochat-head { padding-top: max(14px, env(safe-area-inset-top)); }
	.ecochat-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
	.ecochat-panel.ecochat-kb .ecochat-head { padding-top: 8px; padding-bottom: 8px; }
	.ecochat-panel.ecochat-kb .ecochat-avatar { width: 34px; height: 34px; }
}

/* Pantallas táctiles: iOS amplía la página al enfocar un campo de menos de 16px (y no la
   devuelve al cerrar el teclado). Botones de la cabecera con tamaño de dedo. */
@media (pointer: coarse), (max-width: 1024px) {
	.ecochat-input { font-size: 16px; }
	.ecochat-icon { padding: 11px; }
}
.ecochat-body { overscroll-behavior: contain; }
