/**
 * @file
 * n8n Chat styles.
 */

.n8n-chat {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Widget positioning */
.n8n-chat.bottom-right {
  bottom: 20px;
  right: 20px;
}

.n8n-chat.bottom-left {
  bottom: 20px;
  left: 20px;
}

.n8n-chat.top-right {
  top: 20px;
  right: 20px;
}

.n8n-chat.top-left {
  top: 20px;
  left: 20px;
}

/* Chat toggle button */
.chat-toggle {
  background: #007cba;
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
}

.chat-toggle:hover {
  background: #005a87;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chat-icon {
  font-size: 18px;
}

.chat-text {
  font-size: 14px;
  font-weight: 500;
}

/* Chat window */
.chat-window {
  position: absolute;
  bottom: 70px;
  width: 380px;
  height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Position chat window based on widget position */
.n8n-chat.bottom-right .chat-window,
.n8n-chat.top-right .chat-window {
  right: 0;
}

.n8n-chat.bottom-left .chat-window,
.n8n-chat.top-left .chat-window {
  left: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .chat-window {
    width: 300px;
    height: 400px;
  }
}

@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 40px);
    height: calc(100vh - 120px);
    bottom: 70px;
    right: 20px;
    left: 20px;
  }

  .n8n-chat.bottom-left .chat-window,
  .n8n-chat.bottom-right .chat-window {
    right: 0;
    left: 0;
  }
}

/* Chat header */
.chat-header {
  background: #007cba;
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  font-weight: 600;
  font-size: 16px;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-close,
.chat-new-conversation {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.chat-close {
  font-size: 24px;
}

.chat-new-conversation {
  font-size: 16px;
}

.chat-close:hover,
.chat-new-conversation:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-new-conversation:active {
  transform: rotate(180deg);
  transition: transform 0.3s ease;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f8f9fa;
}

.chat-message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.chat-message.user {
  align-items: flex-end;
}

.chat-message.bot {
  align-items: flex-start;
}

.message-content {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.user .message-content {
  background: #007cba;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.bot .message-content {
  background: white;
  color: #333;
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 4px;
}

.chat-message.system {
  align-items: center;
}

.chat-message.system .message-content {
  background: #f0f8ff;
  color: #0066cc;
  border: 1px solid #b3d9ff;
  border-radius: 12px;
  font-size: 13px;
  font-style: italic;
  max-width: 90%;
}

.message-time {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
  padding: 0 4px;
}

.welcome-message {
  text-align: center;
  color: #666;
  font-style: italic;
  margin-bottom: 20px;
}

/* Typing indicator */
.typing-indicator .message-content {
  padding: 16px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

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

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat input */
.chat-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e1e5e9;
  display: flex;
  gap: 12px;
}

#chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e1e5e9;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
}

#chat-input:focus {
  border-color: #007cba;
  box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

#chat-send {
  background: #007cba;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

#chat-send:hover {
  background: #005a87;
}

#chat-send:active {
  transform: translateY(1px);
}

/* Dark theme */
.n8n-chat.dark .chat-window {
  background: #2d3748;
  color: white;
}

.n8n-chat.dark .chat-messages {
  background: #1a202c;
}

.n8n-chat.dark .chat-message.bot .message-content {
  background: #4a5568;
  color: white;
  border-color: #2d3748;
}

.n8n-chat.dark .chat-input-container {
  background: #2d3748;
  border-color: #4a5568;
}

.n8n-chat.dark #chat-input {
  background: #4a5568;
  color: white;
  border-color: #2d3748;
}

.n8n-chat.dark #chat-input::placeholder {
  color: #a0aec0;
}
