/* Chat Widget Styles - Following enermaind design system */

/* Chat widget container - fixed position bottom right */
.chat-widget {
  position: fixed;
  bottom: var(--spacing-600, 24px);
  right: var(--spacing-600, 24px);
  z-index: 1001; /* Above navigation which is 1000 */
  font-family: Arial, sans-serif;
  transition: transform var(--duration-normal, 300ms) ease-in-out, opacity var(--duration-normal, 300ms) ease-in-out;
}

/* Chat toggle button - FAB style */
.chat-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-brand-primary, #3d9143);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform var(--duration-fast, 150ms) ease-in-out, background-color var(--duration-fast, 150ms) ease-in-out;
  position: relative;
  padding: 0;
}

.chat-toggle-btn:hover {
  background: #2d7632;
  transform: scale(1.1);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

/* Notification badge for rate limit */
.chat-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-brand-secondary, #feb04d);
  color: var(--color-neutral-900, #1a1a1a);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Chat window */
.chat-window {
  position: fixed;
  bottom: var(--spacing-600, 24px);
  right: var(--spacing-600, 24px);
  width: 400px;
  height: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.8);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--duration-normal, 300ms) ease-in-out, opacity var(--duration-normal, 300ms) ease-in-out;
}

.chat-window.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat header */
.chat-header {
  background: var(--color-brand-primary, #3d9143);
  color: white;
  padding: var(--spacing-500, 20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-title {
  font-size: 18px;
  font-weight: bold;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-300, 12px);
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color var(--duration-fast, 150ms) ease-in-out;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-500, 20px);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-400, 16px);
  background: var(--color-neutral-50, #fafafa);
}

/* Individual message */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-200, 8px);
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message-content {
  padding: var(--spacing-400, 16px);
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  line-height: 1.5;
}

/* User message */
.chat-message.user .chat-message-content {
  background: var(--color-brand-primary, #3d9143);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Assistant message */
.chat-message.assistant .chat-message-content {
  background: white;
  color: var(--color-neutral-900, #1a1a1a);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
}

/* System message (welcome, errors, rate limit) */
.chat-message.system .chat-message-content {
  background: var(--color-neutral-100, #f5f5f5);
  color: var(--color-neutral-700, #404040);
  align-self: center;
  text-align: center;
  font-size: 14px;
  border-radius: 8px;
}

.chat-message.system.error .chat-message-content {
  background: #fee;
  color: #c00;
  border: 1px solid #fcc;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: var(--spacing-400, 16px);
  background: white;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: 85%;
  box-shadow: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--color-neutral-400, #a3a3a3);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* Chat input area */
.chat-input-area {
  padding: var(--spacing-500, 20px);
  background: white;
  border-top: 1px solid var(--color-neutral-200, #e5e5e5);
  flex-shrink: 0;
}

.chat-input-form {
  display: flex;
  gap: var(--spacing-300, 12px);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: var(--spacing-300, 12px) var(--spacing-400, 16px);
  border: 2px solid var(--color-neutral-200, #e5e5e5);
  border-radius: 8px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  transition: border-color var(--duration-fast, 150ms) ease-in-out;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-brand-primary, #3d9143);
}

.chat-input::placeholder {
  color: var(--color-neutral-400, #a3a3a3);
}

.chat-send-btn {
  padding: var(--spacing-300, 12px) var(--spacing-400, 16px);
  background: var(--color-brand-primary, #3d9143);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color var(--duration-fast, 150ms) ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
}

.chat-send-btn:hover:not(:disabled) {
  background: #2d7632;
}

.chat-send-btn:disabled {
  background: var(--color-neutral-300, #d4d4d4);
  cursor: not-allowed;
}

/* Rate limit info */
.chat-rate-limit-info {
  font-size: 12px;
  color: var(--color-neutral-600, #525252);
  text-align: center;
  padding: var(--spacing-200, 8px);
  background: var(--color-neutral-50, #fafafa);
  border-top: 1px solid var(--color-neutral-200, #e5e5e5);
}

.chat-rate-limit-warning {
  color: var(--color-brand-secondary, #feb04d);
  font-weight: bold;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .chat-window {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chat-toggle-btn {
    bottom: var(--spacing-500, 20px);
    right: var(--spacing-500, 20px);
  }

  .chat-widget {
    bottom: var(--spacing-500, 20px);
    right: var(--spacing-500, 20px);
  }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--color-neutral-100, #f5f5f5);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300, #d4d4d4);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400, #a3a3a3);
}
