/* ============================================================
   好友系统（friends.js）：侧栏列表 + 聊天窗 + 分享选择器
   桌面双栏；手机端单窗切换（.chat-open 时只显示聊天）
   ============================================================ */

.friends {
  position: relative;
  height: 100%; min-height: 0;
  display: flex; gap: 0;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}

/* ---- 侧栏 ---- */
.fr-side {
  width: 300px; flex: none;
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line-1);
  background: var(--bg-2);
}
.fr-side-head {
  display: flex; gap: var(--sp-2); padding: var(--sp-3);
  border-bottom: 1px solid var(--line-1);
}
.fr-add-btn { flex: 1; justify-content: center; }
.fr-req-btn { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.fr-list { flex: 1; overflow-y: auto; padding: var(--sp-2); }
.fr-empty { padding: var(--sp-6) var(--sp-3); }

.fr-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: none; border: none; border-radius: var(--r-md);
  color: var(--tx-1); cursor: pointer; text-align: left;
  transition: background var(--t-fast) var(--ease);
}
.fr-item:hover { background: var(--bg-3); }
.fr-item.active { background: var(--bg-3); box-shadow: inset 2px 0 0 var(--neon-cyan); }
.fr-av { position: relative; flex: none; display: flex; }
.fr-online {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--neon-green); border: 2px solid var(--bg-2);
}
.fr-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.fr-name { font-size: var(--fs-md); font-weight: 600; }
.fr-sub { font-size: var(--fs-xs); color: var(--tx-3); }
/* 会员徽章（任务4）：好友列表/聊天头部的紧凑档位标 */
.fr-namerow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.fr-namerow .fr-name { flex: 1; min-width: 0; }
.fr-vip { flex: none; padding: 1px 7px; gap: 3px; font-size: 10px; line-height: 1.5; cursor: default; }
.fr-vip .i { width: 10px; height: 10px; }
.fr-badge {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---- 聊天区 ---- */
.fr-chat { flex: 1; min-width: 0; display: none; flex-direction: column; min-height: 0; }
.friends.chat-open .fr-chat { display: flex; }
.friends.chat-open .fr-placeholder { display: none; }
.fr-chat-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-2);
}
.fr-back { display: none; }
.fr-chat-av { display: flex; flex: none; }
.fr-chat-meta { flex: 1; min-width: 0; }
.fr-chat-title { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.fr-chat-title > .ellipsis { min-width: 0; }
.fr-chat-title .fr-vip { flex: none; }
.fr-chat-sub { font-size: var(--fs-xs); color: var(--tx-3); }

.fr-msgs {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.fr-chat-empty { margin: auto; color: var(--tx-3); font-size: var(--fs-sm); }

.fr-msg { display: flex; align-items: flex-end; gap: var(--sp-2); max-width: 78%; }
.fr-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.fr-msg:not(.mine) { align-self: flex-start; }
.fr-bubble {
  min-width: 0; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  background: var(--bg-3); color: var(--tx-1);
  border: 1px solid var(--line-1);
  border-bottom-left-radius: var(--r-sm);
  word-break: break-word;
}
.fr-msg.mine .fr-bubble {
  background: linear-gradient(135deg, rgba(79,124,255,.28), rgba(139,92,246,.28));
  border-color: var(--line-2);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-sm);
}
.fr-text { font-size: var(--fs-md); line-height: 1.6; white-space: pre-wrap; }
.fr-time { margin-top: 4px; font-size: 10px; color: var(--tx-3); text-align: right; }

/* ---- 输入栏 ---- */
.fr-inputbar {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  padding: var(--sp-3);
  border-top: 1px solid var(--line-1);
  background: var(--bg-2);
}
.fr-input {
  flex: 1; resize: none; max-height: 120px;
  font-size: 16px; line-height: 1.5;
}
.fr-share-btn, .fr-send { flex: none; }

/* ---- 占位 ---- */
.fr-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--sp-2);
  color: var(--tx-3); text-align: center; padding: var(--sp-4);
}
.fr-placeholder .empty-art { opacity: .5; }

