
.chat-message-window {
  position: fixed;
  right: 5%;
  bottom: 10vh;
  width: 25vw;
  height: 80vh;
  background: #2d3748; /* Dark mode default */
  color: #e2e8f0; /* Light text for dark mode */
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  z-index: 9999;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transform-origin: bottom center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RWD: mobile */
@media (max-width: 600px) {
  .chat-message-window {
    top: 5vh;
    left: 10%;
    right: auto;
    width: 80%;
    height: 90%;
    bottom: auto;
    border-radius: 12px;
    font-size: 1em;
    max-width: 100vw;
    max-height: 100vh;
    transform-origin: top center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .chat-message-window.minimized {
    width: 48px;
    height: 40px;
    left: auto;
    right: 2vw;
    top: auto;
    bottom: 2vh;
    border-radius: 12px;
    opacity: 0.8;
    transform-origin: bottom center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .chat-content {
    transition: all 0.3s ease;
  }
  .chat-messages {
    width: 98%;
    height: 60%;
    font-size: 0.95em;
    padding: 4px;
    transition: all 0.3s ease;
  }
  .chat-input-container {
    width: 98%;
    min-width: 0;
    gap: 4px;
    transition: all 0.3s ease;
  }
  .chat-input {
    font-size: 1em;
    padding: 6px 6px;
    min-width: 0;
    transition: all 0.3s ease;
  }
  .chat-send-btn {
    min-width: 44px;
    font-size: 1em;
    padding: 6px 0;
    transition: all 0.3s ease;
  }
  .chat-minimize-btn, .chat-theme-toggle {
    width: 22px;
    height: 22px;
    font-size: 15px;
    top: 6px;
    right: 10px;
    transition: all 0.3s ease;
  }
}

/* Light mode theme */
.chat-message-window.light-mode {
  background: #fff;
  color: #2d3748;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.chat-message-window.minimized {
  right: 1%;
  bottom: 8vh;
  top: auto;
  width: 40px;
  height: 40px;
  justify-content: center;
  align-items: center;
  transform-origin: bottom center;
  opacity: 0.8;
}

.chat-minimize-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: #4a5568; /* Dark mode default */
  border: 1px solid #718096;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  font-weight: bold;
  color: #e2e8f0; /* Light text for dark mode */
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10001;
}

.chat-minimize-btn:hover {
  background: #2d3748;
  border-color: #4a5568;
}

/* Light mode minimize button */
.chat-message-window.light-mode .chat-minimize-btn {
  background: #f0f0f0;
  border: 1px solid #ccc;
  color: #666;
}

.chat-message-window.light-mode .chat-minimize-btn:hover {
  background: #e0e0e0;
  border-color: #999;
}

.chat-messages {
  width: 90%;
  height: 80%;
  overflow-y: auto;
  margin-bottom: 10px;
  background: #1a202c; /* Dark mode default */
  border-radius: 6px;
  padding: 8px;
  box-sizing: border-box;
}

/* Light mode messages container */
.chat-message-window.light-mode .chat-messages {
  background: #f7f7f7;
}

.chat-input-container {
  width: 90%;
  display: flex;
  gap: 8px;
  margin-top: 0;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #4a5568; /* Dark mode default */
  background: #2d3748;
  color: #e2e8f0;
  font-size: 1em;
}

.chat-input::placeholder {
  color: #a0aec0;
}

/* Light mode input */
.chat-message-window.light-mode .chat-input {
  border: 1px solid #ccc;
  background: #fff;
  color: #2d3748;
}

.chat-message-window.light-mode .chat-input::placeholder {
  color: #a0adb8;
}

.chat-send-btn {
  min-width: 60px;
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  background: #3182ce; /* Adjusted blue for dark mode */
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover {
  background: #2c5282;
}

/* Light mode send button */
.chat-message-window.light-mode .chat-send-btn {
  background: #1976d2;
}

.chat-message-window.light-mode .chat-send-btn:hover {
  background: #1565c0;
}

.chat-message-item {
  margin: 5px 0;
  padding: 4px 8px;
  background: #4299e1; /* Dark mode user message */
  color: #fff;
  border-radius: 4px;
  word-break: break-all;
  text-align: right;
  align-self: flex-end;
}

/* Light mode user message */
.chat-message-window.light-mode .chat-message-item {
  background: #e3f2fd;
  color: #1976d2;
}

.chat-message-reply {
  background: #2d3748; /* Dark mode reply */
  color: #e2e8f0;
  border-left: 4px solid #ed8936;
  margin: 8px 0 8px 16px;
  padding: 4px 12px;
  border-radius: 4px;
  font-style: italic;
  text-align: left;
  align-self: flex-start;
}

/* Light mode reply message */
.chat-message-window.light-mode .chat-message-reply {
  background: #fffde7;
  color: #333;
  border-left: 4px solid #ffd600;
}

.chat-message-loading {
  background: #2d3748; /* Dark mode loading */
  color: #a0aec0;
  border-left: 4px solid #ed8936;
  margin: 8px 0 8px 16px;
  padding: 4px 12px;
  border-radius: 4px;
  font-style: italic;
  text-align: left;
  align-self: flex-start;
  min-width: 60px;
  font-family: monospace;
}

/* Light mode loading message */
.chat-message-window.light-mode .chat-message-loading {
  background: #fffde7;
  color: #999;
  border-left: 4px solid #ffd600;
}

.chat-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}

.chat-message-window.minimized .chat-content {
  display: none;
}

.chat-message-window.minimized .chat-minimize-btn {
  position: static;
  margin: 0;
}

/* Theme toggle button */
.chat-theme-toggle {
  position: absolute;
  top: 8px;
  right: 42px;
  width: 24px;
  height: 24px;
  background: #4a5568;
  border: 1px solid #718096;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: #e2e8f0;
  transition: all 0.2s ease;
  z-index: 10001;
}

.chat-theme-toggle:hover {
  background: #2d3748;
  border-color: #4a5568;
}

.chat-theme-toggle::before {
  content: "🌙";
}

/* Light mode theme toggle */
.chat-message-window.light-mode .chat-theme-toggle {
  background: #f0f0f0;
  border: 1px solid #ccc;
  color: #666;
}

.chat-message-window.light-mode .chat-theme-toggle:hover {
  background: #e0e0e0;
  border-color: #999;
}

.chat-message-window.light-mode .chat-theme-toggle::before {
  content: "☀️";
}

/* Hide theme toggle when minimized */
.chat-message-window.minimized .chat-theme-toggle {
  display: none;
}

/* Scrollbar styling for dark mode */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #1a202c;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

/* Light mode scrollbar */
.chat-message-window.light-mode .chat-messages::-webkit-scrollbar-track {
  background: #f7f7f7;
}

.chat-message-window.light-mode .chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
}

.chat-message-window.light-mode .chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}
