/**
 * Chatbot IA — front-end (Imob Pro Theme).
 * Widget flutuante, leve, sem dependências. Respeita prefers-reduced-motion
 * e prefers-color-scheme (segue o modo claro/escuro do tema).
 */

.imob-chat { position: fixed; z-index: 9000; right: 20px; bottom: 20px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }

.rcp-wa-pos-left .imob-chat { right: auto; left: 20px; }
.rcp-wa-on .imob-chat { bottom: 92px; }

.imob-chat__fab {
	width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
	background: linear-gradient(135deg, #2563eb, #3b82f6);
	color: #fff; font-size: 26px; box-shadow: 0 10px 28px rgba(37,99,235,.35);
	display: flex; align-items: center; justify-content: center;
	transition: transform .15s ease;
}
.imob-chat__fab:hover { transform: scale(1.05); }
.imob-chat__fab.is-active { transform: scale(.94); }

.imob-chat__panel {
	position: absolute; bottom: 72px; right: 0; width: 340px; max-width: calc(100vw - 40px);
	max-height: 480px; background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.22);
	display: flex; flex-direction: column; overflow: hidden;
}
/* O atributo [hidden] precisa de override explícito: uma regra de autor com
   display:flex vence a regra padrão do navegador (display:none) mesmo com
   [hidden] presente, então o JS não conseguiria esconder o painel sem isto. */
.imob-chat__panel[hidden] { display: none; }
.rcp-wa-pos-left .imob-chat__panel { right: auto; left: 0; }

.imob-chat__head {
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	padding: 14px 16px; background: linear-gradient(120deg, #2563eb, #3b82f6); color: #fff;
}
.imob-chat__agent { display: flex; align-items: center; gap: 10px; min-width: 0; }
.imob-chat__avatar {
	width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
	background: rgba(255,255,255,.25); border: 1px solid rgba(255,255,255,.4);
}
.imob-chat__avatar--placeholder { display: inline-block; }
.imob-chat__agent-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.imob-chat__title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imob-chat__role { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imob-chat__close { background: transparent; border: 0; color: #fff; font-size: 20px; cursor: pointer; line-height: 1; }
.imob-chat__intro { padding: 10px 16px 0; font-size: 12px; color: #6b7280; }

.imob-chat__messages { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.imob-chat__msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; }
.imob-chat__msg--bot { align-self: flex-start; background: #f3f4f6; color: #1f2329; border-bottom-left-radius: 3px; }
.imob-chat__msg--user { align-self: flex-end; background: #2563eb; color: #fff; border-bottom-right-radius: 3px; }
.imob-chat__msg--typing { opacity: .6; font-style: italic; }

/* Mensagens do bot podem conter HTML seguro (parágrafos/listas/negrito)
   gerado por safeMarkdownToHtml() — nunca HTML bruto vindo da IA. */
.imob-chat__msg--bot p { margin: 0 0 8px; }
.imob-chat__msg--bot p:last-child { margin-bottom: 0; }
.imob-chat__msg--bot ul { margin: 0 0 8px; padding-left: 18px; }
.imob-chat__msg--bot ul:last-child { margin-bottom: 0; }
.imob-chat__msg--bot li { margin-bottom: 4px; }
.imob-chat__msg--bot li:last-child { margin-bottom: 0; }
.imob-chat__msg--bot strong { font-weight: 700; }
.imob-chat__msg--bot a { color: inherit; text-decoration: underline; }

.imob-chat__ctas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.imob-chat__cta {
	display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
	font-size: 12.5px; font-weight: 600; text-decoration: none; border: 1px solid #e7e3dd; color: #1f2329;
}
.imob-chat__cta--wa { background: #25d366; color: #fff; border-color: transparent; }
.imob-chat__cta--form { background: #fff; }
.imob-chat__cta--landing { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.imob-chat__quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
.imob-chat__quick:empty { display: none; padding: 0; }
.imob-chat__quickbtn {
	background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 999px;
	padding: 6px 11px; font-size: 12px; cursor: pointer;
}
.imob-chat__quickbtn:hover { background: #dbeafe; }

.imob-chat__leadbox { margin-top: 4px; }
.imob-chat__leadform { display: flex; flex-direction: column; gap: 8px; background: #f9fafb; border-radius: 10px; padding: 10px; }
.imob-chat__linput { border: 1px solid #e7e3dd; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.imob-chat__consent { font-size: 11.5px; color: #6b7280; display: flex; gap: 6px; align-items: flex-start; }

.imob-chat__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e7e3dd; }
.imob-chat__input { flex: 1 1 auto; border: 1px solid #e7e3dd; border-radius: 999px; padding: 9px 14px; font-size: 13.5px; }
.imob-chat__send {
	border: 0; background: #2563eb; color: #fff; border-radius: 999px; padding: 9px 16px;
	font-size: 13px; font-weight: 700; cursor: pointer;
}
.imob-chat__send:hover { background: #1d4ed8; }

@media (prefers-color-scheme: dark) {
	.imob-chat__panel { background: #1b1e24; }
	.imob-chat__intro { color: #9ca3af; }
	.imob-chat__msg--bot { background: #262b33; color: #e5e7eb; }
	.imob-chat__cta { color: #e5e7eb; border-color: #333944; background: #21252c; }
	.imob-chat__leadform { background: #21252c; }
	.imob-chat__linput { background: #1b1e24; border-color: #333944; color: #e5e7eb; }
	.imob-chat__form { border-top-color: #333944; }
}

@media (prefers-reduced-motion: reduce) {
	.imob-chat__fab { transition: none; }
}

@media (max-width: 480px) {
	.imob-chat { right: 12px; bottom: 12px; }
	.imob-chat__panel { width: calc(100vw - 24px); max-height: 70vh; }
}

/* ---------- Aceite único (LGPD) antes da conversa ---------- */
.imob-chat__gate {
	background: var(--rcp-surface, #f8fafc);
	border: 1px solid var(--rcp-border, #e2e8f0);
	border-radius: 14px;
	padding: 16px;
	margin: 4px 0 8px;
}
.imob-chat__gate-title {
	display: block;
	font-size: 15px;
	margin-bottom: 6px;
	color: var(--rcp-text, #0f172a);
}
.imob-chat__gate-text {
	margin: 0 0 10px;
	font-size: 13.5px;
	line-height: 1.55;
	color: var(--rcp-muted, #64748b);
}
.imob-chat__gate-links {
	margin: 0 0 12px;
	font-size: 13px;
}
.imob-chat__gate-links a {
	color: var(--rcp-primary, #2563eb);
	text-decoration: underline;
}
.imob-chat__gate-accept {
	display: block;
	width: 100%;
	padding: 11px 16px;
	border: 0;
	border-radius: 10px;
	background: var(--rcp-primary, #2563eb);
	color: #fff;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
}
.imob-chat__gate-accept:hover { background: var(--rcp-primary-dk, #1d4ed8); }

/* Composer desabilitado enquanto o aceite não é dado */
.imob-chat__form--disabled { opacity: .55; }
.imob-chat__form--disabled .imob-chat__input,
.imob-chat__form--disabled .imob-chat__send { cursor: not-allowed; }

/* Erro do formulário de lead (inline, sem destruir o formulário) */
.imob-chat__leaderr {
	margin: 2px 0 8px;
	padding: 8px 10px;
	border-radius: 8px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
	line-height: 1.45;
}
