/* ========================================= */
/* 文件：messages.css                         */
/* 功能：聊天消息相关的全部样式 —— 聊天气泡、  */
/*       输入框、头像、引用条、长按菜单、      */
/*       时间分隔线、链接预览卡片              */
/* ========================================= */

/* 消息列表 (大盒子) */
.messages {
  flex: 1;
  min-height: 0; /* 弹性盒子默认 min-height:auto 会撑爆父容器，这里强制归零 */
  padding: 12px;
  overflow-y: auto;
  scrollbar-width: none;
  position: relative;
  
  /* ✨ 魔法减震器：留住它！防止扯动外层网页 */
  overscroll-behavior-y: none;
  touch-action: pan-y;
}
.messages::-webkit-scrollbar { display: none; }

/* 单个气泡排版 (小盒子，刚才被误伤的就是它俩，现在补回来！) */
.message { display: flex; align-items: flex-end; margin-bottom: 12px; }
.message.me { justify-content: flex-end; }

/* 气泡样式 */
.msg {
  max-width: 75%;
  padding: 8px 12px;
  line-height: 1.5;
  border-radius: 22px;
  word-wrap: break-word;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  transition: filter 0.2s, transform 0.1s;
}
.message.me .msg {
  background: linear-gradient(135deg, rgba(255,195,140,0.45), rgba(255,165,100,0.35));
  border-bottom-right-radius: 6px;
  color: #271910;
}
.message.him .msg { background: rgba(255,255,255,0.15); border-bottom-left-radius: 6px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; margin: 0 6px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6); 
}
.message.me .avatar {
  box-shadow: 0 0 0 2px rgba(255, 179, 122, 0.6);
  filter: drop-shadow(0 2px 4px rgba(255, 159, 90, 0.3));
}

/* 底部输入区 */
.input-area {
  position: relative;
  display: flex;
  align-items: flex-end;
  background: transparent;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  padding-top: 10px;
  padding-left: 5px;
  padding-right: 5px;
  flex-shrink: 0;
  min-height: 56px;
}

.input-area textarea {
  flex: 1; 
  height: 36px; max-height: 120px;
  padding: 8px 15px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(11,15,26,0.55);
  border-radius: 20px; 
  color: #fff; 
  font-size: 15px; 
  font-family: inherit;
  outline: none;
  margin: 0 8px; margin-bottom: 0px; 
  transition: background 0.3s;
  resize: none; overflow-y: auto; line-height: 20px;
}
.input-area textarea:focus { background: rgba(11,15,26,0.7); border-color: rgba(255,255,255,0.3); }

.input-area button {
  padding: 8px; 
  background: none; border: none;
  display: flex; align-items: center; justify-content: center;
  height: 36px; margin-bottom: 0px; 
}
.input-area button img { width: 26px; height: 26px; filter: invert(0.9); }

/* 图片消息 */
.msg.has-image {
  padding: 5px !important;    
  background: rgba(255, 179, 122, 0.2) !important; 
  border: 1px solid rgba(255, 179, 122, 0.3);
  display: inline-block !important; 
  width: auto !important;
}
.chat-image-bubble {
  max-width: 140px !important; 
  width: auto !important;      
  height: auto !important;     
  border-radius: 10px;         
  display: block;              
  margin: 0;
}
.message.preview .msg { opacity: 0.7; }

