/* Styles for chat interface with space theme */
.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: 'Poppins', sans-serif;
}

#chat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(106, 13, 173, 0.4),
              0 0 0 0 rgba(147, 112, 219, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: glowing 2s infinite;
}

@keyframes glowing {
  0% {
    box-shadow: 0 4px 12px rgba(106, 13, 173, 0.4),
                0 0 0 0 rgba(147, 112, 219, 0.7);
  }
  70% {
    box-shadow: 0 4px 12px rgba(106, 13, 173, 0.6),
                0 0 0 15px rgba(147, 112, 219, 0);
  }
  100% {
    box-shadow: 0 4px 12px rgba(106, 13, 173, 0.4),
                0 0 0 0 rgba(147, 112, 219, 0);
  }
}

#chat-icon i {
  color: white;
  font-size: 24px;
}

#chat-icon:hover {
  transform: scale(1.05);
  background-color: var(--primary-color-light);
  animation: none;
  box-shadow: 0 0 20px rgba(147, 112, 219, 0.8),
              0 0 30px rgba(147, 112, 219, 0.4);
}

#chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 350px;
  height: 500px;
  background-color: rgba(10, 3, 20, 0.85);
  border: 1px solid var(--primary-color-light);
  border-radius: 12px;
  box-shadow: 0 5px 25px rgba(106, 13, 173, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  /* backdrop-filter: blur(10px); */
  z-index: 1000;
}

.chat-header {
  background-color: var(--primary-color);
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab; /* Indicate draggable */
 /* user-select: none; /* Prevent text selection when dragging */
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
}

#chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

#chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background-color: rgba(15, 5, 30, 0.5);
}

.message {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.bot-message {
  align-items: flex-start;
}

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

.message-content {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
  background-color: rgba(75, 0, 130, 0.4);
  border: 1px solid var(--primary-color-dark);
  color: white;
  border-bottom-left-radius: 5px;
}

.user-message .message-content {
  background-color: var(--primary-color);
  color: white;
  border-bottom-right-radius: 5px;
}

.message-content p {
  margin: 0;
  line-height: 1.4;
  font-size: 14px;
  position: static;
  left: auto;
  top: auto;
}

.chat-input {
  display: flex;
  padding: 10px;
  background-color: rgba(15, 5, 30, 0.7);
  border-top: 1px solid var(--primary-color-dark);
  align-items: flex-end; /* Align items to bottom for multi-line support */
}

#message-input {
  flex: 1;
  border: 1px solid var(--primary-color-dark);
  border-radius: 20px;
  padding: 12px 15px;
  font-size: 14px;
  outline: none;
  color: white;
  background-color: rgba(30, 10, 50, 0.5);
  min-height: 20px;
  max-height: 100px;
  overflow-y: auto; /* Allow scrolling for very long messages */
  resize: none; /* Prevent manual resizing */
  line-height: 1.4;
  word-wrap: break-word; /* Ensure words wrap properly */
}

#message-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

#send-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  margin-left: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s;
  flex-shrink: 0; /* Prevent button from shrinking */
}

#send-button:hover {
  background-color: var(--primary-color-light);
  box-shadow: 0 0 10px rgba(147, 112, 219, 0.5);
}

.hidden {
  display: none !important;
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 3px;
}

.typing span {
  width: 8px;
  height: 8px;
  background-color: var(--primary-color-light);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite ease-in-out;
}

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

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

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

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: rgba(30, 10, 50, 0.2);
}

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

/* Server restart notice styling */
.server-notice .message-content {
  background-color: rgba(255, 166, 0, 0.2);
  border: 1px dashed orange;
  color: #ffcc80;
  font-size: 13px;
  padding: 8px 12px;
}

.server-notice .message-content p {
  color: #ffcc80;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  #chat-window {
    width: 90%; /* Slightly narrower */
    height: 60vh; /* Smaller height */
    bottom: 75px;
    right: 5%;
    border-radius: 12px;
    max-width: none;
  }
  
  #chat-icon {
    width: 55px;
    height: 55px;
    bottom: 15px;
    right: 15px;
  }
  
  #chat-icon i {
    font-size: 28px; /* Larger icon */
  }
  
  .chat-header {
    padding: 14px;
  }
  
  .chat-header h3 {
    font-size: 18px; /* Larger header text */
  }
  
  #chat-close {
    font-size: 22px; /* Larger close button */
    min-height: 30px;
    min-width: 30px;
  }
  
  .message-content {
    max-width: 90%;
    padding: 12px 16px; /* More padding */
  }
  
  .message-content p {
    font-size: 16px; /* Larger message text */
    line-height: 1.5;
  }
  
  .message {
    margin-bottom: 18px; /* More space between messages */
  }
  
  #message-input {
    width: calc(100% - 55px); /* Leave room for the send button */
    padding: 12px 15px;
    font-size: 18px;
  }
  
  #send-button {
    min-width: 45px;
    min-height: 45px;
    width: 45px;
    height: 45px;
    margin-left: 10px;
    position: relative; /* Ensure button is properly positioned */
    z-index: 5; /* Ensure button stays on top */
  }
  
  #send-button i {
    font-size: 18px; /* Larger send icon */
  }
  
  /* Full screen chat for very small devices */
  @media (max-width: 360px) {
    #chat-window {
      width: 100%;
      height: 85vh; /* Not 100vh to avoid keyboard issues */
      bottom: 0;
      right: 0;
      border-radius: 0;
    }
    
    .chat-header {
      border-radius: 0;
      padding: 16px; /* More padding */
    }
    
    .chat-header h3 {
      font-size: 20px; /* Even larger header text */
    }
    
    .message-content p {
      font-size: 18px; /* Even larger message text */
    }
  }
  
  /* Make sure the window is properly resizable on touch devices */
  .resize-handle {
    width: 24px;
    height: 24px; /* Larger handle for touch */
  }
  
  /* Adjust typing indicator */
  .typing span {
    width: 10px;
    height: 10px; /* Larger typing dots */
  }
}

/* Improve touch target sizes for better mobile interaction */
#chat-close {
  min-height: 28px;
  min-width: 28px;
}

/* Prevent zooming issues on input focus for mobile */
@media (max-width: 768px) {
  #message-input {
    font-size: 18px; /* Prevents iOS from zooming in on inputs */
  }
  
  .chat-input {
    padding: 12px; /* More padding in the input area */
  }
  
  /* Ensure code blocks are readable */
  .message-content pre {
    font-size: 15px;
    max-width: 100%;
    overflow-x: auto;
  }
  
  .message-content code {
    font-size: 15px;
  }
}
