/* =============================================================
   门户好友系统 —— 独立整页 /friends/ + 全站顶栏未读小红点
   只画门户自己的界面，不下探游戏 iframe 内部；零 emoji，图标一律手绘 SVG。
   ============================================================= */

/* ── 顶栏「好友」旁的未读小红点 ── */
.ps-navbadge {
  display: inline-block; min-width: 17px; height: 17px; padding: 0 4px;
  margin-left: 5px; border-radius: 9px;
  background: #f59e0b; color: #3b2503;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
  vertical-align: 1px;
}
.ps-navbadge[hidden] { display: none; }
/* 顶栏比原先多了「好友」这一项，992–1199 这段窄桌面会把每个导航项挤成两行；
   把导航项收紧一点并禁止折行，换来「一行放得下」。宽屏本来就宽，看不出差别。 */
@media (min-width: 992px) {
  .site-navbar .navbar-nav .nav-link {
    white-space: nowrap;
    padding-left: .45rem;
    padding-right: .45rem;
  }
}
/* 窄屏：导航收起，红点改挂在汉堡按钮右上角 */
.navbar-toggler { position: relative; }
.ps-togglerbadge { position: absolute; top: -6px; right: -6px; margin: 0; }

/* ── 整页骨架：左栏列表 + 右栏会话 ── */
.ps-page {
  position: relative;
  display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px;
  height: min(660px, calc(100vh - 240px)); min-height: 430px;
  font-size: 14px; line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
.ps-page * { box-sizing: border-box; }

.ps-side, .ps-chatpane {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .06);
}

/* ── 左栏 ── */
.ps-sidehead {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 8px;
  padding: 11px 13px 9px;
}
.ps-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.ps-myname {
  min-width: 0; font-size: 12px; color: #94a3b8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ps-search {
  flex: 0 0 auto; display: flex; gap: 6px;
  padding: 0 12px 10px; border-bottom: 1px solid #f1f5f9;
}
.ps-search input {
  flex: 1 1 auto; min-width: 0; padding: 6px 10px; font-size: 13px;
  border: 1px solid #cbd5e1; border-radius: 9px; font-family: inherit;
}
.ps-search input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px #e0e7ff; }
.ps-search button { flex: 0 0 auto; }

