/* Chat Popup Styles */
.chat-popup {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 380px;
  height: 520px;
  background: #131620;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.3, 0, 0.2, 1);
}

.chat-popup.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-popup.minimized {
  height: 60px;
  border-radius: 16px;
  overflow: hidden;
  transform: translateZ(0);
}

.chat-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #131620;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.model-indicator {
  font-size: 16px;
  font-weight: 500;
  color: #00DCD4;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00DCD4;
  box-shadow: 0 0 8px rgba(0, 220, 212, 0.5);
}

.chat-popup.minimized .chat-messages,
.chat-popup.minimized .chat-input-container {
  display: none;
  opacity: 0;
}

.chat-messages, 
.chat-input-container {
  opacity: 1;
  transition: opacity 0.3s ease 0.1s;
}

.chat-popup.minimized .chat-popup-header {
  border-bottom: none;
  padding-top: 10px;
  padding-bottom: 10px;
}

.chat-popup-controls {
  display: flex;
  gap: 8px;
}

.control-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-app-region: no-drag;
}

.control-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  background: #131620;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.message {
  display: flex;
  max-width: 85%;
  animation: fadeIn 0.3s ease forwards;
}

.message.user {
  align-self: flex-end;
}

.message.ai, .message.system {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.message.user .message-content {
  background: linear-gradient(135deg, #00DCD4, #9d4bff);
  color: #fff;
  border-radius: 16px 16px 0 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message.ai .message-content {
  background: rgba(30, 38, 55, 0.8);
  color: #E5E7EB;
  border-radius: 16px 16px 16px 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.message.system .message-content {
  background: rgba(30, 38, 55, 0.5);
  color: #E5E7EB;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.message p {
  margin: 0;
}

.message a {
  color: #00DCD4;
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

.message code {
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

/* Enhanced typing indicator */
.typing-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 0 6px 0;
}

.typing-dot {
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #00DCD4 40%, #9d4bff 100%);
  border-radius: 50%;
  opacity: 0.7;
  animation: typingBounce 1.2s infinite;
  margin: 0 2px;
}

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

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

@keyframes typingBounce {
  0%, 100% {
    transform: translateY(0) scale(0.8);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px) scale(1.1);
    opacity: 1;
  }
  60% {
    transform: translateY(0) scale(0.8);
    opacity: 0.7;
  }
}

/* Remove old dot and typing-dots rules if present */
.typing-dots, .dot { display: none !important; }

.chat-input-container {
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: #131620;
}

.chat-input {
  flex: 1;
  background: rgba(30, 38, 55, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  transition: all 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(0, 220, 212, 0.3);
  box-shadow: 0 0 0 2px rgba(0, 220, 212, 0.1);
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.send-btn {
  background: linear-gradient(135deg, #00DCD4, #9d4bff);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

@keyframes pulse {
  0%, 100% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .chat-popup {
    width: 90%;
    right: 5%;
    bottom: 20px;
  }
}
