.n8n-ai-webchat-root {
  --n8n-primary: #1f7aed;
  --n8n-chat-bg: #ffffff;
  --n8n-text: #1f2937;
  --n8n-user-bubble: #1f7aed;
  --n8n-assistant-bubble: #f1f5f9;
  --n8n-teaser-bg: #111827;
  --n8n-teaser-text: #ffffff;
  --n8n-send-btn-font-size: 14px;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.n8n-ai-hidden {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.n8n-ai-webchat-root.n8n-ai-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.n8n-ai-webchat-toggle {
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 999px;
  background: var(--n8n-primary);
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.n8n-ai-webchat-toggle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
}

.n8n-ai-webchat-toggle svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}

.n8n-ai-webchat-teaser {
  position: absolute;
  right: 74px;
  bottom: 10px;
  max-width: min(520px, calc(100vw - 96px));
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  background: var(--n8n-teaser-bg);
  color: var(--n8n-teaser-text);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.n8n-ai-webchat-teaser::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 18px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid var(--n8n-teaser-bg);
}

.n8n-ai-webchat-teaser.n8n-ai-show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.n8n-ai-webchat-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--n8n-chat-bg);
  border-radius: 18px;
  overflow: hidden;
  display: none;
  box-shadow: 0 22px 50px rgba(2, 6, 23, 0.28);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.n8n-ai-webchat-panel.n8n-ai-open {
  display: flex;
  flex-direction: column;
}

.n8n-ai-webchat-header {
  background: var(--n8n-primary);
  color: #fff;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.n8n-ai-webchat-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.n8n-ai-webchat-header-meta strong {
  font-size: 14px;
}

.n8n-ai-webchat-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.n8n-ai-webchat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.95);
}

.n8n-ai-webchat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.n8n-ai-webchat-status.is-typing .n8n-ai-webchat-status-dot {
  background: #fde047;
  box-shadow: 0 0 0 2px rgba(253, 224, 71, 0.2);
  animation: n8n-ai-status-pulse 1.2s infinite;
}

.n8n-ai-webchat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.n8n-ai-webchat-close {
  border: 0 !important;
  background: transparent;
  color: #ffffff !important;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  box-shadow: none !important;
  outline: none;
  appearance: none;
}

.n8n-ai-webchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  color: var(--n8n-text);
  background: var(--n8n-chat-bg);
}

.n8n-ai-msg {
  margin: 0 0 12px;
  display: flex;
}

.n8n-ai-msg span {
  max-width: 86%;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: pre-wrap;
}

.n8n-ai-msg-user {
  justify-content: flex-end;
}

.n8n-ai-msg-user span {
  color: #fff;
  background: var(--n8n-user-bubble);
  border-bottom-right-radius: 4px;
}

.n8n-ai-msg-assistant span {
  color: var(--n8n-text);
  background: var(--n8n-assistant-bubble);
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
}

.n8n-ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.n8n-ai-typing-indicator i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.6);
  animation: n8n-ai-typing-bounce 1s infinite ease-in-out;
}

.n8n-ai-typing-indicator i:nth-child(2) {
  animation-delay: 0.18s;
}

.n8n-ai-typing-indicator i:nth-child(3) {
  animation-delay: 0.36s;
}

.n8n-ai-webchat-form {
  border-top: 1px solid rgba(15, 23, 42, 0.1);
  padding: 10px;
  display: flex;
  gap: 8px;
  background: var(--n8n-chat-bg);
}

.n8n-ai-webchat-form input {
  flex: 1;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  outline: none;
  color: var(--n8n-text);
}

.n8n-ai-webchat-form input:focus {
  border-color: var(--n8n-primary);
}

#n8n-ai-webchat-root .n8n-ai-webchat-form button,
#n8n-ai-webchat-root .n8n-ai-webchat-form button:hover,
#n8n-ai-webchat-root .n8n-ai-webchat-form button:focus {
  border: none;
  background: var(--n8n-primary);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: var(--n8n-send-btn-font-size, 14px) !important;
  line-height: 1.2 !important;
}

@media (max-width: 680px) {
  .n8n-ai-webchat-root {
    right: 12px;
    bottom: 12px;
  }

  .n8n-ai-webchat-panel {
    width: calc(100vw - 24px);
    height: min(72vh, 560px);
  }

  .n8n-ai-webchat-teaser {
    max-width: calc(100vw - 86px);
    right: 70px;
  }
}

@keyframes n8n-ai-typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.38;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes n8n-ai-status-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}
