/*
 * Chat de qualificação do site (views/partials/chat.php + chat.js). Tudo começa com .ty-chat / .ty-: nada vaza para o resto do site.
 * Azul #010066, laranja #ff6201 (decorativo) e #b84600 (texto), Poppins (já carregada pelo layout).
 * Posição: canto inferior direito (convite e lançador: ver abaixo). Nas páginas de lançamento (que já têm WhatsApp flutuante ou barra fixa embaixo) o botão sobe e fica empilhado acima.
 */
.ty-chat { --ty-right: 24px; --ty-bottom: 24px; font-family: Poppins, system-ui, -apple-system, "Segoe UI", sans-serif; }
body:has(.lp-float) .ty-chat { --ty-bottom: 98px; }
@media (max-width: 899px) { body:has(.lp-bar) .ty-chat { --ty-bottom: calc(88px + env(safe-area-inset-bottom)); } }
@media (max-width: 720px) { .ty-chat { --ty-right: 16px; } }

/*
 * Botão flutuante (sem JavaScript é um link para o WhatsApp).
 * Celular: botão redondo 62px com o selo de balão (laranja) e a bolinha verde "online". A partir de 768px: pílula de 56px com o texto "Fale com a gente".
 */
.ty-chat { --ty-fab-h: 62px; }
.ty-chat-fab { position: fixed; right: var(--ty-right); bottom: var(--ty-bottom); z-index: 900; width: 62px; height: var(--ty-fab-h); padding: 0; border-radius: 50%; background: #010066; border: 3px solid #ff6201; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 24px rgba(1, 0, 102, .35); cursor: pointer; transition: transform .15s ease; color: #fff; font: 600 15px/1 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif; text-decoration: none; }
.ty-chat-fab:hover { transform: scale(1.05); }
.ty-chat-ico { position: relative; display: block; flex: none; width: 44px; height: 44px; }
.ty-chat-fab img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.ty-chat-on { position: absolute; top: -3px; right: -4px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; box-sizing: border-box; }
.ty-chat-lbl { display: none; white-space: nowrap; color: #fff; }
.ty-chat-badge { position: absolute; top: -9px; right: -9px; width: 24px; height: 24px; display: block; filter: drop-shadow(0 1px 3px rgba(1, 0, 40, .35)); }
/* no celular a bolinha verde vai para baixo, porque o selo ocupa o canto de cima */
.ty-chat-on { top: auto; bottom: -3px; }
@media (min-width: 768px) {
  .ty-chat { --ty-fab-h: 56px; }
  .ty-chat-fab { width: auto; padding: 0 22px 0 6px; border-radius: 999px; gap: 10px; }
  .ty-chat-fab img { width: 40px; height: 40px; }
  .ty-chat-ico { width: 40px; height: 40px; }
  .ty-chat-on { top: -2px; bottom: auto; }
  .ty-chat-lbl { display: block; }
  .ty-chat-badge { display: none; }
}
.ty-chat-fab:focus-visible, .ty-chat button:focus-visible, .ty-chat a:focus-visible, .ty-chat input:focus-visible, .ty-chat select:focus-visible { outline: 3px solid #ff6201; outline-offset: 2px; }

/* Convite (balão): uma vez por visita, acima do botão; no celular fica compacto */
.ty-chat-tip { position: fixed; right: var(--ty-right); bottom: calc(var(--ty-bottom) + var(--ty-fab-h) + 12px); z-index: 900; display: flex; align-items: flex-start; width: max-content; max-width: min(300px, calc(100vw - 2 * var(--ty-right))); background: #fff; border-radius: 16px 16px 4px 16px; box-shadow: 0 6px 20px rgba(1, 0, 102, .22); border: 1px solid #e2e2ee; }
.ty-chat-tip[hidden] { display: none; }
.ty-chat-tip button { font: inherit; border: 0; background: none; color: #14143f; cursor: pointer; }
.ty-chat-tip .ty-chat-tip-open { flex: 1 1 auto; min-width: 0; padding: 12px 4px 12px 14px; font-size: 13.5px; line-height: 1.4; text-align: left; }
.ty-chat-tip .ty-chat-tip-open:hover { color: #010066; text-decoration: underline; }
.ty-chat-tip .ty-chat-tip-x { flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 4px 4px 0 0; color: #4a4a72 !important; border-radius: 50%; }
.ty-chat-tip .ty-chat-tip-x:hover { background: #f0f0f8 !important; }
@media (max-width: 767px) { .ty-chat-tip { max-width: min(260px, calc(100vw - 2 * var(--ty-right))); } .ty-chat-tip .ty-chat-tip-open { font-size: 13px; padding: 10px 2px 10px 12px; } }
/* entrada suave (uma vez); com "reduzir movimento" o balão só aparece, sem deslizar */
@media (prefers-reduced-motion: no-preference) { .ty-chat-tip:not([hidden]) { animation: ty-tip-in .35s ease-out both; } }
@keyframes ty-tip-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Painel: cartão no computador, folha de baixo no celular */
.ty-chat-back { position: fixed; inset: 0; z-index: 905; background: rgba(1, 0, 40, .45); }
.ty-chat-back[hidden] { display: none; }
.ty-chat-panel { position: fixed; right: var(--ty-right); bottom: calc(var(--ty-bottom) + var(--ty-fab-h) + 12px); z-index: 910; width: 380px; max-width: calc(100vw - 16px); height: min(620px, calc(100vh - var(--ty-bottom) - var(--ty-fab-h) - 12px - 16px)); background: #fff; border-radius: 22px; box-shadow: 0 18px 50px rgba(1, 0, 102, .25); display: flex; flex-direction: column; overflow: hidden; color: #14143f; }
.ty-chat-panel[hidden] { display: none; }
@media (max-width: 720px) {
  .ty-chat-panel { left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: 85vh; height: 85dvh; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  html.ty-chat-open { overflow: hidden; }
}

.ty-chat-head { flex: none; background: #010066; color: #fff; padding: 14px 16px; display: flex; gap: 12px; align-items: center; border-bottom: 4px solid #ff6201; }
.ty-chat-head img { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.ty-chat-head strong { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.ty-chat-head small { display: block; font-size: 12px; color: #d4d4f4; line-height: 1.4; }
.ty-chat-close { margin-left: auto; width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: #d4d4f4; cursor: pointer; }
.ty-chat-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.ty-chat-body { flex: 1 1 auto; min-height: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f5f5fa; overflow-y: auto; overscroll-behavior: contain; }
.ty-chat-log { display: flex; flex-direction: column; gap: 10px; }
.ty-b { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; animation: ty-in .18s ease-out; }
.ty-bot { background: #fff; border: 1px solid #e2e2ee; color: #14143f; border-bottom-left-radius: 4px; align-self: flex-start; }
.ty-me { background: #010066; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
@keyframes ty-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ty-b { animation: none; } .ty-chat-fab { transition: none; } }

/* Botões de resposta */
.ty-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ty-chat-actions { display: flex; flex-direction: column; gap: 10px; }
.ty-chat-actions.ty-chips { flex-direction: row; }
.ty-chip { font: inherit; font-size: 12.5px; font-weight: 500; min-height: 34px; padding: 6px 13px; border: 1.5px solid #ff6201; border-radius: 999px; background: #fff; color: #b84600; cursor: pointer; }
.ty-chip:hover { background: #fff3ec; }
.ty-chip[aria-pressed="true"] { background: #010066; border-color: #010066; color: #fff; }
.ty-go { font: inherit; font-size: 14px; font-weight: 700; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: #ff6201; color: #010066; cursor: pointer; }
.ty-go:hover:not(:disabled) { background: #ff7a26; }
.ty-go:disabled { background: #e2e2ee; color: #6b6b8f; cursor: not-allowed; }
.ty-wa { display: block; background: #128040; color: #fff; font-weight: 700; font-size: 13px; border-radius: 999px; padding: 12px 10px; text-align: center; text-decoration: none; }
.ty-wa:hover { background: #0e6a35; color: #fff; }

.ty-chat-prog { margin: 0; font-size: 11px; line-height: 1.5; color: #4a4a72; text-align: center; }
.ty-chat-prog[hidden] { display: none; }
.ty-chat-prog a { color: inherit; text-decoration: underline; }
.ty-chat-prog a:hover { color: #b84600; }

/* Cartões de imóvel */
.ty-card { background: #fff; border: 1px solid #e2e2ee; border-radius: 14px; display: flex; gap: 10px; padding: 8px; align-items: center; text-decoration: none; color: #14143f; animation: ty-in .18s ease-out; }
.ty-card:hover { border-color: #ff6201; }
.ty-card img, .ty-card-ph { width: 64px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: linear-gradient(135deg, #7aa7d6, #2d5f94); display: block; }
.ty-card-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ty-card-t b { font-size: 12.5px; line-height: 1.35; color: #010066; font-weight: 700; }
.ty-card-t span { font-size: 12px; line-height: 1.4; color: #4a4a72; }

/* Rodapé com texto livre */
.ty-chat-foot { flex: none; display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e2ee; background: #fff; }
.ty-chat-foot input { flex: 1 1 auto; min-width: 0; min-height: 40px; border: 1px solid #c9c9e0; border-radius: 999px; padding: 0 14px; font: inherit; font-size: 13px; color: #14143f; background: #fff; }
.ty-chat-foot input::placeholder { color: #6b6b8f; }
.ty-chat-foot input:disabled { background: #f5f5fa; }
.ty-chat-send { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #ff6201; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ty-chat-send:disabled { background: #c9c9e0; cursor: not-allowed; }
@media (max-width: 720px) { .ty-phone .ddi { width: 138px; } .ty-chat-foot input, .ty-form input:not([type="checkbox"]), .ty-form select { font-size: 16px !important; } .ty-chip { min-height: 40px; font-size: 13.5px; } }

/* Dados de contato */
.ty-form { background: #fff; border: 1px solid #e2e2ee; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ty-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ty-f-lbl { font-size: 12px; font-weight: 500; color: #4a4a72; }
.ty-form input:not([type="checkbox"]), .ty-form select { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid #b9b9d4; border-radius: 10px; background: #fff; color: #14143f; font: inherit; font-size: 14px; }
.ty-form input[aria-invalid="true"] { border-color: #b3261e; }
.ty-phone { display: flex; gap: 6px; }
.ty-phone .ddi { flex: 0 0 auto; width: 112px; padding: 0 4px; font-size: 13px; }
.ty-phone input { flex: 1 1 auto; min-width: 0; }
.ty-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0; }
.ty-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.45; color: #4a4a72; }
.ty-consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: #010066; }
.ty-consent a { color: #010066; text-decoration: underline; }
.ty-err { display: block; min-height: 0; font-size: 12px; line-height: 1.4; color: #b3261e; margin: 0; }
.ty-err:empty { display: none; }