/* ---- 分享卡片 ---- */
.fr-share {
  display: block; min-width: 220px; max-width: 320px;
  border-radius: var(--r-md); overflow: hidden;
  background: rgba(5, 8, 20, 0.35);
  border: 1px solid var(--line-2);
  color: var(--tx-1); text-decoration: none;
}
.fr-share-head {
  display: flex; align-items: center; gap: 6px;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm); font-weight: 600;
  background: var(--grad-brand-soft);
  border-bottom: 1px solid var(--line-1);
}
.fr-share-body { padding: var(--sp-2) var(--sp-3); }
.fr-share-line {
  margin: 0; padding: 2px var(--sp-3);
  font-size: var(--fs-sm); color: var(--tx-2); line-height: 1.5;
}
.fr-share-body .fr-share-line { padding: 2px 0; }
.fr-share-note {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap;
}
.fr-share-more { padding: 2px var(--sp-3) var(--sp-2); margin: 0; font-size: var(--fs-xs); color: var(--tx-3); }
.fr-share-body .fr-share-more { padding: 2px 0 0; }
.fr-share-img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.fr-share-file { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); transition: background var(--t-fast); }
.fr-share-file:hover { background: var(--bg-3); }
.fr-share-fic { display: flex; color: var(--neon-cyan); flex: none; }
.fr-share-fmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--fs-sm); }
.fr-share-fdl { display: flex; color: var(--tx-3); flex: none; }

/* ---- 分享选择器 / 搜索 / 申请 ---- */
.fr-picker { display: flex; flex-direction: column; gap: var(--sp-3); min-height: 320px; }
.fr-picker-tabs { flex-wrap: wrap; }
.fr-picker-pane { min-height: 280px; max-height: 55vh; overflow-y: auto; }
.fr-pick-list { display: flex; flex-direction: column; gap: 6px; }
.fr-pick-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: var(--bg-2); border: 1px solid var(--line-1);
  border-radius: var(--r-md); color: var(--tx-1);
  cursor: pointer; text-align: left; font-size: var(--fs-md);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.fr-pick-item:hover { background: var(--bg-3); border-color: var(--line-2); }
.fr-pick-item.checked { border-color: var(--neon-cyan); background: rgba(0, 229, 255, 0.08); }
.fr-pick-item > span:nth-child(2) { flex: 1; min-width: 0; }
.fr-pick-msgs .fr-pick-item { align-items: flex-start; }
.fr-role {
  flex: none; font-size: var(--fs-xs); font-weight: 700;
  padding: 2px 6px; border-radius: var(--r-sm);
  background: rgba(139, 92, 246, 0.18); color: var(--neon-violet);
}
.fr-role.user { background: rgba(0, 229, 255, 0.14); color: var(--neon-cyan); }
.fr-pick-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); margin-bottom: var(--sp-2);
}
.fr-pick-count { font-size: var(--fs-sm); color: var(--tx-2); }
.fr-pick-foot {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  margin-top: var(--sp-3);
}
.fr-pick-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--sp-2);
}
.fr-pick-img {
  padding: 0; border: 2px solid transparent; border-radius: var(--r-md);
  overflow: hidden; cursor: pointer; background: var(--bg-2);
  aspect-ratio: 1; transition: border-color var(--t-fast), transform var(--t-fast);
}
.fr-pick-img:hover { border-color: var(--neon-cyan); transform: scale(1.02); }
.fr-pick-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fr-add { display: flex; flex-direction: column; gap: var(--sp-3); }
.fr-add-result { max-height: 50vh; overflow-y: auto; }
.fr-add-row { cursor: default; }
.fr-add-row:hover { background: var(--bg-2); }
.fr-req-title { margin: var(--sp-2) 0; font-size: var(--fs-sm); color: var(--tx-2); }
.fr-reqs { display: flex; flex-direction: column; gap: 6px; }

/* ---- 头像菜单气泡 ---- */
.avatar-btn { position: relative; }
.avatar-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  border: 2px solid var(--bg-1);
  pointer-events: none;
}
.dropdown-suffix {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---- 手机端（≤768px）：单窗切换 ---- */
@media (max-width: 768px) {
  .friends { border: none; border-radius: 0; }
  .fr-side { width: 100%; flex: 1; border-right: none; }
  .fr-chat {
    position: absolute; inset: 0; z-index: 5;
    background: var(--bg-1);
  }
  .friends.chat-open .fr-side { display: none; }
  .fr-back { display: inline-flex; }
  .fr-placeholder { display: none !important; }
  .fr-msg { max-width: 88%; }
  .fr-share { min-width: 0; max-width: 100%; }
  .fr-inputbar { padding: var(--sp-2); padding-bottom: calc(var(--sp-2) + env(safe-area-inset-bottom)); }
  .fr-send span { display: none; }
  .fr-picker-pane { max-height: 60vh; }
}
