/* PE Chat — widget (fase 3). Tokens del sitio: Inter, texto #222, filetes #e6e7e9, botones negros (paleta A),
   cabecera negra como la de la web. Todo bajo #pe-chat; z-index alto para quedar sobre la cabecera de Houzez.
   El botón es position:fixed: no ocupa sitio en la página (sin CLS). */

#pe-chat {
	--pc-ink: #222222;
	--pc-muted: #5c666e;
	--pc-line: #e6e7e9;
	--pc-bg: #ffffff;
	--pc-soft: #f6f6f6;
	--pc-black: #000000;
	--pc-radius: 4px;
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--pc-ink);
}
#pe-chat *, #pe-chat *::before, #pe-chat *::after { box-sizing: border-box; }

/* ---------- Botón flotante ---------- */
#pe-chat .pe-chat__launcher {
	position: fixed;
	right: calc(18px + env(safe-area-inset-right, 0px));
	bottom: calc(18px + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--pc-black);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
	transition: transform .15s ease;
}
#pe-chat .pe-chat__launcher:hover { transform: scale(1.05); }
#pe-chat .pe-chat__launcher:focus-visible { outline: 3px solid #5b8b8b; outline-offset: 3px; }
#pe-chat.is-open .pe-chat__launcher { display: none; }

/* ---------- Ventana ---------- */
#pe-chat .pe-chat__dialog {
	position: fixed;
	right: calc(18px + env(safe-area-inset-right, 0px));
	bottom: calc(18px + env(safe-area-inset-bottom, 0px));
	z-index: 99991;
	width: 390px;
	height: min(640px, calc(100vh - 110px));
	max-height: calc(100vh - 40px);
	display: none;
	flex-direction: column;
	background: var(--pc-bg);
	border-radius: 8px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
	overflow: hidden;
}
#pe-chat.is-open .pe-chat__dialog { display: flex; }
#pe-chat.is-wide .pe-chat__dialog { width: min(720px, calc(100vw - 40px)); height: calc(100vh - 40px); }

/* Cabecera negra */
#pe-chat .pe-chat__head {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 14px 12px 12px 18px;
	background: var(--pc-black);
	color: #ffffff;
}
#pe-chat .pe-chat__titles { flex: 1 1 auto; min-width: 0; }
#pe-chat .pe-chat__title { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.3; color: #ffffff; letter-spacing: .01em; }
#pe-chat .pe-chat__notice { margin: 3px 0 0; font-size: 12px; line-height: 1.4; color: #c9c9c9; }
#pe-chat .pe-chat__icon {
	flex: 0 0 36px;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--pc-radius);
	background: transparent;
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
#pe-chat .pe-chat__icon:hover { background: rgba(255, 255, 255, .12); }
#pe-chat .pe-chat__icon:focus-visible { outline: 2px solid #ffffff; outline-offset: -2px; }

/* Mensajes */
#pe-chat .pe-chat__log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	background: var(--pc-soft);
	display: flex;
	flex-direction: column;
	gap: 10px;
}
#pe-chat .pe-chat__msg {
	max-width: 88%;
	padding: 10px 13px;
	border-radius: 10px;
	white-space: normal;
	overflow-wrap: anywhere;
}
#pe-chat .pe-chat__msg--bot { align-self: flex-start; background: #ffffff; border: 1px solid var(--pc-line); border-bottom-left-radius: 3px; }
#pe-chat .pe-chat__msg--user { align-self: flex-end; background: var(--pc-black); color: #ffffff; border-bottom-right-radius: 3px; }
#pe-chat .pe-chat__msg--error { align-self: flex-start; background: #fff7f5; border: 1px solid #f0d4cd; color: #7a2e1f; }
#pe-chat .pe-chat__msg a { color: inherit; text-decoration: underline; }

/* Opciones pulsables de «Me interesa» (fase 3b): solo bajo la última respuesta */
#pe-chat .pe-chat__opts { display: flex; flex-wrap: wrap; gap: 8px; }
#pe-chat .pe-chat__chip {
	padding: 7px 12px;
	border: 1px solid var(--pc-black);
	border-radius: 999px;
	background: #ffffff;
	color: var(--pc-black);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}
#pe-chat .pe-chat__chip:focus-visible { background: var(--pc-black); color: #ffffff; }
/* :hover solo con ratón: en pantallas táctiles se queda «pegado» tras tocar. */
@media (hover: hover) {
	#pe-chat .pe-chat__chip:hover { background: var(--pc-black); color: #ffffff; }
	#pe-chat .pe-chat__interest:hover { background: #ffffff; color: var(--pc-black); }
}

