/* Friends (client/js/friends.js): Home's Friends page, its sidebar entry, Active Now, and the
   friend controls on profile cards. Uses the theme tokens from styles.css. */

/* ---- Home's sidebar: the Friends entry above the DM list ---- */
.channel.friends-entry { gap: 12px; padding: 8px; margin-bottom: 8px; font-weight: 500; }
.channel.friends-entry .icon { opacity: 1; }
.friends-entry-label { flex: 1; }
.friends-entry-badge { position: static; box-shadow: none; flex: none; }

/* ---- the header: title and tabs ---- */
.friends-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-strong); white-space: nowrap; }
.friends-title .icon { color: var(--text-muted); }
.friends-divider { width: 1px; height: 24px; background: var(--bg-active); margin: 0 8px; flex: none; }
.friends-tabs { display: flex; align-items: center; gap: 12px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.friends-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 4px; background: none; color: var(--text-muted); padding: 2px 8px; font-weight: 500; white-space: nowrap; }
.friends-tab:hover { background: var(--bg-hover); color: var(--text); }
.friends-tab.active { background: var(--bg-active); color: var(--text-strong); }
.friends-tab-badge { position: static; box-shadow: none; }
.friends-tab.friends-tab-add { background: var(--online); color: #fff; }
.friends-tab.friends-tab-add:hover { filter: brightness(1.1); }
.friends-tab.friends-tab-add.active { background: none; color: var(--online); }

/* ---- the page ---- */
.friends-page { padding: 8px 20px 16px 30px; display: flex; flex-direction: column; min-height: 100%; }
.friends-heading { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted); margin: 16px 0 8px; }
.friends-list { display: flex; flex-direction: column; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 10px; margin: 0 -10px; border-top: 1px solid var(--bg-active); border-radius: 8px; }
.friend-row + .friend-row { border-top-color: var(--bg-active); }
.friend-row:hover, .friend-row:focus-visible { background: var(--bg-hover); border-top-color: transparent; outline: none; }
.friend-row:hover + .friend-row { border-top-color: transparent; }
.friend-row.clickable { cursor: pointer; }
.friend-row .avatar .status { border-color: var(--bg-chat); }
.friend-row:hover .avatar .status { border-color: var(--bg-hover); }
.friend-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-row-names { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.friend-name { font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-username { font-size: 13px; visibility: hidden; white-space: nowrap; }
.friend-row:hover .friend-username, .friend-row:focus-visible .friend-username { visibility: visible; }
.friend-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-actions { display: flex; gap: 10px; flex: none; }
.friend-action { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--bg-sidebar); color: var(--text-muted); }
.friend-row:hover .friend-action { background: var(--bg-rail); }
.friend-action:hover { color: var(--text-strong); }
.friend-action.accept:hover { color: var(--online); }
.friend-action.decline:hover { color: var(--danger); }
.friends-empty { margin: auto; max-width: 420px; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.friends-empty .icon { color: var(--bg-active); }
.friends-empty p { margin: 0; }

/* Add Friend */
.add-friend { padding: 12px 0 20px; border-bottom: 1px solid var(--bg-active); }
.add-friend h2 { margin: 8px 0 4px; font-size: 16px; text-transform: uppercase; color: var(--text-strong); }
.add-friend > p.muted { margin: 0 0 16px; font-size: 14px; }
.add-friend-box { display: flex; align-items: center; gap: 12px; background: var(--bg-rail); border: 1px solid var(--bg-rail); border-radius: 8px; padding: 6px 6px 6px 12px; }
.add-friend-box:focus-within { border-color: var(--link); }
.add-friend-box.success { border-color: var(--online); }
.add-friend-box.error { border-color: var(--danger); }
.add-friend-input { flex: 1; min-width: 0; background: none; padding: 8px 0; font-size: 15px; }
.add-friend-input:focus { box-shadow: none; }
.add-friend-box button.primary { padding: 8px 16px; white-space: nowrap; }
.add-friend-box button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.add-friend-result { margin: 8px 0 0; font-size: 14px; min-height: 1.2em; }
.add-friend-result.success { color: var(--online); }
.add-friend-result.error { color: var(--danger); }

/* ---- Active Now (beside the page) ---- */
.active-now h2 { margin: 0 4px 12px; font-size: 18px; color: var(--text-strong); }
.active-now-list { display: flex; flex-direction: column; gap: 8px; }
.active-now-card { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 8px; background: var(--bg-chat); }
.active-now-card .avatar .status { border-color: var(--bg-chat); }
.active-now-card .icon { vertical-align: -2px; }
.active-now-empty { padding: 12px 4px; text-align: center; }
.active-now-empty strong { color: var(--text-strong); }
.active-now-empty p { margin: 4px 0 0; }

/* ---- profile cards ---- */
.profile-friend-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.profile-friend-actions button { flex: 1 1 auto; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.profile-friend-actions button:disabled { opacity: 0.6; cursor: default; }
.profile-friend-state { display: inline-flex; align-items: center; gap: 4px; flex: none; }

/* ---- narrow windows ---- */
@media (max-width: 720px) {
  .friends-divider, .friends-title { display: none; }
  .friends-page { padding: 8px 12px 16px; }
}
