/* Chat Widget */
#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
#chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(59, 130, 246, 0.5);
}

#chat-toggle.chat-hidden {
  display: none;
}

/* Panel */
#chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 380px;
  height: 520px;
  background: #111827;
  border: 1px solid #1e293b;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  animation: chat-slide-up 0.25s ease-out;
}

#chat-panel.chat-hidden {
  display: none;
}

@keyframes chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0a0e1a;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

#chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

#chat-header-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
}

#chat-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

#chat-close:hover {
  color: #f1f5f9;
}

/* Messages */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  max-width: 85%;
}

.chat-msg-user {
  align-self: flex-end;
}

.chat-msg-assistant {
  align-self: flex-start;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg-user .chat-msg-bubble {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-msg-bubble {
  background: #1a2035;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}

.chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
  animation: chat-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes chat-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* Input area */
#chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #1e293b;
  background: #0a0e1a;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: #1a2035;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px 14px;
  color: #f1f5f9;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input::placeholder {
  color: #64748b;
}

#chat-input:focus {
  border-color: #3b82f6;
}

#chat-send {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

#chat-send:hover {
  opacity: 0.9;
}

/* Mobile */
@media (max-width: 768px) {
  #chat-widget {
    bottom: 16px;
    right: 16px;
  }

  #chat-toggle {
    width: 48px;
    height: 48px;
  }

  #chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: 500px;
    border-radius: 12px;
  }
}