/* 引用预览条 */
#quote-bar {
  position: absolute;
  bottom: 100%; left: 0; width: 100%; height: 35px;
  background: rgba(20, 22, 30, 0.4); backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%);
  border-top: 1px solid rgba(255, 255, 255, 0.15); border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex; align-items: center; justify-content: space-between; padding: 0 12px; z-index: 50; 
  animation: slideUp 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#quote-bar::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; background: #ffb37a; border-radius: 0 4px 4px 0;
  box-shadow: 2px 0 8px rgba(255, 179, 122, 0.4);
}
.quote-content {
  flex: 1; font-size: 13px; color: rgba(255, 255, 255, 0.75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
  margin-right: 10px; padding-left: 6px; display: flex; align-items: center;
}
.quote-label { color: #ffb37a; font-weight: 700; margin-right: 6px; opacity: 0.9; }
.quote-close {
  width: 32px; height: 100%; background: transparent; 
  color: rgba(255, 255, 255, 0.4); display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 300; cursor: pointer; transition: all 0.2s; margin-right: -8px;
}
.quote-close:active { color: #fff; transform: scale(1.1); }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.msg-quote {
  font-size: 12px; margin-bottom: 6px; padding: 6px 10px; border-radius: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4;
}
.message.me .msg-quote { background: rgba(39, 25, 16, 0.08); border-left: 3px solid rgba(39, 25, 16, 0.3); color: rgba(39, 25, 16, 0.7); }
.message.him .msg-quote { background: rgba(255, 255, 255, 0.1); border-left: 3px solid rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.7); }
/* =========================================
   ✨✨✨ 气泡长按菜单 ✨✨✨
   ========================================= */
#bubble-menu {
  position: fixed; z-index: 9999;
  background: rgba(20, 22, 30, 0.75); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 0; display: none; flex-direction: row; overflow: hidden;
  animation: menuPopScale 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.menu-option {
  padding: 8px 14px; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.9);
  white-space: nowrap; cursor: pointer; border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; align-items: center; gap: 6px; transition: all 0.2s;
}
.menu-option:last-child { border-right: none; }
.menu-option:active { background: rgba(255, 179, 122, 0.15); color: #ffb37a; }
#bubble-menu::after {
  content: ""; position: absolute; width: 8px; height: 8px;
  background: rgba(20, 22, 30, 0.95); 
  border-right: 1px solid rgba(255, 255, 255, 0.12); border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  left: 50%; margin-left: -4px; bottom: -4px; transform: rotate(45deg); z-index: -1; 
}
#bubble-menu.arrow-up::after { top: -4px; bottom: auto; border-bottom: none; border-right: none; border-top: 1px solid rgba(255, 255, 255, 0.12); border-left: 1px solid rgba(255, 255, 255, 0.12); }
.msg.active-press { filter: brightness(0.9); transform: scale(0.97); }
@keyframes menuPopScale { 0% { opacity: 0; transform: scale(0.8) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
/* =========================================
   ✨✨✨ 微信式：时间胶囊断点 ✨✨✨
   ========================================= */
.chat-time-label {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45); /* 极其克制的半透明灰色 */
  margin: 20px 0 15px 0; /* 上下留出呼吸感 */
  font-weight: 500;
  letter-spacing: 0.5px;
  clear: both; /* 确保它独占一行，不会和气泡挤在一起 */
}

.chat-time-label span {
  background: rgba(255, 255, 255, 0.08); /* 微微浮现的深色底托 */
  padding: 4px 10px;
  border-radius: 6px; /* 微信同款的微圆角 */
}
/* ============ 链接预览卡片 ============ */
.link-preview-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 0 48px 0 48px;
  margin-bottom: 8px;
}
.link-preview-card {
  max-width: 75%;
  background: linear-gradient(135deg, rgba(255,195,140,0.38), rgba(255,165,100,0.28));
  border: 1px solid rgba(255,165,100,0.28);
  border-radius: 18px;
  overflow: hidden;
  font-size: 13px;
  color: #271910;
}
.link-preview-card.loading {
  padding: 12px 16px;
}
.lp-loading {
  color: rgba(39,25,16,0.55);
  font-size: 12px;
}
.lp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
  text-decoration: none;
  color: inherit;
}
.lp-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}
.lp-favicon-fallback {
  font-size: 16px;
  flex-shrink: 0;
}
.lp-title-block {
  flex: 1;
  min-width: 0;
}
.lp-title {
  font-size: 13px;
  font-weight: 600;
  color: #271910;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.lp-domain {
  font-size: 11px;
  color: rgba(39,25,16,0.55);
  margin-top: 1px;
}
.lp-desc {
  padding: 0 12px 8px;
  font-size: 12px;
  color: rgba(39,25,16,0.65);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-content {
  display: none;
  padding: 8px 12px;
  font-size: 12px;
  color: rgba(39,25,16,0.72);
  line-height: 1.7;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid rgba(39,25,16,0.12);
  white-space: pre-wrap;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.lp-content.open {
  display: block;
}
.lp-toggle {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: rgba(39,25,16,0.06);
  border: none;
  border-top: 1px solid rgba(39,25,16,0.1);
  color: rgba(39,25,16,0.6);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.5px;
}
.lp-toggle:active { background: rgba(39,25,16,0.12); }
.lp-error {
  padding: 10px 14px;
  font-size: 12px;
  color: rgba(180, 40, 40, 0.85);
}

/* ============ 打字指示器 ============ */
.typing { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,0.7); margin-left: 42px; margin-bottom: 8px; animation: breathe 1.4s infinite; }
.typing-star { width: 14px; fill: #C0C0C0; }
