/* ═══════════════════════════════════════════════════════════
   Widget de chat — Synapsur (Asistente: Clara · ia.kapos.cl)
   Paleta: teal neuromodulación + slate profundo
   ═══════════════════════════════════════════════════════════ */

/* ── Botón flotante ── */
#sy-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 0;
  border: 3px solid #14b8a6;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(13, 148, 136, 0.45);
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: #fff;
}
#sy-toggle-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
#sy-online-dot {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #10b981;
  border: 2.5px solid #fff;
  pointer-events: none;
}
/* Ondas de radiación de calor */
#sy-chat-toggle::before,
#sy-chat-toggle::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(20, 184, 166, 0.8);
  animation: sy-heat 2.6s ease-out infinite;
  pointer-events: none;
}
#sy-chat-toggle::after { animation-delay: 1.3s; }
#sy-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(13, 148, 136, 0.65);
}

@keyframes sy-heat {
  0%   { transform: scale(1);   opacity: 0.9; }
  70%  { transform: scale(1.85); opacity: 0; }
  100% { transform: scale(1.85); opacity: 0; }
}

/* ── Ícono de chat SVG en el botón ── */
#sy-toggle-icon {
  width: 36px;
  height: 36px;
  fill: white;
  display: block;
}

/* ── Ventana de chat ── */
#sy-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.20);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: scale(0.92) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#sy-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#sy-chat-header {
  background: linear-gradient(135deg, #0f766e, #14b8a6 55%, #0d9488);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#sy-chat-header .sy-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}
#sy-chat-header .sy-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
#sy-chat-header .sy-avatar svg {
  width: 26px;
  height: 26px;
  fill: white;
}
#sy-chat-header .sy-info { flex: 1; }
#sy-chat-header .sy-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
#sy-chat-header .sy-sub  { font-size: 11px; opacity: 0.75; margin-top: 1px; }
#sy-chat-header .sy-status { font-size: 12px; opacity: 0.80; }
#sy-chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.15s;
}
#sy-chat-close:hover { opacity: 1; }
#sy-chat-close svg { width: 18px; height: 18px; fill: white; display: block; }

/* ── Mensajes ── */
#sy-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f0fdfa;
  scrollbar-width: thin;
  scrollbar-color: #99c9c2 transparent;
}
.sy-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.sy-msg.bot {
  background: white;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.09);
}
.sy-msg.user {
  background: linear-gradient(135deg, #134e4a, #0f766e);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.sy-msg.typing { color: #94a3b8; font-style: italic; }
.sy-chat-link {
  color: #0f766e;
  text-decoration: underline;
  font-weight: 500;
  word-break: break-all;
}
.sy-chat-link:hover { color: #134e4a; }

/* ── Input area ── */
#sy-chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  background: white;
  flex-shrink: 0;
}
#sy-chat-input {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
}
#sy-chat-input:focus { border-color: #14b8a6; }
#sy-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #134e4a, #0f766e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
#sy-chat-send:hover { transform: scale(1.06); }
#sy-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
#sy-chat-send svg { width: 18px; height: 18px; fill: white; }

#sy-chat-powered {
  text-align: center;
  font-size: 11px;
  color: #b0b8c4;
  padding-bottom: 6px;
}

/* ── Formulario de captura de lead ── */
#sy-lead-form {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 22px;
  gap: 10px;
  z-index: 10;
  overflow-y: auto;
}
#sy-lead-form .sy-lf-title {
  font-weight: 700;
  font-size: 15px;
  color: #0f766e;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 2px;
}
#sy-lead-form .sy-lf-sub {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-bottom: 6px;
}
#sy-lead-form .sy-lf-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
#sy-lead-form .sy-lf-logo img {
  width: auto;
  height: 44px;
  border: none;
  padding: 0;
  background: transparent;
}
#sy-lead-form input {
  border: 1.5px solid #99c9c2;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
#sy-lead-form input:focus { border-color: #14b8a6; }
#sy-lead-form input.sy-lf-err { border-color: #ef4444; }
#sy-lead-form .sy-lf-msg {
  font-size: 12px;
  color: #ef4444;
  padding-left: 4px;
  display: none;
  margin-top: -6px;
}
#sy-lead-form .sy-lf-msg.show { display: block; }
#sy-lead-form .sy-lf-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  cursor: pointer;
}
#sy-lead-form .sy-lf-consent input {
  width: auto;
  margin-top: 2px;
  flex: none;
  accent-color: #14b8a6;
  cursor: pointer;
}
#sy-lead-form .sy-lf-consent a {
  color: #0f766e;
  text-decoration: underline;
}
#sy-lead-form button {
  background: linear-gradient(135deg, #134e4a, #0f766e);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 6px;
}
#sy-lead-form button:hover { opacity: 0.88; }
#sy-lead-form button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Responsive ── */
@media (max-width: 480px) {
  #sy-chat-toggle { width: 60px; height: 60px; bottom: 16px; right: 16px; }
  #sy-toggle-icon { width: 30px; height: 30px; }
  #sy-chat-window {
    bottom: 88px;
    right: 16px;
    width: calc(100vw - 32px);
    height: min(520px, calc(100vh - 120px));
  }
}

@media (prefers-reduced-motion: reduce) {
  #sy-chat-toggle { animation: none; }
  #sy-chat-toggle::before,
  #sy-chat-toggle::after { display: none; }
}
