/* ==========================================================================
   CONVIVE — Widget de chat (SOCI)
   Reemplaza al widget embebido de SendPulse. Usa los mismos tokens que el
   resto del sitio (assets/css/variables.css) para quedar integrado.
   ========================================================================== */

.soci-bubble {
  position: fixed;
  right: var(--sp-md);
  bottom: var(--sp-md);
  width: 62px;
  height: 62px;
  border-radius: var(--radius-full);
  background: var(--g-brand);
  border: none;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--z-modal);
  color: var(--c-white);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  animation: soci-bubble-in var(--dur-slow) var(--ease-out);
}

.soci-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-glow);
}

.soci-bubble:active {
  transform: translateY(0) scale(0.98);
}

.soci-bubble svg {
  width: 26px;
  height: 26px;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.soci-bubble__close {
  position: absolute;
  opacity: 0;
  transform: scale(0.6) rotate(-45deg);
}

.soci-bubble.is-open .soci-bubble__chat {
  opacity: 0;
  transform: scale(0.6) rotate(45deg);
}

.soci-bubble.is-open .soci-bubble__close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.soci-bubble__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--c-aqua-500);
  border: 2px solid var(--c-white);
}

.soci-bubble__dot.is-hidden {
  display: none;
}

@keyframes soci-bubble-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.soci-panel {
  position: fixed;
  right: var(--sp-md);
  bottom: calc(var(--sp-md) + 62px + var(--sp-xs));
  width: min(380px, calc(100vw - 2 * var(--sp-md)));
  height: min(600px, 74vh);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.soci-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.soci-panel__header {
  background: var(--g-brand);
  color: var(--c-white);
  padding: var(--sp-sm) var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

.soci-panel__avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.soci-panel__avatar svg { width: 20px; height: 20px; }

.soci-panel__title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); line-height: var(--lh-tight); }

.soci-panel__subtitle {
  font-size: var(--fs-xs);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.soci-panel__subtitle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: #6ee7b7;
  box-shadow: 0 0 0 2px rgba(110, 231, 183, 0.35);
}

.soci-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2xs);
  background: var(--c-surface-2);
  scroll-behavior: smooth;
}

.soci-msg {
  max-width: 84%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: soci-msg-in var(--dur-fast) var(--ease-out);
}

@keyframes soci-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.soci-msg--bot {
  align-self: flex-start;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  color: var(--c-ink-900);
  border-bottom-left-radius: 4px;
}

.soci-msg--user {
  align-self: flex-end;
  background: var(--g-brand);
  color: var(--c-white);
  border-bottom-right-radius: 4px;
}

.soci-msg--image img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.soci-options {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
  margin-top: 2px;
}

.soci-options--row { flex-direction: row; flex-wrap: wrap; }

.soci-option {
  background: var(--c-white);
  border: 1.5px solid var(--c-blue-500);
  color: var(--c-blue-600);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.soci-option:hover:not(:disabled) {
  background: var(--c-blue-500);
  color: var(--c-white);
  transform: translateY(-1px);
}

.soci-option:disabled { opacity: 0.5; cursor: default; }

.soci-list-row {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.soci-list-row:hover:not(:disabled) {
  border-color: var(--c-blue-500);
  background: var(--c-blue-100);
}

.soci-list-row:disabled { opacity: 0.5; cursor: default; }

.soci-list-row__title { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--c-ink-900); }
.soci-list-row__desc { font-size: 0.75rem; color: var(--c-ink-500); margin-top: 2px; }

.soci-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.7rem 0.9rem;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
}

.soci-typing span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--c-ink-300);
  animation: soci-typing-bounce 1.1s infinite ease-in-out;
}

.soci-typing span:nth-child(2) { animation-delay: 0.15s; }
.soci-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes soci-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.soci-panel__footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2xs);
  padding: var(--sp-2xs) var(--sp-sm);
  border-top: 1px solid var(--c-border);
  background: var(--c-white);
}

.soci-input {
  flex: 1;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-full);
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--c-ink-900);
  background: var(--c-surface-2);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.soci-input:focus { border-color: var(--c-blue-500); }
.soci-input:disabled { opacity: 0.6; }

.soci-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--g-brand);
  color: var(--c-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}

.soci-send:hover:not(:disabled) { transform: scale(1.07); }
.soci-send:disabled { opacity: 0.45; cursor: default; }
.soci-send svg { width: 17px; height: 17px; }

@media (max-width: 480px) {
  .soci-panel {
    right: var(--sp-2xs);
    left: var(--sp-2xs);
    width: auto;
    bottom: calc(var(--sp-2xs) + 62px + var(--sp-2xs));
    height: min(560px, 72vh);
  }
  .soci-bubble { right: var(--sp-sm); bottom: var(--sp-sm); }
}
