/* Messages icon + preview, chat pop-ups and the Friends widget (public/dock.js). Also the Streamer Card action row. */

/* ---- header icon + dropdown (styled like the bell) ---- */
.msg-wrap { position: relative; display: flex; align-items: center; }
.msg-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-md); background: none; color: var(--text); cursor: pointer; }
.msg-btn:hover, .msg-btn[aria-expanded="true"] { background: var(--panel2); }
.msg-btn .count { position: absolute; top: -2px; right: -4px; margin: 0; }
.msg-panel { position: absolute; right: 0; top: 44px; width: 360px; max-height: min(520px, calc(100vh - 80px)); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); z-index: 30; font-weight: 400; text-align: left; }
.msg-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 16px; }
.msg-pad { padding: 12px 14px; margin: 0; }
.msg-sub { padding: 10px 14px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.msg-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.msg-row:hover { background: var(--panel2); }
.msg-row.slim { padding: 6px 14px; }
.msg-row.unread { background: rgba(232, 116, 59, 0.08); }
.msg-row.unread .msg-prev { color: var(--text); font-weight: 600; }
.msg-mid { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-mid b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.msg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.dk-av { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; background: var(--panel2); color: var(--text); font-size: 11px; font-weight: 600; }

/* friend + collab requests (dropdown and widget) */
.dk-req { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dk-req-name { display: flex; flex-direction: column; min-width: 0; flex: 1 1 120px; font-size: 14px; }
.dk-req-name a { color: var(--text); text-decoration: none; }
.dk-req-name .muted { overflow-wrap: anywhere; }
.dk-req-btns { display: flex; gap: 6px; }

/* friend rows */
.dk-friend { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 14px; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; font: inherit; font-size: 14px; }
.dk-friend:hover { background: var(--panel2); }
.dk-fav { position: relative; display: inline-flex; flex: none; }
.dk-fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-fstat { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ghost); border: 2px solid var(--panel); flex: none; }
.dk-fav .dk-dot { position: absolute; right: -2px; bottom: -2px; }
.dk-dot.online { background: var(--strong); }
.dk-dot.live { background: var(--none); }
.dk-dot.party { background: var(--accent); }
.dk-dot.offline { background: var(--ghost); }

/* ---- Friends widget, bottom right ---- */
.fdock { position: fixed; right: 16px; bottom: 0; width: 264px; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, .35); display: flex; flex-direction: column; }
.fdock-bar { display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; padding: 0 14px; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.fdock-bar .count { margin-left: 0; }
.fdock-chev { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(-45deg) translate(-2px, 2px); }
.fdock.open .fdock-chev { transform: rotate(135deg) translate(-2px, 2px); }
.fdock-body { max-height: min(460px, calc(100vh - 160px)); overflow: auto; border-top: 1px solid var(--line); padding-bottom: 6px; }
.fdock-find { display: block; width: calc(100% - 20px); margin: 8px 10px; padding: 7px 10px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-size: 13px; }
.fdock-out { padding: 6px 14px; }
.fdock-out summary { cursor: pointer; }
.fdock-out .dk-req { padding: 6px 0; }
.fdock .dk-req .dk-req-btns { width: 100%; justify-content: flex-end; }

/* ---- chat pop-ups: a row left of the Friends bar ---- */
.chat-dock { position: fixed; right: 292px; bottom: 0; z-index: 41; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 10px; pointer-events: none; max-width: calc(100vw - 300px); }
.chat-pop { pointer-events: auto; width: 320px; height: 430px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, .35); position: relative; min-width: 0; }
.chat-pop.min { width: 210px; height: 42px; }
.chat-pop.min .chat-msgs, .chat-pop.min .chat-form, .chat-pop.min .chat-cant, .chat-pop.min .chat-menu, .chat-pop.min [data-chat-menu] { display: none; }
.chat-head { display: flex; align-items: center; gap: 6px; height: 42px; flex: none; padding: 0 6px 0 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-who { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.chat-av { display: inline-flex; flex: none; }
.chat-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-name a { color: var(--text); text-decoration: none; }
.chat-name a:hover { text-decoration: underline; }
.chat-unread { margin-left: 0; }
.chat-btns { display: flex; flex: none; }
.chat-ib { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-lg); background: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 0; }
.chat-ib:hover { background: var(--panel2); color: var(--text); }
.chat-menu { position: absolute; top: 42px; right: 8px; z-index: 2; display: flex; flex-direction: column; min-width: 170px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); padding: 4px; }
.chat-menu a, .chat-menu button { display: block; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--r-md); background: none; color: var(--text); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.chat-menu a:hover, .chat-menu button:hover { background: var(--line); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.chat-pad { margin: 0; }
.chat-msg { display: flex; align-items: flex-end; gap: 6px; max-width: 85%; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble { padding: 7px 11px; border-radius: var(--r-lg); background: var(--panel2); font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; white-space: normal; }
.chat-msg.mine .chat-bubble { background: var(--accent2); color: var(--on-accent); }
.chat-rep { font-size: 11px; color: var(--muted); opacity: 0; transition: opacity .15s; }
.chat-msg:hover .chat-rep, .chat-rep:focus { opacity: 1; }
.chat-seen { align-self: flex-end; font-size: 11px; }
.chat-hello { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.chat-form { display: flex; align-items: flex-end; gap: 6px; padding: 8px; border-top: 1px solid var(--line); flex: none; }
.chat-form textarea { flex: 1; min-width: 0; resize: none; max-height: 96px; padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-size: 14px; line-height: 1.3; }
.chat-send { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }
.chat-send:hover { background: var(--panel2); }
.chat-cant { margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); }

/* stream + party pages: no Friends bar (it would cover Twitch chat's input), one chat over the chat column, never the player */
.dock-stream .fdock { display: none; }
.dock-stream .chat-dock { right: 16px; max-width: calc(100vw - 32px); }
.dock-stream .chat-pop:nth-child(n+2) { display: none; }

/* narrow desktop: fewer pop-ups fit, keep the newest */
@media (max-width: 1100px) and (min-width: 761px) { .chat-pop:nth-child(n+3) { display: none; } }
@media (max-width: 900px) and (min-width: 761px) { .chat-pop:nth-child(n+2) { display: none; } }

/* ---- phones: no Friends widget (friends live in the Messages dropdown), one chat as a bottom sheet ---- */
@media (max-width: 760px) {
  .fdock { display: none; }
  .msg-btn { width: 34px; height: 34px; }
  .msg-panel { position: fixed; left: 8px; right: 8px; width: auto; top: 56px; max-height: calc(100vh - 140px); }
  .chat-dock { left: 0; right: 0; max-width: none; bottom: calc(58px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 0; }
  .chat-pop { width: 100%; height: min(70vh, 520px); border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .chat-pop.min { width: auto; margin-left: auto; margin-right: 10px; max-width: 70vw; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .chat-pop:nth-child(n+2) { display: none; }
  .chat-rep { opacity: 1; }
}

/* ---- Streamer Card action row (src/cards.js) ---- */
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }
.card-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.card-actions .btn.primary:first-child { background: var(--accent-card, var(--accent)); border-color: transparent; color: #111; }
.card-more { position: relative; }
.card-more-btn { min-width: 40px; justify-content: center; font-weight: 600; letter-spacing: 1px; }
.card-more-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 170px; display: flex; flex-direction: column; padding: 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.card-more-menu button, .card-more-menu a { text-align: left; padding: 8px 10px; border: 0; border-radius: var(--r-md); background: none; color: var(--text); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.card-more-menu button:hover, .card-more-menu a:hover { background: var(--line); }
@media (max-width: 760px) { .card-more-menu { left: auto; right: 0; } .card-actions .btn { padding-left: 12px; padding-right: 12px; } }

/* Squads on the card side */
.side-squad { display: flex; gap: 10px; align-items: center; padding: 8px; margin: 0 -8px; border-radius: var(--r-lg); color: var(--text); text-decoration: none; }
.side-squad:hover { background: var(--panel2); }
.ssq-icon { width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: var(--r-md); background: var(--panel2); font-weight: 600; }
.ssq-body { display: flex; flex-direction: column; min-width: 0; }
.ssq-body .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* collab request window */
.dk-collab { text-align: left; }
.dk-collab textarea { width: 100%; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; resize: vertical; }
.dk-collab-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Phones (owner, Nov 2026: chat tabs "start leaning to the right"): a minimized chat is one full width bar right above the
   bottom tab bar, name on the left, buttons on the right; open chats are the usual bottom sheet. */
@media (max-width: 760px) {
  .chat-dock { padding: 0; }
  .chat-pop.min { width: 100%; max-width: none; margin: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; border-left: 0; border-right: 0; }
  .chat-pop.min .chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 0 8px 0 14px; }
  .chat-pop .chat-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
