:root {
  --bg: #ffffff;
  --bg-secondary: #f7f7f7;
  --fg: #212121;
  --border-color: #e0e0e0;
  --accent: #1565c0;
  --accent-dark: #0d47a1;
  --accent-rgb: 21, 101, 192;
}
/* Dark theme variables */
.colorscheme-dark {
  --bg: #212121;
  --bg-secondary: #2a2a2a;
  --fg: #dadada;
  --border-color: #424242;
  --accent: #42a5f5;
  --accent-dark: #1e88e5;
  --accent-rgb: 66, 165, 245;
}

/* Chat container */
#chatWindow {
  width: 350px;
  height: 500px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px 20px 15px 20px;
  overflow-y: auto;
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 120px);
  right: 30px;
  background-color: var(--bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  font-family: "Lato", sans-serif;
  z-index: 1000;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  transition: all 0.3s ease;
  max-height: 80vh;
}

/* Scrollbar styling for WebKit browsers */
#chatWindow::-webkit-scrollbar {
  width: 6px;
}

#chatWindow::-webkit-scrollbar-track {
  background: transparent;
}

#chatWindow::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 3px;
}

/* Chat messages */
#chatWindow p {
  margin: 8px 0;
  line-height: 1.5;
  padding: 12px 16px;
  border-radius: 8px;
  background-color: var(--bg-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s ease;
}

#chatWindow p strong {
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

/* Input container */
.chat-input-container {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  right: 30px;
  width: 350px;
  padding: 10px;
  background-color: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  z-index: 9999;
}

#questionInput {
  width: calc(100% - 16px);
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg);
  color: var(--fg);
  font-size: 14px;
  transition: border-color 0.2s ease;
  outline: none;
}

#questionInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.1);
}

#questionInput::placeholder {
  color: var(--fg);
  opacity: 0.65;
}

#submitBtn {
  width: 100%;
  padding: 8px;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 14px;
  height: 40px;
}

#submitBtn:hover {
  background-color: var(--accent-dark);
  transform: translateY(-1px);
}

#submitBtn:active {
  transform: translateY(0);
}

/* Responsive design */
@media (max-width: 480px) {
  #chatWindow,
  .chat-input-container {
    width: calc(100% - 40px);
    right: 20px;
    left: 20px;
  }

  #chatWindow {
    bottom: 140px;
    height: 60vh;
  }
}

/* Dark mode adjustments */
.colorscheme-dark #chatWindow,
.colorscheme-dark .chat-input-container {
  background-color: var(--bg);
  border-color: var(--border-color);
}

.colorscheme-dark #questionInput {
  background-color: var(--bg);
  color: var(--fg);
  border-color: var(--border-color);
}

.colorscheme-dark #chatWindow p {
  background-color: rgba(255, 255, 255, 0.05);
}

.colorscheme-dark #questionInput:focus {
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

/* Message animations */
.message {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Loading animation */
.loading-dots span {
  animation: loadingDots 1.5s infinite;
  opacity: 0;
  display: inline-block;
  margin: 0 2px;
}

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

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

@keyframes loadingDots {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Message types */
.user-message {
  float: right;
  background: var(--accent);
  color: white;
  border-radius: 15px 15px 0 15px;
}

.user-message strong {
  color: white;
}

.assistant-message {
  float: left;
  background: var(--bg-secondary);
  color: var(--fg);
  border-radius: 15px 15px 15px 0;
}

/* Code formatting */
.message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.colorscheme-dark .message-content code {
  background: rgba(255, 255, 255, 0.1);
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-color);
  margin: -20px -20px 15px -20px;
  background: var(--bg);
  border-radius: 8px 8px 0 0;
}

.chat-header .robot-icon {
  width: 32px;
  height: 32px;
  margin-right: 12px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.chat-header .robot-icon svg {
  width: 20px;
  height: 20px;
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--fg);
}

/* Clear float */
#chatWindow::after {
  content: "";
  display: table;
  clear: both;
}

/* Small AI badge */
.chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.75em;
  line-height: 1.6;
  border-radius: 999px;
  background: var(--accent, #1565c0);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.05em;
}
