/* ===========================================================================
   BC Chatbot — Lifting Fase A (2026-05-29)
   Branding: azul oscuro #00252F (header/FAB) + verde brand #0EA84C (CTAs/badges)
   Mobile: 100dvh + safe-area-inset (notch + teclado virtual iOS)
   =========================================================================== */

#bc-chatbot-fab,
#bc-chatbot-window {
	--bcch-primary: #00252F;
	--bcch-primary-hover: #003d4f;
	--bcch-accent: #0EA84C;
	--bcch-accent-soft: #f0fdf4;
	--bcch-accent-border: #c8ecd3;
	--bcch-accent-dark: #065f2a;
	--bcch-text: #1e293b;
	--bcch-text-muted: #64748b;
	--bcch-text-light: #94a3b8;
	--bcch-border: #e2e8f0;
	--bcch-border-strong: #cbd5e1;
	--bcch-bg: #ffffff;
	--bcch-bg-alt: #f1f5f9;
	--bcch-bg-soft: #fafafa;
	--bcch-radius-sm: 8px;
	--bcch-radius-md: 12px;
	--bcch-radius-lg: 16px;
	--bcch-radius-pill: 999px;
	--bcch-shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
	--bcch-shadow-md: 0 4px 16px rgba(0,37,47,0.10);
	--bcch-shadow-lg: 0 8px 40px rgba(0,0,0,0.20);
	--bcch-trans: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === FAB === */
#bc-chatbot-fab {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--bcch-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 99996;
	box-shadow: 0 4px 16px rgba(0, 37, 47, 0.35);
	transition: transform var(--bcch-trans), box-shadow var(--bcch-trans);
	user-select: none;
}
#bc-chatbot-fab:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 24px rgba(0, 37, 47, 0.45);
}
#bc-chatbot-fab:focus-visible {
	outline: 3px solid var(--bcch-accent);
	outline-offset: 2px;
}
#bc-chatbot-fab.bc-chatbot-home {
	bottom: 100px;
}
/* En desktop ocultar FAB al abrir; en mobile NO (se transforma en cerrar pequeño) */
@media (min-width: 601px) {
	#bc-chatbot-fab.bc-fab-hidden {
		display: none;
	}
}

/* === Ventana del chat === */
#bc-chatbot-window {
	position: fixed;
	bottom: 90px;
	right: 20px;
	width: 380px;
	height: 560px;
	max-height: calc(100dvh - 110px);
	background: var(--bcch-bg);
	border-radius: var(--bcch-radius-lg);
	box-shadow: var(--bcch-shadow-lg);
	z-index: 99999;
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#bc-chatbot-window.bc-chat-open {
	display: flex;
}
#bc-chatbot-window.bc-chatbot-home {
	bottom: 170px;
}

/* === Header === */
.bc-chat-header {
	background: var(--bcch-primary);
	color: #fff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	gap: 10px;
}
.bc-chat-header-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
.bc-chat-header-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--bcch-primary) 0%, var(--bcch-accent) 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 13px;
	color: #fff;
	flex-shrink: 0;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}
.bc-chat-header-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}
.bc-chat-header-title {
	font-size: 14px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 6px;
	line-height: 1.2;
}
.bc-chat-header-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}
.bc-chat-header-tag {
	font-size: 11px;
	color: rgba(255,255,255,0.7);
	font-weight: 500;
	letter-spacing: 0.02em;
}

#bc-chatbot-window button,
#bc-chatbot-window input {
	display: block !important;
	visibility: visible !important;
}
.bc-chat-close {
	background: none !important;
	border: none !important;
	color: #fff !important;
	cursor: pointer !important;
	padding: 4px !important;
	line-height: 1 !important;
	font-size: 22px !important;
	opacity: 0.85;
	transition: opacity var(--bcch-trans);
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 32px !important;
	height: 32px !important;
	min-width: unset !important;
	min-height: unset !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	flex-shrink: 0;
}
.bc-chat-close:hover {
	opacity: 1;
}

/* === Mensajes === */
/* Wrap: contiene el scroll + el boton flotante "scroll-to-bottom".
   Tener el boton FUERA del scroll evita que el boton se mueva con el contenido
   y que su posicion absoluta interfiera con el calculo de scrollHeight. */
.bc-chat-messages-wrap {
	flex: 1;
	position: relative;
	display: flex;
	min-height: 0;
}
.bc-chat-messages {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}

