.draxter-aichat-root {
  --drax-brand-500: #6366f1;
  --drax-brand-600: #4f46e5;
  --drax-brand-700: #4338ca;
  position: fixed !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 2147483000 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  overflow: visible !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  pointer-events: none;
}

.draxter-aichat-root .draxter-aichat-fab,
.draxter-aichat-root .draxter-aichat-panel {
  pointer-events: auto;
}

/* Сброс стилей шаблона Битрикс для кнопки FAB */
button.draxter-aichat-fab,
.draxter-aichat-root button.draxter-aichat-fab {
  position: fixed !important;
  bottom: 110px !important;
  right: 1rem !important;
  z-index: 2147483001 !important;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  min-width: 3.5rem !important;
  max-width: calc(100vw - 2rem);
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #3730a3 !important;
  border-radius: 9999px !important;
  background: #4f46e5 !important;
  background-color: #4f46e5 !important;
  background-image: none !important;
  color: #ffffff !important;
  padding: 0.375rem 1rem 0.375rem 0.375rem !important;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(79, 70, 229, 0.5), 0 2px 8px rgba(15, 23, 42, 0.15);
  animation: drax-fab-pulse 2.4s ease-out infinite;
  transition: width 0.2s ease, height 0.2s ease, padding 0.2s ease, background 0.2s ease;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.2;
  text-decoration: none !important;
  box-sizing: border-box;
}

button.draxter-aichat-fab:hover,
.draxter-aichat-root button.draxter-aichat-fab:hover {
  background: #4338ca !important;
  background-color: #4338ca !important;
  color: #ffffff !important;
}

.draxter-aichat-fab-avatar {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
}

button.draxter-aichat-fab .draxter-aichat-fab-label,
button.draxter-aichat-fab .draxter-aichat-fab-label strong,
button.draxter-aichat-fab .draxter-aichat-fab-sublabel {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  opacity: 1 !important;
  text-shadow: 0 1px 2px rgba(30, 27, 75, 0.35);
}

.draxter-aichat-fab-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.2;
  color: #ffffff !important;
  white-space: nowrap;
}

.draxter-aichat-fab-label strong {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff !important;
}

.draxter-aichat-fab-sublabel {
  font-size: 0.6875rem;
  font-weight: 400;
  color: #f8fafc !important;
}

button.draxter-aichat-fab.draxter-aichat-fab--open,
.draxter-aichat-fab--open {
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  max-width: 3.5rem;
  padding: 0;
  justify-content: center;
  align-items: center;
  gap: 0;
  background: #1e293b !important;
  background-color: #1e293b !important;
  border-color: #0f172a !important;
  color: #ffffff !important;
  animation: none;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35);
}

button.draxter-aichat-fab.draxter-aichat-fab--open:hover {
  background: #334155 !important;
  background-color: #334155 !important;
}

.draxter-aichat-fab--open .draxter-aichat-fab-label,
.draxter-aichat-fab--open .draxter-aichat-fab-avatar {
  display: none !important;
}

.draxter-aichat-fab-icon {
  display: block;
  flex-shrink: 0;
}

.draxter-aichat-panel {
  position: fixed !important;
  bottom: 170px !important;
  right: 1rem !important;
  z-index: 2147483001 !important;
  display: flex;
  flex-direction: column;
  width: min(100vw - 2rem, 400px);
  height: min(70vh, 560px);
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(79, 70, 229, 0.25);
  transform-origin: bottom right;
  animation: drax-chat-open 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.draxter-aichat-root--embedded .draxter-aichat-panel {
  position: relative;
  bottom: auto;
  right: auto;
  width: 100%;
  height: 100%;
  min-height: 420px;
  animation: none;
}

.draxter-aichat-panel--closing {
  animation: drax-chat-close 0.28s ease forwards;
  pointer-events: none;
}

.draxter-aichat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.draxter-aichat-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draxter-aichat-close {
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 0.5rem;
  padding: 0.375rem;
  cursor: pointer;
}

.draxter-aichat-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.draxter-aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  background: #f8fafc;
  scrollbar-width: thin;
}

.draxter-aichat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.draxter-aichat-msg--user {
  justify-content: flex-end;
}

.draxter-aichat-bubble {
  max-width: 88%;
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  line-height: 1.5;
  font-size: 0.875rem;
}

.draxter-aichat-bubble--bot {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-bottom-left-radius: 0.25rem;
}

.draxter-aichat-bubble--user {
  background: var(--drax-brand-600);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.draxter-aichat-bubble a {
  color: var(--drax-brand-600);
  font-weight: 500;
}

.draxter-aichat-bubble--user a {
  color: #fff;
}

.draxter-aichat-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.draxter-aichat-input {
  flex: 1;
  height: 2.25rem;
  min-height: 2.25rem;
  max-height: 5rem;
  resize: none;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.4375rem 0.75rem;
  line-height: 1.35;
  font: inherit;
  background: #f8fafc;
  overflow-y: auto;
}

.draxter-aichat-input:focus {
  outline: none;
  border-color: var(--drax-brand-500);
  background: #fff;
}

.draxter-aichat-send {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: var(--drax-brand-600);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.draxter-aichat-send:hover:not(:disabled) {
  background: var(--drax-brand-700);
}

.draxter-aichat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.draxter-aichat-error {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.75rem;
}

.draxter-aichat-avatar {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: linear-gradient(135deg, #1e293b, #020617);
  display: flex;
  align-items: center;
  justify-content: center;
}

.draxter-aichat-bubble--bot.draxter-aichat-typing {
  min-width: 3.5rem;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.draxter-aichat-typing span {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 2px;
  border-radius: 9999px;
  background: #94a3b8;
  animation: drax-typing 1s infinite;
}

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

@keyframes drax-chat-open {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes drax-chat-close {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.92) translateY(12px); }
}

@keyframes drax-fab-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
  70% { box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); }
}

@keyframes drax-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}
