#mjca-chat-assistant {
  --mjca-dark: var(--dark, #16201d);
  --mjca-green: var(--green, #2b4a3e);
  --mjca-sage: var(--sage, #7db4a6);
  --mjca-accent: var(--terra, #c0673a);
  --mjca-light: var(--ivory, #f5efe6);
  --mjca-serif: var(--font-serif, Georgia, serif);
  --mjca-sans: var(--font-sans, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
  box-sizing: border-box;
}

#mjca-chat-assistant *,
#mjca-chat-assistant *::before,
#mjca-chat-assistant *::after {
  box-sizing: border-box;
}

.mjca-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.mjca-toggle:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

.mjca-toggle-ring {
  position: absolute;
  inset: 0;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(#c0673a 0%, #f5c8a8 20%, #7db4a6 45%, #2b4a3e 65%, #7db4a6 80%, #c0673a 100%);
  animation: mjcaAvatarSpin 4s linear infinite;
}

.mjca-toggle-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--mjca-green);
  color: var(--mjca-light);
  font-family: var(--mjca-serif);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.mjca-badge {
  position: absolute;
  top: -4px;
  right: -3px;
  padding: 0.17rem 0.38rem;
  border-radius: 2rem;
  background: var(--mjca-accent);
  color: var(--mjca-light);
  font-family: var(--mjca-sans);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.mjca-panel {
  width: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(125, 180, 166, 0.22);
  border-radius: 14px;
  background: var(--mjca-dark);
  box-shadow: 0 10px 48px rgba(0, 0, 0, 0.5);
  animation: mjcaSlideUp 0.28s ease both;
}

.mjca-panel[hidden] {
  display: none !important;
}

.mjca-head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(245, 239, 230, 0.08);
  background: var(--mjca-green);
}

.mjca-avatar {
  flex-shrink: 0;
  animation: mjcaAvatarFloat 3.5s ease-in-out infinite;
}

.mjca-avatar-ring {
  width: 46px;
  height: 46px;
  display: block;
  padding: 2.5px;
  border-radius: 50%;
  background: conic-gradient(#c0673a 0%, #f5c8a8 20%, #7db4a6 45%, #2b4a3e 65%, #7db4a6 80%, #c0673a 100%);
  animation: mjcaAvatarSpin 4s linear infinite;
}

.mjca-avatar-photo {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 12%;
  animation: mjcaAvatarUnspin 4s linear infinite;
}

.mjca-head-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.mjca-head-name {
  color: var(--mjca-light);
  font-family: var(--mjca-sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mjca-head-status {
  color: var(--mjca-sage);
  font-family: var(--mjca-sans);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.mjca-close,
.mjca-reset {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  border: 0;
  background: transparent;
  color: rgba(245, 239, 230, 0.45);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s;
}

.mjca-close:hover,
.mjca-reset:hover {
  color: var(--mjca-light);
}

.mjca-body {
  min-height: 200px;
  max-height: 310px;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
}

.mjca-msg {
  max-width: 86%;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-family: var(--mjca-sans);
  font-size: 0.81rem;
  line-height: 1.55;
  animation: mjcaMsgIn 0.25s ease both;
}

.mjca-msg.ai {
  align-self: flex-start;
  border: 1px solid rgba(125, 180, 166, 0.12);
  border-radius: 12px 12px 12px 3px;
  background: rgba(43, 74, 62, 0.5);
  color: rgba(245, 239, 230, 0.92);
}

.mjca-msg.user {
  align-self: flex-end;
  border: 1px solid rgba(192, 103, 58, 0.2);
  border-radius: 12px 12px 3px 12px;
  background: rgba(192, 103, 58, 0.28);
  color: rgba(245, 239, 230, 0.92);
}

.mjca-typing {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  padding: 0.7rem 0.9rem;
  border-radius: 12px 12px 12px 3px;
  background: rgba(43, 74, 62, 0.38);
  animation: mjcaMsgIn 0.2s ease both;
}

.mjca-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mjca-sage);
  animation: mjcaTypeDot 1.2s ease-in-out infinite;
}

.mjca-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.mjca-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

.mjca-foot {
  flex-shrink: 0;
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(245, 239, 230, 0.07);
  background: rgba(0, 0, 0, 0.18);
}

.mjca-cta-button,
.mjca-whatsapp-button {
  width: 100%;
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--mjca-accent);
  color: var(--mjca-light);
  font-family: var(--mjca-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, background 0.2s, transform 0.2s;
}

.mjca-whatsapp-button {
  background: #1f8f5f;
}

.mjca-cta-button.visible,
.mjca-whatsapp-button.visible {
  opacity: 1;
  pointer-events: auto;
}

.mjca-cta-button:hover {
  background: #a85530;
  color: var(--mjca-light);
  transform: translateY(-1px);
}

.mjca-whatsapp-button:hover {
  background: #18784f;
  color: var(--mjca-light);
  transform: translateY(-1px);
}

.mjca-whatsapp-button.disabled,
.mjca-whatsapp-button.disabled:hover {
  background: rgba(245, 239, 230, 0.18);
  color: rgba(245, 239, 230, 0.48);
  cursor: not-allowed;
  transform: none;
}

.mjca-whatsapp-status {
  display: none;
  color: rgba(245, 239, 230, 0.62);
  font-family: var(--mjca-sans);
  font-size: 0.68rem;
  line-height: 1.35;
  text-align: center;
}

.mjca-whatsapp-button.visible + .mjca-whatsapp-status {
  display: block;
}

.mjca-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  animation: mjcaMsgIn 0.3s ease 0.2s both;
}

.mjca-option-button {
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(125, 180, 166, 0.28);
  border-radius: 8px;
  background: transparent;
  color: rgba(245, 239, 230, 0.72);
  font-family: var(--mjca-sans);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.mjca-option-button:hover {
  border-color: var(--mjca-sage);
  background: rgba(43, 74, 62, 0.45);
  color: var(--mjca-light);
}

.mjca-option-button.secondary {
  color: rgba(245, 239, 230, 0.62);
}

.mjca-option-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mjca-consent-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  animation: mjcaMsgIn 0.3s ease both;
}

@keyframes mjcaSlideUp {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mjcaAvatarSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes mjcaAvatarUnspin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(-360deg);
  }
}

@keyframes mjcaAvatarFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes mjcaMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mjcaTypeDot {
  0%,
  60%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

@media (max-width: 480px) {
  #mjca-chat-assistant {
    right: 1rem;
    bottom: 1rem;
  }

  .mjca-panel {
    width: calc(100vw - 2rem);
  }
}