.ps-tabs { display: flex; flex: 0 0 auto; background: #f8fafc; border-bottom: 1px solid #e5e7eb; }
.ps-tab {
  flex: 1; padding: 9px 4px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: #475569; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.ps-tab:hover { color: #1e293b; }
.ps-tab.on { color: #4f46e5; font-weight: 700; border-bottom-color: #4f46e5; }
.ps-tab .ps-dot {
  display: inline-block; min-width: 16px; height: 16px; padding: 0 4px;
  margin-left: 4px; border-radius: 8px; background: #f59e0b; color: #3b2503;
  font-size: 11px; font-weight: 700; line-height: 16px;
}
.ps-tab .ps-dot[hidden] { display: none; }

.ps-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* ── 右栏 ── */
.ps-chatempty {
  flex: 1 1 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  padding: 24px; text-align: center; color: #cbd5e1;
}
.ps-chatempty svg { width: 60px; height: 60px; }
.ps-chatempty .ps-hint { margin: 4px 0 0; color: #64748b; font-size: 14px; }
.ps-chatempty .ps-subhint { margin: 0; color: #94a3b8; font-size: 13px; max-width: 320px; }

.ps-chatbox { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ps-chatbox[hidden] { display: none; }
.ps-chatempty[hidden] { display: none; }

.ps-chathead {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; background: #4f46e5; color: #fff;
}
.ps-chathead .ps-av { width: 32px; height: 32px; font-size: 14px; }
.ps-chathead .ps-name { color: #fff; }
.ps-chathead .ps-name .ps-id { color: #c7d2fe; }
.ps-chathead .ps-sub { color: #c7d2fe; }
.ps-back {
  flex: 0 0 auto; display: none; padding: 3px 8px; border-radius: 7px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .55); background: transparent;
  color: #fff; font-size: 12px; font-family: inherit;
}
.ps-back:hover { background: rgba(255, 255, 255, .18); }
.ps-headbtn {
  flex: 0 0 auto; padding: 2px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .55); background: transparent;
  color: #fff; font-size: 12px; font-family: inherit;
}
.ps-headbtn:hover { background: rgba(255, 255, 255, .18); }

/* ── 列表行 ── */
.ps-sec { padding: 8px 12px 3px; font-size: 12px; color: #94a3b8; background: #fff; }
.ps-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-bottom: 1px solid #f1f5f9;
}
.ps-item.ps-click { cursor: pointer; }
.ps-item.ps-click:hover { background: #f8fafc; }

.ps-av {
  position: relative; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: #e0e7ff; color: #3730a3;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.ps-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ps-av .ps-on {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #fff; background: #cbd5e1;
}
.ps-av .ps-on.up { background: #22c55e; }

.ps-main { flex: 1 1 auto; min-width: 0; }
.ps-name {
  display: flex; align-items: center; gap: 5px;
  font-weight: 600; color: #0f172a; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ps-name .ps-id { font-size: 11px; font-weight: 400; color: #94a3b8; }
.ps-name .ps-chip {
  flex: 0 0 auto; padding: 0 5px; border-radius: 6px;
  background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 400;
}
.ps-sub {
  font-size: 12px; color: #64748b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ps-act { flex: 0 0 auto; display: flex; gap: 4px; }
.ps-act button {
  padding: 3px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid #4f46e5; background: #4f46e5; color: #fff;
  font-size: 12px; font-family: inherit;
}
.ps-act button:hover { background: #4338ca; border-color: #4338ca; }
.ps-act button.ghost { background: #fff; color: #4f46e5; }
.ps-act button.ghost:hover { background: #eef2ff; }
.ps-act button.danger { border-color: #e11d48; background: #fff; color: #e11d48; }
.ps-act button.danger:hover { background: #fff1f2; }
.ps-act button:disabled { opacity: .55; cursor: default; }

.ps-empty { padding: 26px 16px; text-align: center; color: #94a3b8; font-size: 13px; }

/* ── 会话正文 ── */
.ps-msgs {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; background: #f8fafc;
}
.ps-msgs .ps-empty { margin: auto; }
.ps-msg {
  max-width: 72%; padding: 7px 11px; border-radius: 12px;
  font-size: 13px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.ps-msg.me { align-self: flex-end; background: #4f46e5; color: #fff; border-bottom-right-radius: 4px; }
.ps-msg.you { align-self: flex-start; background: #fff; color: #0f172a; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.ps-msg.pending { opacity: .6; }
.ps-msg.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; align-self: flex-end; }

.ps-foot { flex: 0 0 auto; display: flex; gap: 7px; padding: 9px 12px; border-top: 1px solid #e5e7eb; background: #fff; }
.ps-foot[hidden] { display: none; }
.ps-foot .ps-input {
  flex: 1 1 auto; min-width: 0; height: 36px;
  padding: 7px 10px; font-size: 13px; font-family: inherit;
  border: 1px solid #cbd5e1; border-radius: 9px;
}
.ps-foot .ps-input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px #e0e7ff; }
.ps-foot button { flex: 0 0 auto; padding: 0 16px; }

/* ── 一次性提示（加好友失败之类）── */
.ps-toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 1040; max-width: 300px;
  padding: 9px 14px; border-radius: 10px;
  background: #0f172a; color: #fff; font-size: 13px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .3);
}

/* ── 窄屏：列表与会话切换，不做并排 ── */
@media (max-width: 768px) {
  .ps-page {
    grid-template-columns: minmax(0, 1fr);
    height: auto; min-height: 60vh;
  }
  .ps-side { min-height: 60vh; }
  .ps-chatpane { min-height: 60vh; }
  .ps-page.chatting .ps-side { display: none; }
  .ps-page:not(.chatting) .ps-chatpane { display: none; }
  .ps-back { display: block; }
  .ps-msg { max-width: 84%; }
}
