/* Chat Page */
#page-chat {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}

.chat-status {
  font-size: 11px;
  color: var(--primary);
  margin-top: 2px;
}

.chat-settings {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  font-size: 18px;
}

/* Messages */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.message-wrap {
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

.ai-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.message-bubble {
  max-width: 280px;
  border-radius: 12px;
  padding: 12px 14px;
}

.ai-bubble {
  background: var(--bg-card);
  border-radius: 2px 12px 12px 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.message-text {
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.user-bubble {
  background: var(--primary);
  border-radius: 12px 2px 12px 12px;
}

.user-bubble .message-text {
  color: #ffffff;
}

/* Quick Replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.quick-reply-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 16px;
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-light);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.quick-reply-btn:active {
  background: var(--primary);
  color: #ffffff;
}

/* Recommended Articles in Chat */
.rec-articles {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.rec-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.rec-article {
  padding: 4px 0;
  cursor: pointer;
}

.rec-article-text {
  font-size: 13px;
  color: var(--primary);
}

.rec-article-text:hover {
  text-decoration: underline;
}

/* Typing Indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #CCCCBB;
  animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.chat-input-area {
  background: var(--bg-card);
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 22px;
  padding: 4px 4px 4px 14px;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-dark);
  outline: none;
  height: 32px;
  font-family: inherit;
}

.chat-input::placeholder {
  color: var(--text-placeholder);
}

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #DDDDCC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
  border: none;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
}

.send-btn.active {
  background: var(--primary);
}

/* Desktop */
@media (min-width: 768px) {
  #page-chat {
    width: 100%;
  }
  .chat-header {
    padding: 16px 28px;
  }
  .chat-name {
    font-size: 18px;
  }
  .messages-area {
    padding: 16px 28px;
  }
  .message-bubble {
    max-width: 480px;
    padding: 14px 18px;
  }
  .message-text {
    font-size: 15px;
  }
  .quick-reply-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
  .chat-input-area {
    padding: 10px 28px 16px;
  }
  .chat-input {
    font-size: 15px;
    height: 36px;
  }
  .send-btn {
    width: 36px;
    height: 36px;
  }
}
