/* 聊天页面样式 */

#chat-page-content {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  /* 底部padding = 输入栏(70px) + 快捷回复(60px) + 底部导航(60px) = 190px */
  padding-bottom: 190px;
  position: relative;
}

/* ========== 置顶卡片 ========== */
.top-card {
  position: relative;
  margin: 10px 15px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.top-card-content {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: white;
  cursor: pointer;
  transition: opacity 0.2s;
}

.top-card-content:active {
  opacity: 0.8;
}

.top-card-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  margin-right: 12px;
  font-size: 14px;
}

.top-card-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.top-card-button {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.arrow {
  margin-left: 4px;
  font-size: 12px;
}

.top-card-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.top-card-close:hover {
  color: white;
  transform: scale(1.1);
}

/* ========== 消息区域 ========== */
.messages-container {
  /* 移除flex和overflow，让页面body自带滚动条 */
  padding: 10px 0;
}

.load-more {
  text-align: center;
  padding: 20px 0;
}

.loading-text {
  color: #999;
  font-size: 12px;
}

.messages-list {
  padding: 0 15px;
}

/* 时间分隔线 */
.time-divider {
  text-align: center;
  margin: 20px 0 10px;
}

.time-divider span {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  color: #999;
  font-size: 11px;
}

/* 消息项 */
.message-item {
  margin-bottom: 10px;
}

.message-wrapper {
  display: flex;
  align-items: flex-start;
}

/* 用户消息 - 右对齐 */
.user .message-wrapper {
  justify-content: flex-end;
  flex-direction: row;
  padding-right: 15px; /* 与输入框右侧对齐 */
}

.user .avatar {
  margin-left: 8px;
  margin-right: 0;
  order: 2; /* 头像在右边 */
}

.user .message-content {
  order: 1; /* 消息内容在左边 */
}

.user-message {
  max-width: 250px;
  padding: 8px 12px;
  background: white;
  color: #333;
  border-radius: 12px 12px 2px 12px;
  word-wrap: break-word;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 守护兽消息 - 左对齐 */
.guardian .message-wrapper {
  padding-left: 15px; /* 与用户消息右侧padding对称 */
}

.avatar {
  width: 36px;
  height: 36px;
  margin-right: 12px;
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 1px solid #fff;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-star {
  color: white;
  font-size: 16px;
  font-weight: bold;
}

.guardian-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.guardian-message {
  flex: 1;
  max-width: 250px;
  padding: 8px 12px;
  background: white;
  border-radius: 12px 12px 12px 2px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  animation: fadeIn 0.3s ease;
}

.message-text {
  display: block;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* 消息反馈 */
.message-feedback-simple {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
}

.feedback-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: #f8f9fa;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-icon:hover {
  transform: scale(1.1);
}

.feedback-icon:active {
  transform: scale(0.9);
  background: #e9ecef;
}

.feedback-icon.thumbup:active {
  background: #e6f4ea;
}

.feedback-icon.thumbdown:active {
  background: #fce8e6;
}

.feedback-result-simple {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
  font-size: 16px;
}

/* 系统消息 */
.system-wrapper {
  justify-content: center;
  margin: 10px 0;
}

.system-message {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 10px;
  max-width: 200px;
}

.system-icon {
  margin-right: 6px;
  font-size: 14px;
}

.system-text {
  font-size: 13px;
  color: #667eea;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 30px;
  text-align: center;
  min-height: 300px;
}

.empty-image {
  font-size: 80px;
  margin-bottom: 20px;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

/* ========== 快捷回复区域 ========== */
.quick-replies-area {
  position: fixed;
  bottom: 130px; /* 输入栏高度 + 底部导航栏高度 */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 750px;
  padding: 10px 0;
  background: white;
  border-top: 1px solid #e9ecef;
  z-index: 50;
}

.quick-replies-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.quick-replies-scroll::-webkit-scrollbar {
  display: none;
}

.quick-replies-list {
  display: flex;
  padding: 0 15px;
  white-space: nowrap;
}

.quick-reply-item {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  margin-right: 10px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  color: #667eea;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quick-reply-item:hover {
  background: #e9ecef;
}

.quick-reply-item:active {
  background: #e9ecef;
  transform: scale(0.95);
}

/* ========== 输入栏 ========== */
.input-bar {
  position: fixed;
  bottom: 60px; /* 底部导航栏高度 */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 750px;
  background: white;
  border-top: 1px solid #e9ecef;
  padding: 10px 15px;
  transition: all 0.3s ease;
  z-index: 100;
}

.input-bar.focus {
  padding-bottom: 10px;
}

.input-container {
  display: flex;
  align-items: flex-end;
  min-height: 40px;
}

.input-extra {
  margin-right: 10px;
}

.input-wrapper {
  position: relative;
  flex: 1;
  background: #f8f9fa;
  border-radius: 16px;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.input-textarea {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 100px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
}

.input-textarea::placeholder {
  color: #999;
}

.input-counter {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 10px;
  color: #999;
}

.input-actions {
  margin-left: 10px;
}

.voice-btn-placeholder {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ccc;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  cursor: not-allowed;
}

.send-btn {
  min-width: 40px;
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #667eea;
  border: none;
  border-radius: 16px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.send-btn:not(.active) {
  background: #ccc;
  color: #999;
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========== 回到底部按钮 ========== */
.scroll-to-bottom {
  position: fixed;
  bottom: 200px; /* 快捷回复(60px) + 输入栏(70px) + 底部导航(60px) + 间距(10px) = 200px */
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(102, 126, 234, 0.9);
  border-radius: 50%;
  color: white;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 40; /* 低于输入栏和快捷回复，保持在消息区域内 */
}

.scroll-to-bottom.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.scroll-to-bottom:active {
  transform: scale(0.9);
}

/* ========== Toast 提示 ========== */
.toast-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 10000;
  font-size: 14px;
  animation: fadeIn 0.3s ease;
}

/* ========== 响应式适配 ========== */
@media (max-width: 375px) {
  .user-message,
  .guardian-message {
    max-width: 210px;
  }
}

@media (min-width: 414px) {
  .user-message,
  .guardian-message {
    max-width: 280px;
  }
}

/* ========== 滚动条美化 ========== */
.messages-container::-webkit-scrollbar {
  width: 4px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ========== 早签晚评页面 ========== */
.morning-evening-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
}

.me-header {
  position: relative;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-bottom: 1px solid #e9ecef;
}

.me-back-btn {
  position: absolute;
  left: 15px;
  padding: 8px 12px;
  color: #667eea;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.me-back-btn:hover {
  background: #f8f9fa;
  border-radius: 8px;
}

.me-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.me-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.me-placeholder {
  text-align: center;
}

.me-icon {
  font-size: 80px;
  margin-bottom: 20px;
}

.me-text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.me-desc {
  font-size: 14px;
  color: #999;
}
