.aichat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--neon-purple);
}

.aichat-header h2 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.aichat-header h5 strong {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.aichat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  max-height: 70vh;
  background: rgba(10, 10, 18, 0.8);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--glow);
}

.aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  max-width: 65%;
  width: fit-content;
  padding: 15px 20px;
  border-radius: 18px;
  line-height: 1.5;
  position: relative;
  animation: fadeIn 0.3s ease-out;
  flex-direction: column;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.user-message {
  background: rgba(102, 126, 234, 0.2);
  border: 1px solid var(--neon-purple);
  margin-left: auto;
  border-bottom-right-radius: 5px;
  color: var(--text-color);
  align-items: flex-end;
}


.ai-message {
  background: rgba(138, 43, 226, 0.2);
  border: 1px solid var(--neon-pink);
  margin-right: auto;
  border-bottom-left-radius: 5px;
  color: var(--text-color);
  align-items: flex-start;
}

.message-content {
  flex: 1;
  width: 100%;
  max-width: 100%;
  padding-bottom: 5px;
}

.message-time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 5px;
  align-self: flex-end;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
  max-width: 100%;
  margin: 8px 0;
}

.message-content code {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
}

.message-content p {
  margin-bottom: 10px;
  max-width: 100%;
  word-break: break-word;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
  background: var(--neon-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.user-message .message-avatar {
  background: var(--neon-pink);
}

.aichat-input-container {
  padding: 15px;
  background: rgba(10, 10, 18, 0.9);
  border-top: 1px solid var(--neon-purple);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.aichat-input-wrapper {
  width: 100%;
  max-width: 800px;
  position: relative;
}

#aichat-input {
  width: 100%;
  min-height: 60px;
  max-height: 200px;
  padding: 15px 50px 15px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--neon-purple);
  border-radius: 30px;
  color: var(--text-color);
  font-size: 1rem;
  resize: none;
  box-shadow: var(--glow);
  transition: all 0.3s ease;
}

#aichat-input:focus {
  outline: none;
  border-color: var(--neon-blue);
  box-shadow: 0 0 15px var(--neon-blue);
}

#aichat-send {
  position: absolute;
  right: 15px;
  bottom: 15px;
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
  color: var(--text-color);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

html[dir="rtl"] #aichat-send {
  left: 15px;
  right: auto;

}

#aichat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(138, 43, 226, 0.8);
}

#aichat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome message when chat is empty */
.aichat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.7);
}

.aichat-welcome h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: var(--neon-blue);
}

.aichat-welcome p {
  max-width: 600px;
  margin-bottom: 30px;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  padding: 10px 15px;
  background: rgba(138, 43, 226, 0.2);
  border-radius: 18px;
  margin-right: auto;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--neon-pink);
  border-radius: 50%;
  margin-right: 5px;
  animation: typingAnimation 1.4s infinite both;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .aichat-container {
    height: calc(100vh - 150px);
  }
  
  .message {
    max-width: 85%;
    padding: 12px 16px;
  }
  
  #aichat-input {
    min-height: 50px;
    padding: 12px 45px 12px 15px;
  }
  
  #aichat-send {
    width: 35px;
    height: 35px;
    right: 10px;
    bottom: 10px;
  }

  .aichat-header h2 {
    font-size: 1.5rem
  }

  .aichat-header h5 {
    font-size: 0.6rem
  }

  .aichat-header h5 strong {
    font-size: 1.1rem
  }
}

@media (max-width: 768px) {
  .message {
    max-width: 85%;
    padding: 12px 16px;
  }
  
  .message-content pre {
    padding: 8px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .message {
    max-width: 80%;
    padding: 10px 14px;
  }
  
  .message-time {
    font-size: 0.6rem;
  }
}