.crm-ai-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1080;
  font-family: "Nunito Sans", system-ui, sans-serif;
}

.crm-ai-chat__fab {
  width: 3.4rem;
  height: 3.4rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, #0d6e6e 0%, #14532d 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(13, 64, 48, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.crm-ai-chat__fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 32px rgba(13, 64, 48, 0.42);
}

.crm-ai-chat__fab-dot {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  background: #86efac;
  border-radius: 50%;
  top: 0.55rem;
  right: 0.55rem;
  box-shadow: 0 0 0 2px #0d6e6e;
}

.crm-ai-chat__panel {
  position: absolute;
  right: 0;
  bottom: 4.2rem;
  width: min(24.5rem, calc(100vw - 1.5rem));
  height: min(34rem, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  background: #f7faf8;
  border: 1px solid #d5e0d9;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(15, 40, 30, 0.22);
  animation: crm-ai-slide-up 0.22s ease;
}

.crm-ai-chat__panel[hidden] {
  display: none !important;
}

@keyframes crm-ai-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.crm-ai-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(120deg, #0f3d2e, #1a5c45);
  color: #fff;
}

.crm-ai-chat__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.crm-ai-chat__brand strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.crm-ai-chat__brand small {
  display: block;
  opacity: 0.8;
  font-size: 0.72rem;
}

.crm-ai-chat__avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.crm-ai-chat__actions {
  display: flex;
  gap: 0.25rem;
}

.crm-ai-chat__icon-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.crm-ai-chat__icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.crm-ai-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background:
    radial-gradient(circle at top right, rgba(34, 120, 90, 0.08), transparent 40%),
    #f7faf8;
}

.crm-ai-chat__bubble {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 0.9rem;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.crm-ai-chat__bubble--user {
  align-self: flex-end;
  background: #14532d;
  color: #fff;
  border-bottom-right-radius: 0.3rem;
}

.crm-ai-chat__bubble--assistant {
  align-self: flex-start;
  background: #fff;
  color: #1f2933;
  border: 1px solid #d9e5dd;
  border-bottom-left-radius: 0.3rem;
}

.crm-ai-chat__bubble--system {
  align-self: center;
  max-width: 95%;
  background: #e8f2ec;
  color: #345;
  border: 1px dashed #b7cdb5;
  font-size: 0.8rem;
  text-align: center;
}

.crm-ai-chat__typing {
  display: flex;
  gap: 0.3rem;
  padding: 0 1rem 0.4rem;
}

.crm-ai-chat__typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #6b8f7a;
  animation: crm-ai-bounce 1s infinite ease-in-out;
}

.crm-ai-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.crm-ai-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes crm-ai-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.crm-ai-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.35rem;
  background: #fff;
  border-top: 1px solid #dde7e1;
}

.crm-ai-chat__composer textarea {
  flex: 1;
  resize: none;
  max-height: 6.5rem;
  min-height: 2.4rem;
  border: 1px solid #c9d7cf;
  border-radius: 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.35;
  outline: none;
  background: #fbfefc;
}

.crm-ai-chat__composer textarea:focus {
  border-color: #2f6b52;
  box-shadow: 0 0 0 3px rgba(47, 107, 82, 0.15);
}

.crm-ai-chat__send {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 0.7rem;
  background: #14532d;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.crm-ai-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.crm-ai-chat__hint {
  margin: 0;
  padding: 0 0.85rem 0.65rem;
  font-size: 0.68rem;
  color: #6b7c72;
  background: #fff;
  text-align: center;
}

@media (max-width: 576px) {
  .crm-ai-chat {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .crm-ai-chat__panel {
    width: calc(100vw - 1.5rem);
    height: min(70vh, 32rem);
  }
}
