/* Chat window styles */
#chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: auto;
  height: auto;
  padding: 12px 20px;
  background-color: var(--links);
  color: var(--bg);
  border-radius: 24px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 1000;
}

#chat-button svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

#chat-button span {
  line-height: 1;
  white-space: nowrap;
}

#chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 600px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 999;
  border: 1px solid var(--sidebar-bg);
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background-color: var(--bg);
  border-bottom: 1px solid var(--sidebar-bg);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

#connection-status {
  font-size: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  cursor: help;
  transition: all 0.3s ease;
}

#connection-status.connected {
  color: #4caf50;
  filter: drop-shadow(0 0 2px rgba(76, 175, 80, 0.4));
}

#connection-status.disconnected {
  color: #f44336;
  filter: drop-shadow(0 0 2px rgba(244, 67, 54, 0.4));
}

#connection-status:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 0 4px currentColor);
}

.icon-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--fg, #666666);
  opacity: 0.7;
  transition: all 0.2s ease;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  opacity: 1;
  background-color: var(--sidebar-bg, #f1f1f1);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

#chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#chat-input {
  display: flex;
  padding: 16px;
  gap: 12px;
  background-color: var(--bg);
  border-top: 1px solid var(--sidebar-bg);
}

#message-input {
  flex-grow: 1;
  padding: 12px 16px;
  border: 1px solid var(--sidebar-bg);
  border-radius: 8px;
  background-color: var(--bg);
  color: var(--fg);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

#message-input:focus {
  outline: none;
  border-color: var(--links);
}

#send-message {
  background-color: var(--links);
  color: var(--bg);
  padding: 10px;
  border-radius: 8px;
  opacity: 1;
}

#send-message:hover {
  transform: scale(1.05);
}

.message {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 85%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  min-height: min-content;
  height: auto;
}

.message.user {
  background-color: var(--links);
  color: var(--bg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.ai {
  background-color: var(--sidebar-bg);
  color: var(--fg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.message .content {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 0;
}

.message .content pre {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}

.message .content code {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}

.message.loading {
  background-color: var(--sidebar-bg);
  color: var(--fg);
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.8;
}

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

.loading-dots span {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Scrollbar styles */
#chat-messages {
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-bg) transparent;
}

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

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

#chat-messages::-webkit-scrollbar-thumb {
  background-color: var(--sidebar-bg);
  border-radius: 3px;
}

/* Toast notifications */
#chat-toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
}

.chat-toast {
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
}

.chat-toast.error {
  background-color: #f44336;
}
.chat-toast.success {
  background-color: #4caf50;
}
.chat-toast.warning {
  background-color: #ff9800;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive design */
@media (max-width: 768px) {
  #chat-window {
    width: 90%;
    height: 90vh;
  }

  .message {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  #chat-window {
    width: 100%;
    height: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  #chat-button {
    bottom: 16px;
    right: 16px;
  }
}

.message-disclaimer {
  color: #999;
  align-self: center;
  font-size: 12px;
  font-style: italic;
  margin-top: auto;
  margin-bottom: 12px;
  text-align: center;
  max-width: 80%;
}
