/* General Styles */
body {
  font-family: "Prompt", "Sarabun", sans-serif;
  background-color: #f0f2f5;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}

.chat-container {
  width: 100%;
  max-width: 450px; /* Typical chat width */
  height: 80vh;
  max-height: 700px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.chat-header {
  background-color: #0a2463; /* Main color */
  color: #fff;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  /* border-bottom: 1px solid #081f50; */
  justify-content: space-between;
}

/* .chat-header .logo {
    width: 40px;
    height: 40px;
    margin-right: 15px;
    border-radius: 50%; 
    background-color: #fff; 
} */

.chat-header .logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: #ffd700;
}

.chat-header .header-title h1 {
  font-size: 1.2em;
  margin: 0;
  font-weight: 500;
}

.chat-header .connection-status {
  font-size: 0.8em;
  background-color: #3e92cc; /* Secondary color */
  padding: 3px 8px;
  border-radius: 10px;
}
.connection-status.connected {
  background-color: #4caf50;
} /* Green for connected */
.connection-status.disconnected {
  background-color: #f44336;
} /* Red for disconnected */

/* Chat Messages Area */
.chat-messages {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  max-width: 75%;
  padding: 10px 15px;
  border-radius: 18px;
  margin-bottom: 10px;
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 0.95em;
}

.message-bubble.bot {
  background-color: #e9eaf0; /* Light background */
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}
.message-bubble.bot img.logo-in-message {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 5px;
}

.message-bubble.user {
  background-color: #0a2463; /* Main color */
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.message-bubble .timestamp {
  font-size: 0.7em;
  color: #888;
  display: block;
  text-align: right;
  margin-top: 5px;
}
.message-bubble.bot .timestamp {
  color: #666;
  text-align: left;
}

/* Input Area */
.chat-input-area {
  display: flex;
  padding: 15px;
  border-top: 1px solid #e0e0e0;
  background-color: #f9f9f9;
}

#userInput {
  flex-grow: 1;
  padding: 10px 15px;
  border: 1px solid #ccc;
  border-radius: 20px;
  margin-right: 10px;
  font-size: 0.95em;
  font-family: "Prompt", "Sarabun", sans-serif;
}
#userInput:focus {
  outline: none;
  border-color: #3e92cc;
  box-shadow: 0 0 0 2px rgba(62, 146, 204, 0.2);
}

#sendButton {
  padding: 10px 20px;
  background-color: #0a2463; /* Main color */
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95em;
  font-family: "Prompt", "Sarabun", sans-serif;
  transition: background-color 0.3s ease;
}
#sendButton:hover {
  background-color: #081f50;
}

/* Carousel Component */
.carousel-container {
  display: flex;
  overflow-x: auto;
  padding: 10px 0;
  margin-bottom: 10px;
  scroll-snap-type: x mandatory; /* Smooth snapping */
  -webkit-overflow-scrolling: touch; /* For iOS momentum scrolling */
}
.carousel-container::-webkit-scrollbar {
  height: 8px;
}
.carousel-container::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.advisor-card {
  flex: 0 0 auto; /* Prevent shrinking/growing */
  width: 150px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-right: 5px;
  padding: 5px;
  text-align: center;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  scroll-snap-align: start;
}
.advisor-card:last-child {
  margin-right: 0;
}

.advisor-card img {
  /* ทำให้รูปภาพเต็มความกว้างและดึงออกมานอก padding */
  width: calc(100% + 10px); /* กว้างกว่าปกติ 10px (padding ซ้าย 5 + ขวา 5) */
  margin-left: -5px; /* ดึงไปทางซ้าย 5px */
  margin-top: -5px; /* ดึงขึ้นบน 5px */

  /* จัดการรูปภาพและระยะห่าง */
  height: 135px;
  /* object-fit: cover; ทำให้รูปเต็มพื้นที่โดยไม่เสียสัดส่วน */
  margin-bottom: 10px; /* เพิ่มระยะห่างด้านล่างระหว่างรูปกับชื่อ */

  /* ทำให้มุมบนของรูปโค้งตามการ์ด */
  border-top-left-radius: 8px; /* ทำให้มุมโค้งเหมือน .advisor-card */
  border-top-right-radius: 8px; /* ทำให้มุมโค้งเหมือน .advisor-card */
}

.advisor-card h4 {
  font-size: 0.9em;
  margin: 5px 0;
  color: #0a2463;
}

.advisor-card p {
  font-size: 0.75em;
  color: #555;
  margin-bottom: 10px;
  min-height: 30px; /* Ensure consistent height */
}

.advisor-card .select-advisor-btn,
.option-button,
.link-button {
  background-color: #3e92cc; /* Secondary color */
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 15px;
  font-size: 0.8em;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: block;
  width: 100%;
  box-sizing: border-box;
}
.advisor-card .select-advisor-btn:hover,
.option-button:hover,
.link-button:hover {
  background-color: #2a7aaf;
}

/* Button Options Component */
.options-container {
  display: flex;
  flex-wrap: wrap; /* Allow buttons to wrap */
  gap: 10px; /* Spacing between buttons */
  margin-top: 10px;
  justify-content: flex-start; /* Align to the start for bot messages */
}

.option-button {
  flex-grow: 1; /* Allow buttons to share space */
  min-width: 120px; /* Minimum width before wrapping */
}

/* Form Input Component (within chat bubble) */
.form-input-group {
  margin-bottom: 10px;
}
.form-input-group label {
  display: block;
  font-size: 0.85em;
  margin-bottom: 5px;
  color: #333;
}
.form-input-group input[type="text"] {
  width: calc(100% - 22px); /* Full width minus padding */
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9em;
  font-family: "Prompt", "Sarabun", sans-serif;
}
.form-input-group input[type="text"]:focus {
  outline: none;
  border-color: #3e92cc;
}
.form-input-group .validation-error {
  font-size: 0.75em;
  color: #d32f2f; /* Red for errors */
  margin-top: 3px;
}

/* Loading Indicator (as a message) */
.loading-indicator-bubble {
  display: flex;
  align-items: center;
  font-style: italic;
  color: #777;
}
.loading-spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3e92cc;
  border-radius: 50%;
  width: 15px;
  height: 15px;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: flex-start; /* Align chat to top on small screens */
  }
  .chat-container {
    max-width: 100%;
    height: 100vh; /* Full height on mobile */
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .advisor-card {
    width: 130px; /* Slightly smaller cards on mobile */
  }
  .advisor-card img {
    /* ทำให้รูปภาพเต็มความกว้างและดึงออกมานอก padding */
    width: calc(100% + 10px); /* กว้างกว่าปกติ 10px (padding ซ้าย 5 + ขวา 5) */
    margin-left: -5px; /* ดึงไปทางซ้าย 5px */
    margin-top: -5px; /* ดึงขึ้นบน 5px */
  }
}
