/* Widget bot estilo WhatsApp */
.wa-bot {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9500;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.wa-bot-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: #25d366;
  color: #fff;
  box-shadow: 0 4px 18px rgba(37, 211, 102, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.wa-bot-toggle:hover {
  background: #20bd5a;
  transform: scale(1.05);
}

.wa-bot-toggle svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.wa-bot-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 6rem));
  background: #efeae2;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.wa-bot-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.wa-bot-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.35'%3E%3Ccircle cx='8' cy='8' r='1.5'/%3E%3Ccircle cx='28' cy='22' r='1'/%3E%3Ccircle cx='48' cy='12' r='1.2'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.wa-bot-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: #075e54;
  color: #fff;
}

.wa-bot-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  padding: 4px;
  object-fit: contain;
}

.wa-bot-header-info {
  flex: 1;
  min-width: 0;
}

.wa-bot-header-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.wa-bot-header-status {
  font-size: 0.72rem;
  opacity: 0.9;
}

.wa-bot-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.9;
}

.wa-bot-header-close:hover {
  opacity: 1;
}

.wa-bot-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wa-bot-msg {
  display: flex;
  max-width: 88%;
  animation: waMsgIn 0.28s ease;
}

@keyframes waMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wa-bot-msg--in {
  align-self: flex-start;
}

.wa-bot-msg--out {
  align-self: flex-end;
}

.wa-bot-bubble {
  padding: 0.45rem 0.65rem 0.35rem;
  border-radius: 8px;
  font-size: 0.84rem;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  word-wrap: break-word;
}

.wa-bot-msg--in .wa-bot-bubble {
  background: #fff;
  border-top-left-radius: 2px;
  color: #111;
}

.wa-bot-msg--out .wa-bot-bubble {
  background: #d9fdd3;
  border-top-right-radius: 2px;
  color: #111;
}

.wa-bot-time {
  display: block;
  font-size: 0.65rem;
  color: #667781;
  text-align: right;
  margin-top: 0.2rem;
}

.wa-bot-msg--in .wa-bot-time {
  text-align: left;
}

.wa-bot-system {
  align-self: center;
  max-width: 95%;
  text-align: center;
  font-size: 0.72rem;
  color: #54656f;
  background: rgba(255, 255, 255, 0.85);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  margin: 0.25rem 0;
}

.wa-bot-options {
  position: relative;
  z-index: 1;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(239, 234, 226, 0.95);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-bot-options-label {
  font-size: 0.7rem;
  color: #54656f;
  text-align: center;
}

.wa-bot-option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.wa-bot-chip {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #075e54;
  background: #fff;
  color: #075e54;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.wa-bot-chip:hover,
.wa-bot-chip.is-active {
  background: #075e54;
  color: #fff;
}

.wa-bot-chip--main {
  width: 100%;
  border-radius: 8px;
  text-align: left;
  padding: 0.55rem 0.75rem;
}

.wa-bot-length {
  display: none;
  gap: 0.35rem;
}

.wa-bot-length.is-visible {
  display: flex;
}

.wa-bot-length .wa-bot-chip {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
}

.wa-bot-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: #f0f2f5;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-bot-footer.is-hidden {
  display: none;
}

.wa-bot-input {
  flex: 1;
  resize: none;
  border: none;
  border-radius: 20px;
  padding: 0.55rem 0.85rem;
  font-family: inherit;
  font-size: 0.85rem;
  max-height: 80px;
  line-height: 1.35;
  background: #fff;
}

.wa-bot-input:focus {
  outline: none;
}

.wa-bot-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #075e54;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-bot-send:hover {
  background: #128c7e;
}

.wa-bot-send svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.wa-bot-typing {
  align-self: flex-start;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 8px;
  border-top-left-radius: 2px;
  display: flex;
  gap: 4px;
}

.wa-bot-typing span {
  width: 7px;
  height: 7px;
  background: #90949c;
  border-radius: 50%;
  animation: waTyping 1.2s infinite ease-in-out;
}

.wa-bot-typing span:nth-child(2) { animation-delay: 0.15s; }
.wa-bot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes waTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .wa-bot {
    right: 1rem;
    bottom: 1rem;
  }

  .wa-bot-panel {
    width: calc(100vw - 2rem);
    right: -0.25rem;
  }
}

/* Evitar solapamiento con scroll-up */
body:has(.wa-bot-panel.is-open) .scroll-up {
  bottom: calc(5.5rem + 100px);
}

@media (max-width: 768px) {
  .scroll-up {
    bottom: calc(5.5rem + 100px);
  }
}
