body {
  margin: 0;
  padding: 0;
  background-color: #f5f8fb;
  color: #333333;
}

.welcomerow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  max-width: 1350px;
  margin: 20px;
  gap: 10px;
}

.chatwelcome {
  flex: 1;
  font-size: 30px;
  color: #007bff;
  margin: 0;
}

.newchat {
  background-color: #007bff;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
}

.newchat a {
  color: #ffffff;
  text-decoration: none;
  font-weight: bold;
}

.newchat:hover {
  background-color: #0056b3;
}

.Chatcontainer {
  display: flex;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 15px auto;
  gap: 20px;
}

/* Left: Title History */
.historytitle {
  flex: 1;
  min-width: 200px;
  padding: 15px;
  border: 2px solid #cccccc;
  border-radius: 10px;
  background-color: #f8f9fa;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  max-height: 700px;
  overflow-y: auto;
}

.historytitle h3 {
  color: #1e90ff;
  margin-bottom: 10px;
}

.historytitle ul {
  list-style: none;
  padding: 0;
}

.historytitle ul li {
  margin-top: 10px;
  margin-bottom: 10px;
}

.historytitle li a {
  text-decoration: none;
  color: #086db4;
  font-weight: bold;
}

.historytitle li a:hover {
  text-decoration: underline;
  color: #007bff;
}

/* Right: Chatbox */
.chatbox {
  flex: 2;
  padding: 15px;
  border: 1.5px solid #cccccc;
  border-radius: 10px;
  background-color: #ffffff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}

.chatcontent {
  max-height: 450px;
  overflow-y: auto;
  padding: 12px;
  background-color: #f8f8f8;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  border-radius: 8px;
}

.message {
  max-width: 80%;
  padding: 5px 7px;
  margin: 10px 0;
  border-radius: 12px;
  line-height: 1.5;

  /* 🔥 THIS fixes AI replies */
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
}

/* User message */
.message.user {
  background-color: #086db4;
  color: #ffffff;
  margin-left: auto;
  text-align: left;
}

/* AI message */
.message.ai {
  background-color: #efefef;
  color: #000000;
  margin-right: auto;
}

.chatform {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.chatform form {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1000px;
  gap: 5px;
  padding: 0;
  margin: 0;
}

.chatform .chatinput {
  flex: 1;
  padding: 10px;
  border: 1px solid #cccccc;
  border-radius: 8px;
  min-width: 200px;
  margin-left: 5px;
}

.chatform button {
  padding: 8px 16px;
  white-space: nowrap;
  background-color: #007bff;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  cursor: pointer;
}

.chatform button:hover {
  background-color: #0056b3;
}

@media (max-width: 400px) {
  .chatwelcome {
    font-size: 24px;
  }
  .historytitle {
    max-height: 120px;
  }
  .chatcontent {
    max-height: 250px;
  }
}
