/* Chat Container Main */
.chat-container {
  max-width: 600px;
  margin: 0 auto;
  background-color: #7297c8; /* LINE-like background color */
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (min-width: 601px) {
  .chat-container {
    margin: 5vh auto;
    height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    overflow: hidden;
  }
}

/* Header (Question Area) */
.chat-header {
  background-color: #2c3e50; /* Dark header */
  color: white;
  padding: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
}

.chat-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
  opacity: 0.8;
}

.chat-header p {
  margin: 5px 0 0;
  font-size: 1.1rem;
  font-weight: bold;
}

/* Chat History (Scroll Area) */
.chat-history {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Message Rows */
.message-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.ai {
  justify-content: flex-start;
}

/* Avatar for AI */
.ai-avatar {
  width: 40px;
  height: 40px;
  background-color: #fff;
  border-radius: 50%;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  overflow: hidden;
}

.ai-avatar img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

/* Bubbles */
.bubble {
  position: relative;
  padding: 10px 15px;
  border-radius: 20px;
  max-width: 70%;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.bubble p {
  margin: 0;
}

/* User Bubble Style */
.message-row.user .bubble {
  background-color: #85e249; /* LINE green */
  color: #000;
  border-top-right-radius: 0;
}

.message-row.user .bubble::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent transparent #85e249;
}

/* AI Bubble Style */
.message-row.ai .bubble {
  background-color: #ffffff;
  color: #000;
  border-top-left-radius: 0;
}

.message-row.ai .bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 10px 10px 0;
  border-color: transparent #ffffff transparent transparent;
}

/* Sender Name (Optional, good for group chats but maybe less needed here if avatars/colors are distinct) */
.sender-name {
  font-size: 0.75rem;
  color: #555;
  margin-bottom: 4px;
  margin-left: 5px;
}

/* Footer (Input Area) */
.chat-footer {
  background-color: #f0f0f0;
  padding: 10px;
  border-top: 1px solid #ddd;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  align-items: flex-end; /* Align buttons to the bottom of the growing textarea */
}

.chat-input {
  flex-grow: 1;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
  resize: none;
  min-height: 40px;
  max-height: 150px;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
}

.chat-submit-btn {
  background-color: #5b82db;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 0 20px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  height: 40px; /* Fixed height */
  flex-shrink: 0;
}

.chat-submit-btn:hover {
  background-color: #4a6ec0;
}

.mic-btn {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 44px;
  height: 40px; /* Adjusted to match input min-height */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #555;
  flex-shrink: 0;
}

.mic-btn:hover {
  background-color: #e9ecef;
}

.mic-btn.listening {
  background-color: #ff4757;
  color: white;
  border-color: #ff4757;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* Action Area (Next Button) */
.action-area {
  padding: 10px;
  background-color: rgba(255,255,255,0.9);
  text-align: center;
  border-top: 1px solid #ddd;
}

.next-btn {
  background-color: #34495e;
  color: white;
  text-decoration: none;
  padding: 10px 30px;
  border-radius: 5px;
  display: inline-block;
  font-weight: bold;
  border: none;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}

.system-message {
  text-align: center;
  color: #fff;
  font-size: 0.8rem;
  margin: 10px 0;
  background-color: rgba(0,0,0,0.2);
  padding: 5px;
  border-radius: 10px;
  display: inline-block;
}

.system-message-container {
  text-align: center;
}

/* Option Buttons */
.option-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
  margin-top: 5px;
}

.chat-option-btn {
  background-color: #fff;
  border: 1px solid #3498db;
  color: #3498db;
  padding: 8px 16px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  width: 100%;
  text-align: center;
}

.chat-option-btn:hover {
  background-color: #3498db;
  color: white;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
}

.typing-indicator span {
  display: block;
  width: 6px;
  height: 6px;
  background-color: #b0b0b0;
  border-radius: 50%;
  margin: 0 2px;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

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

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