.bc-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}
.bc-msg-bot {
	align-self: flex-start;
	background: var(--bcch-bg-alt);
	color: var(--bcch-text);
	border-bottom-left-radius: 4px;
}
.bc-msg-user {
	align-self: flex-end;
	background: var(--bcch-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* Markdown completo dentro del mensaje del bot */
.bc-msg-bot a {
	color: #0369a1;
	text-decoration: underline;
}
.bc-msg-bot strong { font-weight: 700; }
.bc-msg-bot em { font-style: italic; }
.bc-msg-bot code {
	background: #e2e8f0;
	padding: 1px 6px;
	border-radius: 3px;
	font-family: ui-monospace, Menlo, Consolas, monospace;
	font-size: 12.5px;
}
.bc-msg-bot ul, .bc-msg-bot ol {
	margin: 8px 0;
	padding-left: 20px;
}
.bc-msg-bot li {
	margin: 3px 0;
}
.bc-msg-bot h3, .bc-msg-bot h4 {
	font-size: 14px;
	font-weight: 700;
	margin: 8px 0 4px;
	color: var(--bcch-text);
}

/* Cursor de "escribiendo" en streaming visual */
.bc-msg-bot.bc-streaming::after {
	content: '▎';
	color: var(--bcch-accent);
	animation: bcCursor 1s infinite;
	margin-left: 1px;
}
@keyframes bcCursor {
	0%, 50% { opacity: 1; }
	51%, 100% { opacity: 0; }
}

/* === Typing dots (mientras el server piensa, antes del streaming) === */
.bc-typing {
	align-self: flex-start;
	padding: 10px 18px;
	background: var(--bcch-bg-alt);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	display: flex;
	gap: 4px;
	align-items: center;
}
.bc-typing-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--bcch-text-light);
	animation: bcTyping 1.4s infinite;
}
.bc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.bc-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bcTyping {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-4px); }
}

/* === Quick replies iniciales === */
.bc-chat-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 6px;
	max-width: 100%;
}
.bc-chat-quick-reply {
	padding: 7px 14px !important;
	background: var(--bcch-bg) !important;
	border: 1px solid var(--bcch-border-strong) !important;
	border-radius: var(--bcch-radius-pill) !important;
	color: var(--bcch-text) !important;
	font-size: 12.5px !important;
	font-weight: 500 !important;
	cursor: pointer !important;
	transition: border-color var(--bcch-trans), color var(--bcch-trans), background var(--bcch-trans), transform var(--bcch-trans) !important;
	box-shadow: none !important;
	min-width: unset !important;
	min-height: unset !important;
	line-height: 1.3 !important;
	font-family: inherit !important;
	text-align: left !important;
}
.bc-chat-quick-reply:hover {
	border-color: var(--bcch-accent) !important;
	color: var(--bcch-accent-dark) !important;
	background: var(--bcch-accent-soft) !important;
	transform: translateY(-1px);
}
.bc-chat-quick-reply:focus-visible {
	outline: 2px solid var(--bcch-accent) !important;
	outline-offset: 2px !important;
}

/* === Tarjetas de vehículo (estilo Airbnb) === */
.bc-vehicle-cards {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 8px;
}
.bc-vehicle-card {
	display: flex;
	flex-direction: column;
	background: var(--bcch-bg);
	border: 1px solid var(--bcch-border);
	border-radius: var(--bcch-radius-md);
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	transition: border-color var(--bcch-trans), box-shadow var(--bcch-trans), transform var(--bcch-trans);
}
.bc-vehicle-card:hover {
	border-color: var(--bcch-primary);
	box-shadow: var(--bcch-shadow-md);
	transform: translateY(-1px);
}
.bc-vehicle-card-body {
	display: flex;
	gap: 10px;
	padding: 10px;
}
.bc-vehicle-card-img {
	width: 96px;
	height: 72px;
	flex-shrink: 0;
	border-radius: var(--bcch-radius-sm);
	overflow: hidden;
	background: var(--bcch-bg-alt);
}
.bc-vehicle-card-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.bc-vehicle-card-info {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
	flex: 1;
}
.bc-vehicle-card-name {
	font-size: 13.5px;
	font-weight: 700;
	color: var(--bcch-text);
	line-height: 1.3;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.bc-vehicle-card-meta {
	font-size: 11.5px;
	color: var(--bcch-text-muted);
	line-height: 1.3;
}
.bc-vehicle-card-price {
	font-size: 13px;
	font-weight: 700;
	color: var(--bcch-primary);
	margin-top: auto;
}
.bc-vehicle-card-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-top: 4px;
	padding: 2px 8px;
	background: var(--bcch-accent-soft);
	color: var(--bcch-accent-dark);
	border-radius: var(--bcch-radius-pill);
	font-size: 10.5px;
	font-weight: 600;
	border: 1px solid var(--bcch-accent-border);
	width: fit-content;
}
.bc-vehicle-card-cta {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 9px;
	background: var(--bcch-accent);
	color: #fff;
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 0.02em;
	transition: background var(--bcch-trans);
}
.bc-vehicle-card:hover .bc-vehicle-card-cta {
	background: #0c8f40;
}

