/* Chat del sitio (js/chat.js): flotante en todas las páginas y dentro de Contáctanos. */
.chat-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat [hidden] { display: none !important; }

/* Botón flotante: el mismo lugar del de WhatsApp */
.chat-lanzador { background: var(--primary); color: #fff; border: 0; cursor: pointer; box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .45); }
.chat-lanzador[hidden], .chat-abierto .chat-lanzador { display: none; }

.chat {
  display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border-radius: 22px; overflow: hidden;
}
.chat.flotante[hidden] { display: none; }
.chat.flotante {
  position: fixed; right: 22px; bottom: 22px; z-index: 45;
  width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100vh - 120px));
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
}
.chat.en-linea { height: min(640px, 78vh); border: 1px solid var(--line); }

.chat-cab { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.chat-cab > div { flex: 1; min-width: 0; }
.chat-cab h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.chat-sub { margin: 1px 0 0; font-size: 12.5px; color: var(--text-2); }
.chat-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--primary-soft); color: var(--primary); flex: none; }
.chat-icono { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; flex: none; }
.chat-icono .ti-brand-whatsapp { color: #1f9d55; }

.chat-hilo { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.asistente { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.chat-msg.persona { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
.chat-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.chat-msg.nota { align-self: stretch; max-width: none; background: none; font-size: 12.5px; color: var(--text-3); text-align: center; padding: 2px 10px; white-space: normal; }
.chat-msg.escribiendo { display: inline-flex; gap: 4px; }
.chat-msg.escribiendo span:not(.chat-oculto) { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: chat-punto 1s infinite; }
.chat-msg.escribiendo span:nth-child(2) { animation-delay: .15s; }
.chat-msg.escribiendo span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-punto { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-msg.escribiendo span { animation: none; } }

.chat-opciones { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.chat-opciones button, .chat-opciones a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; text-decoration: none;
}
.chat-opciones button:hover, .chat-opciones a:hover { border-color: var(--primary); color: var(--primary); }
.chat-opciones i { font-size: 17px; }

.chat-form { display: grid; gap: 6px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.chat-form label, .chat-form legend { font-size: 13px; font-weight: 600; color: var(--text-2); }
.chat-form small { font-weight: 400; color: var(--text-3); }
.chat-form .entrada { width: 100%; }
.chat-form textarea.entrada { min-height: 72px; resize: vertical; padding: 10px 12px; }
.chat-form .boton { justify-self: start; margin-top: 4px; }
.chat-fila { grid-template-columns: 1fr auto; align-items: center; }
.chat-seg { display: flex; flex-wrap: wrap; gap: 6px 12px; border: 0; padding: 0; margin: 4px 0 0; min-width: 0; }
.chat-seg label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text); }
.chat-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500 !important; margin-top: 4px; }
.chat-check input { margin-top: 3px; }
.chat-check a { color: var(--primary); text-decoration: underline; }
.chat-error { margin: 0; font-size: 13px; color: var(--danger); }

.chat-escribir { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-escribir textarea {
  flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 11px 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; line-height: 1.35;
}
.chat-enviar { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--primary); color: #fff; font-size: 20px; display: grid; place-items: center; cursor: pointer; flex: none; }
.chat-enviar:disabled { opacity: .5; cursor: wait; }
.chat :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 640px) {
  .chat.flotante { inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; z-index: 80; }
  .chat.en-linea { height: 72vh; border-radius: 18px; }
}
