/* ════════════════════════════════════════════════════════════════════
   chat.css — nav toggle button + a real side PANEL that pushes the page
   (not an overlay). `body.chat-open` drives both the panel and the page shift.
   ════════════════════════════════════════════════════════════════════ */
:root { --chat-w: 340px; }

/* ── nav toggle button (styled like the other nav icon-buttons) ── */
.chat-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.chat-btn svg { width: 18px; height: 18px; display: block; }
.chat-btn.active { color: var(--cyan, #28e0ff); border-color: var(--cyan, #28e0ff); }
.chat-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #fff; font-family: var(--f-mono);
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--dark);
}

/* ── side panel + page push ── */
#app { transition: padding-right 0.25s cubic-bezier(0.22,1,0.36,1); }
body.chat-open #app { padding-right: var(--chat-w); }
body.chat-open .toast-container { right: calc(var(--chat-w) + 20px); }

#chat-panel {
  position: fixed; top: 0; right: 0; z-index: 60;
  width: var(--chat-w); height: 100dvh; height: 100vh;
  background: var(--card); border-left: 1px solid var(--border2);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.22,1,0.36,1);
}
body.chat-open #chat-panel { transform: none; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.chat-title { font-size: 15px; font-weight: 700; }
.chat-sub { font-size: 11px; color: var(--text3); margin-top: 2px; font-family: var(--f-mono); }
.chat-close {
  background: none; border: none; color: var(--text3); font-size: 18px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; transition: all 0.15s;
}
.chat-close:hover { color: var(--text); background: var(--card2); }

.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty { color: var(--text3); font-size: 13px; text-align: center; margin: auto 0; }
.chat-msg { max-width: 85%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-meta { font-size: 10px; color: var(--text3); margin-bottom: 3px; display: flex; align-items: baseline; gap: 6px; }
.chat-msg.mine .chat-meta { justify-content: flex-end; }
.chat-from {
  position: relative;
  font-family: var(--f-mono); font-size: 13px; font-weight: 600;
  color: var(--text2); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; transition: color 0.12s;
}
.chat-from[data-uid]:hover { color: var(--cyan, #28e0ff); }
/* invisible buffer so the profile preview appears even when the cursor is a bit
   to the SIDE of the name (no need to be pixel-perfect on the text). Positioned
   absolutely → it enlarges the hover hit-area without shifting any layout, and
   mouse events over a pseudo-element target its host (.chat-from), so the
   existing event-delegated hover in chat.js keeps working unchanged. */
.chat-from[data-uid]::after { content: ''; position: absolute; inset: -5px -14px; }
.chat-time { opacity: 0.7; }
.chat-text {
  display: inline-block; background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.4;
  word-break: break-word; text-align: left;
}
.chat-msg.mine .chat-text { background: rgba(40,224,255,0.12); border-color: rgba(40,224,255,0.35); }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input {
  flex: 1; background: var(--dark2); border: 1px solid var(--border2); border-radius: 12px;
  color: var(--text); font-family: var(--f-body); font-size: 13px; padding: 10px 12px;
}
.chat-input:focus { outline: none; border-color: var(--cyan, #28e0ff); }
.chat-send {
  width: 42px; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan, #28e0ff), #1b9fd6); color: #06121f; font-size: 16px; font-weight: 700;
  transition: transform 0.15s, filter 0.15s;
}
.chat-send:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* mobile: overlay full-width (no page push — too narrow) */
@media (max-width: 700px) {
  body.chat-open #app { padding-right: 0; }
  body.chat-open .toast-container { right: 12px; }
  #chat-panel { width: 100vw; z-index: 300; }
}