/* === Botón flotante "scroll-to-bottom" === */
.bc-chat-scroll-bottom {
	position: absolute !important;
	right: 14px;
	bottom: 14px;
	width: 32px !important;
	height: 32px !important;
	border-radius: 50% !important;
	background: var(--bcch-bg) !important;
	border: 1px solid var(--bcch-border-strong) !important;
	color: var(--bcch-text-muted) !important;
	cursor: pointer !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	box-shadow: var(--bcch-shadow-md) !important;
	min-width: unset !important;
	min-height: unset !important;
	padding: 0 !important;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--bcch-trans), transform var(--bcch-trans);
	z-index: 5;
}
.bc-chat-scroll-bottom.is-visible {
	opacity: 1;
	pointer-events: auto;
}
.bc-chat-scroll-bottom:hover {
	border-color: var(--bcch-accent) !important;
	color: var(--bcch-accent) !important;
	transform: translateY(-1px);
}

/* === Input area === */
.bc-chat-input-area {
	display: flex;
	padding: 12px 14px;
	gap: 8px;
	border-top: 1px solid var(--bcch-border);
	flex-shrink: 0;
	background: var(--bcch-bg);
}
.bc-chat-input {
	flex: 1;
	border: 1px solid var(--bcch-border-strong);
	border-radius: 20px;
	padding: 9px 16px;
	font-size: 14px;
	outline: none;
	transition: border-color var(--bcch-trans);
	font-family: inherit;
	min-width: 0;
}
.bc-chat-input:focus {
	border-color: var(--bcch-primary);
}
.bc-chat-input::placeholder {
	color: var(--bcch-text-light);
}
/* Pulse al rellenar desde quick reply: indica al usuario que termine la frase */
.bc-chat-input-highlight {
	animation: bcInputPulse 1.2s ease-out;
}
@keyframes bcInputPulse {
	0%   { box-shadow: 0 0 0 0 rgba(14, 168, 76, 0.5); border-color: var(--bcch-accent); }
	60%  { box-shadow: 0 0 0 6px rgba(14, 168, 76, 0); border-color: var(--bcch-accent); }
	100% { box-shadow: 0 0 0 0 rgba(14, 168, 76, 0); border-color: var(--bcch-border-strong); }
}
.bc-chat-send {
	width: 38px !important;
	height: 38px !important;
	border-radius: 50% !important;
	background: var(--bcch-accent) !important;
	color: #fff !important;
	border: none !important;
	cursor: pointer !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex-shrink: 0;
	transition: background var(--bcch-trans), transform var(--bcch-trans);
	min-width: unset !important;
	min-height: unset !important;
	padding: 0 !important;
	box-shadow: none !important;
}
.bc-chat-send:hover {
	background: #0c8f40 !important;
	transform: scale(1.06);
}
.bc-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}
.bc-chat-send:focus-visible {
	outline: 3px solid var(--bcch-accent-soft) !important;
	outline-offset: 2px !important;
}

/* ===========================================================================
   MOBILE (≤ 600px): fullscreen con dvh + safe-area-inset, FAB persiste como cerrar
   =========================================================================== */
@media (max-width: 600px) {
	#bc-chatbot-fab {
		bottom: 15px;
		right: 15px;
		width: 50px;
		height: 50px;
	}
	#bc-chatbot-fab.bc-chatbot-home {
		bottom: 85px;
	}
	/* En mobile, el FAB no desaparece al abrir el chat: queda visible arriba
	   como botón de cerrar más discreto */
	#bc-chatbot-fab.bc-fab-hidden {
		display: none;
	}

	#bc-chatbot-window {
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100vh;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
		padding-top: env(safe-area-inset-top, 0);
		padding-bottom: env(safe-area-inset-bottom, 0);
		box-sizing: border-box;
	}
	#bc-chatbot-window.bc-chatbot-home {
		bottom: 0;
	}
	.bc-chat-header {
		padding-left: max(18px, env(safe-area-inset-left, 0));
		padding-right: max(18px, env(safe-area-inset-right, 0));
	}
	.bc-chat-input-area {
		padding-left: max(14px, env(safe-area-inset-left, 0));
		padding-right: max(14px, env(safe-area-inset-right, 0));
	}

	/* Tarjetas vehículo a ancho completo en mobile */
	.bc-vehicle-card-img {
		width: 88px;
		height: 66px;
	}
}
