:root {
  --danger: #ef4444;
  --success: #22c55e;
}

/* ── Shadows / Effects ── */
.shadow-dot { box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.success-bg { background: var(--success); }
.disconnected-bg { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }

/* ── Room tabs ── */
.room-btn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: #6b7280; padding: 11px 16px; cursor: pointer;
  font-size: 14px; font-weight: 500; border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: -0.01em; position: relative; white-space: nowrap;
}
.room-btn:hover { color: #1a1a2e; }
.room-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }
.room-btn.dm-room { color: #4f46e5; }

/* ── Messages ── */
#messages:empty::after {
  content: 'No messages yet. Say hello!';
  display: block; text-align: center; color: #9ca3af;
  font-size: 14px; margin-top: 40vh;
}
#messages li {
  padding: 8px 12px; border-radius: 10px; max-width: 75%;
  word-wrap: break-word; font-size: 15px; line-height: 1.45;
  animation: msgIn 0.2s ease; position: relative;
}
#messages li.me {
  background: #4f46e5; color: #fff; align-self: flex-end;
  border-bottom-right-radius: 4px; box-shadow: 0 1px 3px rgba(79,70,229,0.3);
}
#messages li.other {
  background: #fff; color: #1a1a2e; align-self: flex-start;
  border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
#messages li.system {
  background: transparent; color: #9ca3af; align-self: center;
  font-size: 12px; font-weight: 500; animation: none;
  padding: 3px 12px; border-radius: 10px; background: rgba(0,0,0,0.04);
}
#messages li .sender { font-size: 12px; font-weight: 600; opacity: 0.85; display: block; margin-bottom: 2px; letter-spacing: -0.01em; }
#messages li.other .sender { color: #4f46e5; }
#messages li .time { font-size: 11px; opacity: 0.55; display: block; margin-top: 3px; text-align: right; }
#messages li .body { white-space: pre-wrap; }
#messages::-webkit-scrollbar { width: 5px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }
#messages::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ── File Attachments ── */
.file-attach { margin-top: 6px; }
.thumb { max-width: 200px; max-height: 220px; border-radius: 6px; cursor: zoom-in; display: block; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: transform 0.15s; }
.thumb:hover { transform: scale(1.02); }
.thumb.full { max-width: 100%; max-height: none; cursor: zoom-out; transform: none; }
.file-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 6px; color: inherit; text-decoration: none; font-size: 13px; background: rgba(0,0,0,0.05); transition: background 0.15s; }
.file-link:hover { background: rgba(0,0,0,0.08); }
#messages li.me .file-link { background: rgba(255,255,255,0.15); }
#messages li.me .file-link:hover { background: rgba(255,255,255,0.22); }
.fsize { font-size: 11px; opacity: 0.6; margin-left: 2px; }

/* ── Mute Button ── */
.mute-btn { background: none; border: none; color: #e0e0e0; cursor: pointer; font-size: 16px; padding: 0 4px; border-radius: 6px; transition: background 0.15s; }
.mute-btn:hover { background: rgba(255,255,255,0.1); }

/* ── Drag-drop overlay ── */
.drop-active #chatScreen { opacity: 0.7; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: #1a1a2e; color: #e0e0e0; padding: 10px 20px;
  border-radius: 10px; font-size: 13px; font-weight: 500; z-index: 100;
  opacity: 0; transition: all 0.25s ease; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }

/* ── Online Dot ── */
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.offline-dot { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }

/* ── Message Actions / Emoji Picker ── */
#messages li { position: relative; }
#messages li .msg-actions { display: none; position: absolute; top: -12px; right: 4px; z-index: 5; }
#messages li.me .msg-actions { right: auto; left: 4px; }
#messages li.other .msg-actions { left: 4px; }
#messages li:hover .msg-actions { display: block; }
.react-add {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 1px 6px; font-size: 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: transform 0.1s;
}
.react-add:hover { transform: scale(1.15); background: #e0e7ff; }
#emojiPicker {
  position: fixed; z-index: 50; background: #fff;
  border: 1px solid #e5e7eb; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px; gap: 2px; flex-wrap: wrap; max-width: 228px;
}
.emoji-btn { background: none; border: none; border-radius: 6px; font-size: 22px; padding: 4px 6px; cursor: pointer; transition: background 0.1s; }
.emoji-btn:hover { background: #e0e7ff; transform: scale(1.2); }

/* ── Reaction Pills ── */
.reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.react-pill { display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: rgba(0,0,0,0.06); border: 1px solid transparent; cursor: pointer; transition: background 0.15s, border-color 0.15s; user-select: none; }
.react-pill:hover { background: #e0e7ff; border-color: #4f46e5; }
.react-pill.active { background: #e0e7ff; border-color: #4f46e5; font-weight: 600; }
#messages li.me .react-pill { background: rgba(255,255,255,0.2); }
#messages li.me .react-pill.active { background: rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.6); }

/* ── Search Toggle ── */
.search-toggle { border: none; }
.search-toggle:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(79,70,229,0.4); }

/* ── Search Results ── */
.search-empty { padding: 24px; text-align: center; color: #9ca3af; font-size: 14px; }
.search-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 10px 16px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid #e5e7eb; }
.search-result:hover { background: #edeef2; }
.search-result:last-child { border-bottom: none; }
.search-room { font-size: 11px; font-weight: 600; color: #4f46e5; background: #e0e7ff; padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.search-sender { font-size: 11px; font-weight: 600; color: #6b7280; flex-shrink: 0; }
.search-time { font-size: 10px; color: #9ca3af; flex-shrink: 0; margin-left: auto; }
.search-body { font-size: 13px; color: #1a1a2e; width: 100%; line-height: 1.4; }
.search-body b { color: #4f46e5; background: #e0e7ff; padding: 0 1px; border-radius: 2px; }
@keyframes searchPulse { 0%,100%{box-shadow:0 0 0 0 rgba(79,70,229,0.4)} 50%{box-shadow:0 0 0 6px rgba(79,70,229,0)} }
.search-highlight { animation: searchPulse 0.8s ease 3; }

/* ── Sidebar Accordion ── */
.sidebar-section { display: flex; flex-direction: column; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; user-select: none; transition: background 0.1s; flex-shrink: 0; }
.sidebar-section-header:hover { background: #edeef2; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; }
.section-count { font-size: 10px; color: #9ca3af; }
.accordion-arrow { font-size: 10px; color: #9ca3af; margin-left: auto; }
.sidebar-section-body { padding-bottom: 4px; overflow-y: auto; }
.icon-btn { background: none; border: none; border-radius: 6px; color: #4f46e5; cursor: pointer; font-size: 16px; font-weight: 700; padding: 2px 6px; margin-left: auto; line-height: 1; }
.icon-btn:hover { background: #e0e7ff; }

/* ── DM Sidebar ── */
#dmSearchResults { display: none; position: absolute; top: 72px; left: 8px; right: 8px; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); z-index: 10; max-height: 200px; overflow-y: auto; }
.search-result { padding: 8px 12px; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.search-result:hover { background: #e0e7ff; }
.dm-convo { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; cursor: pointer; transition: background 0.15s; gap: 6px; }
.dm-convo:hover { background: #edeef2; }
.dm-convo.has-new { background: #e0e7ff; }
.dm-convo-name { font-size: 14px; color: #1a1a2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dm-convo-time { font-size: 10px; color: #9ca3af; flex-shrink: 0; }
.dm-convo-badge { font-size: 10px; font-weight: 600; color: #4f46e5; background: #e0e7ff; padding: 1px 6px; border-radius: 8px; flex-shrink: 0; }

/* ── All Users List ── */
.sidebar-divider { padding: 6px 12px 2px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #9ca3af; border-top: 1px solid #e5e7eb; margin-top: 4px; }
#allUsersList { padding: 2px 0; max-height: 50%; overflow-y: auto; }
.all-user-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; transition: background 0.1s; }
.all-user-item:hover { background: #edeef2; }
.all-user-name { font-size: 14px; color: #1a1a2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Mentions ── */
.mention { color: #4f46e5; background: #e0e7ff; border-radius: 3px; padding: 1px 4px; cursor: pointer; font-weight: 500; transition: background 0.15s; }
.mention:hover { background: #4f46e5; color: #fff; }
.mention-me { background: #4f46e5; color: #fff; }

/* ── Ticket List ── */
.ticket-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #e5e7eb; transition: background 0.1s; }
.ticket-item:hover { background: #edeef2; }
.ticket-item.is-closed { opacity: 0.5; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.status-new { background: #3b82f6; }
.status-dot.status-work { background: #22c55e; }
.status-dot.status-waiting { background: #f59e0b; }
.status-dot.status-closed { background: #94a3b8; }
.ti-subject { flex: 1; font-size: 13px; color: #1a1a2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-assigned { font-size: 11px; color: #9ca3af; flex-shrink: 0; }

/* ── Ticket Panel ── */
.ticket-panel { border-top: 1px solid #e5e7eb; padding: 12px; flex-shrink: 0; }
.ticket-panel > div { margin-bottom: 6px; font-size: 13px; }
.ticket-status { font-weight: 500; }
.status-badge { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; }
.status-badge.status-new { background: #dbeafe; color: #1d4ed8; }
.status-badge.status-work { background: #dcfce7; color: #16a34a; }
.status-badge.status-waiting { background: #fef3c7; color: #d97706; }
.status-badge.status-closed { background: #f1f5f9; color: #64748b; }
.ticket-meta { color: #6b7280; }
.ticket-tags { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.tag-pill { display: inline-block; padding: 1px 7px; border-radius: 8px; font-size: 10px; font-weight: 500; background: #e0e7ff; color: #4f46e5; }
.ticket-desc { font-size: 13px; color: #6b7280; line-height: 1.4; margin: 6px 0; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow-y: auto; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.action-btn { font-size: 11px; padding: 3px 10px; border-radius: 6px; border: 1px solid #e5e7eb; background: #fff; cursor: pointer; color: #1a1a2e; transition: all 0.1s; }
.action-btn:hover { background: #e0e7ff; border-color: #4f46e5; }
.take-btn { background: #dcfce7; border-color: #16a34a; color: #16a34a; }
.close-btn { background: #fee2e2; border-color: #ef4444; color: #ef4444; }
.hold-btn { background: #fef3c7; border-color: #d97706; color: #d97706; }

/* ── Ticket Modal ── */
.ticket-modal { position: fixed; inset: 0; z-index: 70; }
.ticket-modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.3); }
.ticket-modal-box { position: absolute; top: 25%; left: 50%; transform: translate(-50%,-25%); background: #fff; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 24px; width: 340px; max-width: 92vw; }
.ticket-modal-box h3 { margin-bottom: 16px; font-size: 16px; }
.ticket-modal-box input, .ticket-modal-box select, .ticket-modal-box textarea { width: 100%; border: 1.5px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; outline: none; box-sizing: border-box; font-family: inherit; }
.ticket-modal-box select { background: #fff; }
.ticket-modal-box textarea { resize: vertical; }
.ticket-modal-box input:focus, .ticket-modal-box select:focus, .ticket-modal-box textarea:focus { border-color: #4f46e5; }
.ticket-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.ticket-modal-actions button { padding: 8px 16px; font-size: 13px; border-radius: 6px; border: 1px solid #e5e7eb; background: #fff; cursor: pointer; }
.ticket-modal-actions button.primary { background: #4f46e5; color: #fff; border-color: #4f46e5; }

/* ── Reply / Quote ── */
.reply-btn { font-size: 12px; padding: 1px 6px; }
.reply-quote {
  font-size: 11px;
  margin-top: 4px;
  padding: 4px 8px;
  border-left: 3px solid #4f46e5;
  background: rgba(0,0,0,0.04);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 100%;
  overflow: hidden;
  transition: background 0.1s;
}
.reply-quote:hover { background: rgba(0,0,0,0.07); }
.reply-quote-sender { font-weight: 600; color: #4f46e5; }
.reply-quote-text { color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#messages li.me .reply-quote { background: rgba(255,255,255,0.15); border-left-color: rgba(255,255,255,0.6); }
#messages li.me .reply-quote:hover { background: rgba(255,255,255,0.2); }
#messages li.me .reply-quote-sender { color: rgba(255,255,255,0.9); }
#messages li.me .reply-quote-text { color: rgba(255,255,255,0.7); }

/* ── Reply Preview ── */
#replyPreview { border-top: 1px solid rgba(79,70,229,0.3); }
#quickReplies { display: flex; gap: 4px; padding: 4px 12px; flex-shrink: 0; overflow-x: auto; border-top: 1px solid #e5e7eb; background: #fff; }
.qr-btn { font-size: 11px; padding: 3px 10px; border-radius: 12px; border: 1px solid #e5e7eb; background: #fff; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all 0.1s; }
.qr-btn:hover { background: #e0e7ff; border-color: #4f46e5; }

/* ── Assign Results ── */
#assignResults { max-height: 150px; overflow-y: auto; margin-bottom: 8px; }

/* ── Typing indicator ── */
.typing-dots { color: #4f46e5; font-size: 11px; animation: blink 1s infinite; }

/* ── User entry ── */
.user-entry { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 14px; color: #1a1a2e; }
.user-entry.typing .user-name { color: #4f46e5; font-weight: 500; }
.user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Animations ── */
@keyframes msgIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.animate-slideUp { animation: slideUp 0.3s ease; }

/* ── Connection status dot ── */
#statusDot.disconnected { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }
