/* Chats between collectors and the trades proposed in them. */

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.chat-sidebar { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.chat-new { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.chat-new select { width: 100%; }
.chat-list-note { margin: 8px 0; }

.chat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; overflow-y: auto; max-height: 620px; }
.chat-list-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 14px; border: 1px solid transparent; color: inherit; text-decoration: none; background: var(--surface-muted); }
.chat-list-item:hover { border-color: var(--border); }
.chat-list-item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.chat-list-item.has-unread .chat-list-preview { color: var(--text); font-weight: 700; }
.chat-avatar { position: relative; flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-family: var(--heading-font); font-weight: 700; font-size: 17px; color: #fff; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); }
.chat-online { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--border); }
.chat-online.is-online { background: var(--good); }
.chat-list-text { display: grid; min-width: 0; flex: 1; }
.chat-list-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-list-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-top time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.chat-list-preview { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }


.chat-thread { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0; }
.chat-thread-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.chat-status { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 12px; min-width: 0; }
.chat-online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.chat-online-dot.is-online { background: var(--good); }
.chat-vault-link, .chat-trade-button { font-weight: 700; text-decoration: none; white-space: nowrap; }

.chat-messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.chat-older { align-self: center; }
.chat-message { display: grid; gap: 3px; max-width: 85%; }
.chat-message.is-mine { align-self: flex-end; justify-items: end; }
.chat-message.is-theirs { align-self: flex-start; justify-items: start; }
.chat-bubble { padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.chat-message.is-theirs .chat-bubble { background: var(--surface-muted); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chat-message.is-mine .chat-bubble { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: #fff; border-bottom-right-radius: 5px; }
.chat-time { font-size: 11px; color: var(--text-muted); padding: 0 4px; }

.chat-composer { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 10px; }
.chat-composer textarea { flex: 1; min-width: 0; resize: vertical; min-height: 44px; max-height: 200px; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; }
.chat-composer textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-composer-side { display: grid; gap: 4px; justify-items: end; }
.chat-count { font-size: 11px; }
.chat-count.is-near { color: var(--danger); font-weight: 700; }

/* ---------- Trades in the chat ---------- */

.trade-card { width: min(520px, 100%); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 16px; padding: 12px 14px; background: var(--surface); box-shadow: var(--shadow); display: grid; gap: 10px; }
.trade-card.trade-accepted { border-left-color: var(--good); }
.trade-card.trade-declined, .trade-card.trade-cancelled { border-left-color: var(--border); opacity: .8; }
.trade-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.trade-status { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); }
.trade-status-accepted { background: var(--good-soft); color: var(--good); }
.trade-status-declined { background: var(--danger-soft); color: var(--danger); }
.trade-status-cancelled { background: var(--surface-muted); color: var(--text-muted); }
.trade-sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: start; }
.trade-arrow { align-self: center; font-size: 20px; color: var(--text-muted); }
.trade-side h4 { margin: 0 0 6px; font-size: 13px; }
.trade-side > p { margin: 0; font-size: 13px; }
.trade-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.trade-items li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.trade-face.card-face, .trade-face.pack-face { width: 32px; flex: none; }
.trade-item-text { display: grid; min-width: 0; flex: 1; }
.trade-item-text strong, .trade-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-item-text .muted { font-size: 11px; }
.trade-card-name { color: inherit; font-weight: 700; text-decoration: underline dotted; text-underline-offset: 3px; cursor: zoom-in; }
.trade-quantity { font-weight: 800; white-space: nowrap; }
.trade-money { font-size: 14px; }
.trade-money-icon { width: 32px; text-align: center; font-size: 20px; }
.trade-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.trade-card-actions .muted { flex: 1; min-width: 160px; font-size: 12px; }

/* ---------- Putting a trade together ---------- */

.trade-composer { width: min(860px, calc(100vw - 32px)); }
.trade-composer h2 { margin: 0 32px 4px 0; }
.trade-composer-intro { margin: 0 0 12px; font-size: 13px; }
.trade-composer-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.trade-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-muted); }
.trade-picker h3 { margin: 0; }
.trade-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.trade-lines li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.trade-line-name { flex: 1; min-width: 0; display: grid; font-weight: 700; font-size: 13px; }
.trade-line-name .muted { font-weight: 500; font-size: 11px; }
.trade-line-quantity input { width: 64px; }
.trade-money-input { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.trade-money-input input { width: 110px; }
.trade-hint { margin: -4px 0 0; font-size: 12px; }
.trade-search { width: 100%; }
.trade-choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.trade-choices-empty { padding: 8px; font-size: 13px; }
.trade-choice { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; text-align: left; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: inherit; cursor: pointer; font: inherit; }
.trade-choice:hover:not(:disabled) { border-color: var(--accent); }
.trade-choice:disabled { opacity: .55; cursor: default; }
.trade-choice-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-choice-detail { grid-column: 1; font-size: 11px; }
.trade-choice-add { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 800; color: var(--accent-strong); font-size: 18px; }

@media (max-width: 720px) {
  .trade-sides { grid-template-columns: minmax(0, 1fr); }
  .trade-arrow { justify-self: center; transform: rotate(90deg); }
  .trade-composer-sides { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- The chat bubble and its window (bottom right, like Messenger) ---------- */

.chat-launcher { position: fixed; right: 20px; bottom: 20px; z-index: 55; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; font-size: 26px; color: #fff; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); box-shadow: 0 8px 24px rgba(107, 63, 209, .45); transition: transform .15s ease; }
.chat-launcher:hover { transform: translateY(-2px) scale(1.04); }
.chat-launcher.is-open { font-size: 20px; }
.chat-launcher-badge { position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); animation: bump .5s ease; }

.chat-window { position: fixed; right: 20px; bottom: 90px; z-index: 55; width: min(370px, calc(100vw - 24px)); height: min(540px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 18px 48px rgba(0, 0, 0, .35); overflow: hidden; animation: chat-window-in .18s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes chat-window-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.chat-window-header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; color: #fff; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); }
.chat-window-title { flex: 1; min-width: 0; font-family: var(--heading-font); font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-window-icon { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.chat-window-icon:hover { background: rgba(255, 255, 255, .28); }
.chat-avatar-small { width: 30px; height: 30px; font-size: 14px; background: rgba(255, 255, 255, .22); }
.chat-window-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px 12px; overflow-y: auto; }
.chat-window-body .chat-thread { overflow: hidden; }
.chat-window-body .chat-list { max-height: none; }
.chat-list-item { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.chat-composer textarea { resize: none; min-height: 40px; max-height: 120px; }
.chat-window .trade-card { box-shadow: none; padding: 10px; }
.chat-window .trade-sides { grid-template-columns: minmax(0, 1fr); }
.chat-window .trade-arrow { justify-self: center; transform: rotate(90deg); }

/* The toasts sit above the chat bubble. */
.toast-stack { bottom: 92px; }

@media (max-width: 720px) {
  .chat-launcher { right: 14px; bottom: 14px; width: 52px; height: 52px; font-size: 23px; }
  .chat-window { right: 8px; left: 8px; bottom: 76px; width: auto; height: calc(100vh - 140px); height: calc(100dvh - 140px); }
  .toast-stack { bottom: 78px; }
}
.version-footer { padding-bottom: 88px; } /* Room for the chat bubble. */