/* Tarjetas (como las de los listados) */
#pe-chat .pe-chat__cards { display: flex; flex-direction: column; gap: 10px; align-self: stretch; }
#pe-chat.is-wide .pe-chat__cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
#pe-chat .pe-chat__card {
	display: flex;
	flex-direction: column;
	background: #ffffff;
	border: 1px solid var(--pc-line);
	border-radius: var(--pc-radius);
	overflow: hidden;
}
#pe-chat .pe-chat__card:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, .1); }
#pe-chat .pe-chat__clink { display: block; flex: 1 1 auto; color: var(--pc-ink); text-decoration: none; }
#pe-chat .pe-chat__clink:focus-visible { outline: 2px solid var(--pc-black); outline-offset: -2px; }
#pe-chat .pe-chat__cact { padding: 0 12px 12px; }
#pe-chat .pe-chat__interest {
	width: 100%;
	min-height: 40px;
	padding: 8px 12px;
	border: 1px solid var(--pc-black);
	border-radius: var(--pc-radius);
	background: var(--pc-black);
	color: #ffffff;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
}
#pe-chat .pe-chat__interest:focus-visible { background: #ffffff; color: var(--pc-black); } /* El tema quita el outline de los botones (!important). */
#pe-chat .pe-chat__media { position: relative; display: block; aspect-ratio: 4 / 3; background: #e8e6e1; }
#pe-chat .pe-chat__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
#pe-chat .pe-chat__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 2px 8px;
	border-radius: var(--pc-radius);
	background: var(--pc-black);
	color: #ffffff;
	font-size: 12px;
	font-weight: 500;
}
#pe-chat .pe-chat__badge + .pe-chat__badge { left: auto; right: 8px; background: #ffffff; color: var(--pc-black); }
#pe-chat .pe-chat__cbody { display: block; padding: 10px 12px 12px; }
#pe-chat .pe-chat__price { display: block; font-size: 17px; font-weight: 600; color: var(--pc-black); }
/* Fase 3e: precio aproximado en la moneda del visitante, línea de horario y caja de Turnstile (solo si pide interacción). */
#pe-chat .pe-chat__fx { display: block; margin-top: 1px; font-size: 13px; color: var(--pc-muted); }
#pe-chat .pe-chat__hours { margin: -4px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--pc-muted); }
#pe-chat .pe-chat__ts:empty { display: none; }
#pe-chat .pe-chat__ctitle { display: block; margin-top: 2px; font-size: 14px; font-weight: 500; line-height: 1.35; }
#pe-chat .pe-chat__specs, #pe-chat .pe-chat__zone { display: block; margin-top: 4px; font-size: 13px; color: var(--pc-muted); }
#pe-chat .pe-chat__more { display: block; margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--pc-black); text-decoration: underline; }

/* Escribiendo… */
#pe-chat .pe-chat__typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #ffffff; border: 1px solid var(--pc-line); border-radius: 10px; }
#pe-chat .pe-chat__typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa1a6; animation: pe-chat-dot 1.2s infinite ease-in-out; }
#pe-chat .pe-chat__typing span:nth-child(2) { animation-delay: .15s; }
#pe-chat .pe-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pe-chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Pie: campo + enviar, y WhatsApp */
#pe-chat .pe-chat__foot { flex: 0 0 auto; padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--pc-line); background: #ffffff; }
#pe-chat .pe-chat__form { display: flex; align-items: flex-end; gap: 8px; }
#pe-chat .pe-chat__input {
	flex: 1 1 auto;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid #c5c5c5;
	border-radius: var(--pc-radius);
	font: inherit;
	font-size: 16px; /* 16px: iOS no hace zoom al enfocar */
	line-height: 1.35;
	color: var(--pc-ink);
	resize: none;
	background: #ffffff;
}
#pe-chat .pe-chat__input:focus { outline: 2px solid rgba(0, 0, 0, .25); outline-offset: -1px; border-color: var(--pc-black); }
#pe-chat .pe-chat__send {
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: var(--pc-radius);
	background: var(--pc-black);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
#pe-chat .pe-chat__send[disabled] { opacity: .45; cursor: default; }
#pe-chat .pe-chat__wa {
	margin-top: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 40px;
	border: 1px solid var(--pc-line);
	border-radius: var(--pc-radius);
	color: var(--pc-ink);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
	background: #ffffff;
}
#pe-chat .pe-chat__wa:hover { border-color: var(--pc-black); }
#pe-chat .pe-chat__wa svg { color: #1f9d55; }
#pe-chat .pe-chat__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---------- Bocadillo del móvil (fase 3c): junto al botón, fixed (sin CLS) ---------- */
#pe-chat .pe-chat__teaser {
	position: fixed;
	z-index: 99990;
	right: calc(18px + 56px + 10px + env(safe-area-inset-right, 0px));
	bottom: calc(26px + env(safe-area-inset-bottom, 0px));
	max-width: min(240px, calc(100vw - 110px));
	padding: 10px 14px;
	border: 1px solid var(--pc-line);
	border-radius: 12px;
	background: #ffffff;
	color: var(--pc-ink);
	font: inherit;
	font-size: 14px;
	line-height: 1.35;
	text-align: left;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
	cursor: pointer;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .2s ease, transform .2s ease;
}
#pe-chat .pe-chat__teaser.is-in { opacity: 1; transform: none; }
#pe-chat.is-open .pe-chat__teaser { display: none; }
#pe-chat .pe-chat__backdrop { display: none; }

/* ---------- Móvil: panel desde abajo (~9/10), fondo oscurecido, teclado ---------- */
@media (max-width: 767.98px) {
	#pe-chat .pe-chat__backdrop {
		position: fixed;
		inset: 0;
		z-index: 99990;
		background: rgba(0, 0, 0, .5);
	}
	#pe-chat.is-open .pe-chat__backdrop { display: block; }
	#pe-chat .pe-chat__dialog {
		right: 0;
		bottom: auto;
		left: 0;
		top: 10vh;
		top: var(--pe-chat-top, 10dvh);
		width: 100%;
		height: 90vh;
		height: var(--pe-chat-vh, 90dvh);
		max-height: none;
		border-radius: 14px 14px 0 0;
		animation: pe-chat-up .22s ease-out;
	}
	#pe-chat.is-wide .pe-chat__dialog { width: 100%; height: var(--pe-chat-vh, 90dvh); }
	#pe-chat .pe-chat__wide { display: none; }
	#pe-chat .pe-chat__msg { max-width: 92%; }
}
@keyframes pe-chat-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
html.pe-chat-lock, html.pe-chat-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
	#pe-chat .pe-chat__launcher { transition: none; }
	#pe-chat .pe-chat__typing span { animation: none; opacity: .7; }
	#pe-chat .pe-chat__dialog { animation: none; }
	#pe-chat .pe-chat__teaser { transition: none; }
}
@media print { #pe-chat { display: none !important; } }
