.chat-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 520px;
  background: #1e1e2e;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header {
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.chat-header button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.chat-header button:hover {
  color: white;
}

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

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  animation: fadeInUp 0.25s ease;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.bot {
  align-self: flex-start;
  background: #2a2a3e;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg .msg-source {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 6px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.chat-msg.bot .msg-source {
  background: rgba(99,102,241,0.2);
  color: #a5b4fc;
}

.chat-msg.user .msg-source {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 8px;
  background: #181825;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  background: #2a2a3e;
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input::placeholder {
  color: #6b7280;
}

.chat-input-area input:focus {
  border-color: #7c3aed;
}

.chat-input-area button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.chat-input-area button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

.chat-input-area button:active {
  transform: scale(0.95);
}

.chat-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #2a2a3e;
  border-radius: 14px;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #6366f1;
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

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

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

@media (max-width: 480px) {
  .chat-widget-container {
    right: auto;
    left: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    max-width: 100vw;
  }

  .chat-window {
    position: fixed;
    width: calc(100vw - 20px);
    max-width: 100vw;
    height: calc(100vh - 140px);
    bottom: 80px;
    left: 10px;
    right: 10px;
    margin: 0;
  }

  .chat-widget-container > button {
    position: relative;
    margin-left: auto;
    display: block;
  }
}
