/* Zilly — widget de soporte flotante. Usa las variables de portal.css (--spt-*), así que
   sigue el tema claro/oscuro del portal automáticamente, sin colores propios. */

.spt-zilly {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.spt-zilly-bubble {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--spt-glow) 0%, var(--spt-accent) 55%, var(--spt-accent-deep) 100%);
  box-shadow: 0 18px 32px -16px rgba(124, 92, 255, .7);
  color: #fff;
  transition: transform .15s ease, box-shadow .15s ease;
}
.spt-zilly-bubble:hover { transform: translateY(-2px); }
.spt-zilly-bubble svg { width: 24px; height: 24px; }
.spt-zilly-bubble .spt-zilly-x { display: none; }
.spt-zilly[data-abierto="1"] .spt-zilly-bubble .spt-zilly-headset { display: none; }
.spt-zilly[data-abierto="1"] .spt-zilly-bubble .spt-zilly-x { display: block; }

.spt-zilly-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--spt-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--spt-bg);
}
.spt-zilly-badge[hidden] { display: none; }

.spt-zilly-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: min(320px, calc(100vw - 40px));
  max-height: min(460px, calc(100vh - 120px));
  max-height: min(460px, calc(100dvh - 120px)); /* evita el salto de tamano por la barra de direcciones en movil */
  display: flex;
  flex-direction: column;
  background: var(--spt-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--spt-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7);
}
.spt-zilly-panel[hidden] { display: none; }

.spt-zilly-head {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--spt-glow) 0%, var(--spt-accent) 55%, var(--spt-accent-deep) 100%);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.spt-zilly-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.spt-zilly-avatar svg { width: 15px; height: 15px; }
.spt-zilly-head-text { flex: 1; min-width: 0; }
.spt-zilly-head-text p { margin: 0; line-height: 1.25; }
.spt-zilly-head-nombre { font-size: 13px; font-weight: 800; color: #fff; }
.spt-zilly-head-estado { font-size: 10px; color: rgba(255, 255, 255, .78); }
.spt-zilly-cerrar {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: .85;
}
.spt-zilly-cerrar:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.spt-zilly-cerrar svg { width: 16px; height: 16px; }

.spt-zilly-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}

.spt-zilly-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.spt-zilly-msg-bot,
.spt-zilly-msg-humano {
  align-self: flex-start;
  background: var(--spt-accent-soft);
  color: var(--spt-heading);
  border-bottom-left-radius: 4px;
}
.spt-zilly-msg-cliente {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--spt-glow), var(--spt-accent-deep));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.spt-zilly-msg-error {
  align-self: center;
  background: var(--spt-danger-bg);
  color: var(--spt-danger);
  font-size: 11.5px;
}

.spt-zilly-fila-bot { display: flex; align-items: flex-end; gap: 6px; }
.spt-zilly-mini-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--spt-accent-soft);
  color: var(--spt-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.spt-zilly-mini-avatar svg { width: 10px; height: 10px; }

.spt-zilly-msg.spt-zilly-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
}
.spt-zilly-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
  display: inline-block;
  animation: spt-zilly-typing-rebote 1.1s infinite ease-in-out;
}
.spt-zilly-typing span:nth-child(2) { animation-delay: .15s; }
.spt-zilly-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes spt-zilly-typing-rebote {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.spt-zilly-vacio {
  margin: auto;
  text-align: center;
  color: var(--spt-muted);
  font-size: 12px;
  padding: 0 10px;
}

.spt-zilly-foot {
  flex-shrink: 0;
  border-top: 1px solid var(--spt-border);
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.spt-zilly-textarea {
  flex: 1;
  resize: none;
  border: none;
  background: var(--spt-bg-elev);
  border-radius: 14px;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--spt-heading);
  max-height: 80px;
  outline: none;
}
.spt-zilly-textarea::placeholder { color: var(--spt-muted); }
.spt-zilly-enviar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--spt-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.spt-zilly-enviar:disabled { opacity: .5; cursor: default; }
.spt-zilly-enviar svg { width: 14px; height: 14px; }

@media (max-width: 420px) {
  .spt-zilly { right: 12px; bottom: 12px; }
  .spt-zilly-panel { width: calc(100vw - 24px); }
}
