/* The Inbox (client/js/inbox.js) and polls (client/js/polls.js). Uses the theme tokens from styles.css. */

/* --- the Inbox button: at the right end of the channel header, after the search box --- */
.chat > .inbox-button { position: absolute; top: 8px; right: 12px; z-index: 6; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.chat > .inbox-button[hidden] { display: none; }
.chat > .inbox-button:hover .icon, .chat > .inbox-button.has-unread .icon { color: var(--text); }
.chat:has(> .inbox-button:not([hidden])) > .channel-search { right: 52px; }
.chat:has(> .inbox-button:not([hidden])) > .chat-header { padding-right: 56px; }
.chat:has(> .inbox-button:not([hidden])):has(> .channel-search:not([hidden])) > .chat-header { padding-right: 240px; }
.inbox-badge { position: absolute; right: -2px; bottom: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 3px var(--bg-chat); pointer-events: none; }
@media (max-width: 1000px) {
  .chat:has(> .inbox-button:not([hidden])):has(> .channel-search:not([hidden])) > .chat-header { padding-right: 212px; }
}

/* --- the Inbox popout --- */
.inbox-popout { width: min(480px, calc(100vw - 32px)); height: min(72vh, 640px); height: min(72dvh, 640px); display: flex; flex-direction: column; background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inbox-header { flex: none; background: var(--bg-rail); padding: 12px 16px 0; }
.inbox-title { display: flex; align-items: center; gap: 8px; color: var(--text-strong); }
.inbox-title h3 { margin: 0; font-size: 16px; flex: 1; }
.inbox-title > .icon { color: var(--text-strong); }
.inbox-filter-button { display: grid; place-items: center; }
.inbox-tabs { display: flex; gap: 16px; margin-top: 10px; }
.inbox-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 0 8px; color: var(--text-muted); font-weight: 600; }
.inbox-tab.selected { color: var(--text-strong); border-bottom-color: var(--accent); }
.inbox-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.inbox-item { background: var(--bg-chat); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px 10px; }
.inbox-where { display: flex; align-items: baseline; gap: 2px; margin-bottom: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-channel { font-weight: 700; color: var(--text-strong); font-size: 13px; }
.inbox-message { position: relative; display: flex; gap: 12px; align-items: flex-start; }
.inbox-body { flex: 1; min-width: 0; }
.inbox-meta { display: flex; align-items: baseline; gap: 8px; }
.inbox-meta .author { font-weight: 600; color: var(--text-strong); }
.inbox-body .content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.375; max-height: 9em; overflow: hidden; }
.inbox-extra { margin-top: 2px; }
.inbox-controls { position: absolute; right: -4px; top: -2px; display: none; gap: 4px; }
.inbox-item:hover .inbox-controls, .inbox-item:focus-within .inbox-controls { display: flex; }
.inbox-jump { padding: 2px 8px; font-size: 12px; border-radius: 4px; background: var(--bg-active); color: var(--text); border: 0; }
.inbox-jump:hover { background: var(--accent); color: #fff; }
.inbox-dismiss { background: var(--bg-active); border: 0; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; color: var(--text-muted); padding: 0; }
.inbox-dismiss:hover { color: var(--danger); }
.inbox-empty { margin: auto; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; gap: 2px; color: var(--text-muted); }
.inbox-empty > .icon { opacity: 0.6; margin-bottom: 8px; }
.inbox-empty p { margin: 2px 0; }
.inbox-loading, .inbox-error { text-align: center; padding: 8px; }

/* --- the poll card in a message --- */
.poll { margin-top: 4px; max-width: 440px; background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; }
.poll-question { font-weight: 700; color: var(--text-strong); font-size: 16px; overflow-wrap: anywhere; }
.poll-prompt { margin: 2px 0 10px; }
.poll-answers { display: flex; flex-direction: column; gap: 6px; }
.poll-answer { position: relative; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border-radius: 6px; background: var(--bg-input); border: 1px solid transparent; color: var(--text); text-align: left; overflow: hidden; }
.poll-answer.choice { cursor: pointer; }
.poll-answer.choice:hover { border-color: var(--text-muted); }
.poll-answer.choice:disabled { cursor: default; opacity: 0.7; }
.poll-answer.choice:disabled:hover { border-color: transparent; }
.poll-answer.choice.selected { border-color: var(--accent); background: rgba(91, 108, 240, 0.18); }
.poll-answer-text { position: relative; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-emoji { position: relative; flex: none; font-size: 18px; line-height: 1; }
img.poll-emoji { object-fit: contain; }
.poll-check { position: relative; flex: none; width: 18px; height: 18px; display: grid; place-items: center; border: 2px solid var(--text-muted); color: #fff; }
.poll-check.radio { border-radius: 50%; }
.poll-check.box { border-radius: 4px; }
.poll-answer.selected .poll-check { background: var(--accent); border-color: var(--accent); }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bg-active); border-radius: 6px 0 0 6px; transition: width 0.3s; }
.poll-answer.mine { border-color: var(--accent); }
.poll-answer.mine .poll-bar { background: rgba(91, 108, 240, 0.35); }
.poll-answer.winner .poll-answer-text { font-weight: 700; color: var(--text-strong); }
.poll-mine { position: relative; display: grid; place-items: center; color: var(--accent); }
.poll-votes { position: relative; background: none; border: 0; padding: 0; color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.poll-votes:hover { color: var(--text); text-decoration: underline; }
.poll-pct { position: relative; font-weight: 700; color: var(--text-strong); min-width: 38px; text-align: right; }
.poll-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.poll-buttons { display: flex; align-items: center; gap: 12px; }
.poll-link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 600; font-size: 13px; }
.poll-link:hover { text-decoration: underline; }
.poll-vote { padding: 6px 18px; }
.poll-vote:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- the "poll has closed" line (message type 46) --- */
.poll-result-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.poll-outcome { display: flex; align-items: center; gap: 12px; max-width: 440px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-sidebar); }
.poll-outcome-text { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--text); overflow-wrap: anywhere; }
.poll-outcome-text strong { color: var(--text-strong); }
.poll-view { padding: 4px 10px; font-size: 12px; border-radius: 4px; background: var(--bg-active); color: var(--text); border: 0; }
.poll-view:hover { background: var(--accent); color: #fff; }

/* --- Create a Poll --- */
.modal.poll-create { width: min(520px, 94vw); position: relative; overflow: visible; }
.poll-create-form { display: flex; flex-direction: column; gap: 6px; }
.poll-field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.poll-create .poll-question-input, .poll-create .poll-answer-input { background: var(--bg-rail); }
.poll-create-answers { display: flex; flex-direction: column; gap: 6px; }
.poll-create-answer { display: flex; align-items: center; gap: 6px; }
.poll-create .poll-create-answer .poll-answer-input { flex: 1; width: auto; }
.poll-answer-emoji { flex: none; width: 38px; height: 38px; display: grid; place-items: center; background: var(--bg-rail); border: 0; border-radius: 4px; color: var(--text-muted); font-size: 20px; padding: 0; }
.poll-answer-emoji:hover { color: var(--text); }
.poll-answer-emoji img { width: 22px; height: 22px; }
.poll-answer-remove { flex: none; background: none; border: 0; color: var(--text-muted); padding: 6px; border-radius: 4px; display: grid; place-items: center; }
.poll-answer-remove:hover { color: var(--danger); background: var(--bg-hover); }
.poll-add-answer { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px dashed var(--bg-active); border-radius: 4px; padding: 8px 12px; color: var(--text); }
.poll-add-answer:hover { border-color: var(--text-muted); }
.poll-create-options { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.poll-duration-label { flex-direction: column; align-items: flex-start; gap: 6px; }
.poll-duration { font: inherit; font-size: 14px; text-transform: none; font-weight: 400; color: var(--text); background: var(--bg-rail); border: 0; border-radius: 4px; padding: 8px 10px; }
.poll-multi-label { display: flex; align-items: center; gap: 8px; cursor: pointer; padding-bottom: 8px; }
.modal .poll-multi-label input { width: auto; margin: 0; }
.poll-emoji-layer { position: absolute; z-index: 5; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5)); }

/* --- who voted for an answer --- */
.modal.poll-voters-modal { width: min(560px, 94vw); }
.poll-voters-modal h2 { overflow-wrap: anywhere; }
.poll-voters-body { display: grid; grid-template-columns: minmax(140px, 40%) 1fr; gap: 12px; min-height: 200px; max-height: 60vh; max-height: 60dvh; }
.poll-voters-answers { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.poll-voters-answer { display: flex; align-items: center; gap: 6px; text-align: left; background: none; border: 0; border-radius: 4px; padding: 8px; color: var(--text-muted); }
.poll-voters-answer-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-voters-answer:hover { background: var(--bg-hover); color: var(--text); }
.poll-voters-answer.selected { background: var(--bg-active); color: var(--text-strong); }
.poll-voters-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.poll-voter { display: flex; align-items: center; gap: 10px; padding: 4px; }
.poll-voter-name { font-weight: 600; color: var(--text-strong); }
.poll-voters-none { padding: 8px; }
