/* ========================================
 * COMUNICACIÓ — Estils xat intern
 * Fase 3b: Layout redesign (9 mar 2026)
 * ======================================== */

/* ── Container principal ── */
.chat-container {
  display: flex;
  height: calc(100vh - 52px);
  height: calc(100dvh - 52px); /* Dynamic viewport per mòbil */
  overflow: hidden;
}

/* ── Sidebar canals ── */
.chat-sidebar {
  width: 360px;
  min-width: 360px;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
}

.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-sidebar-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.chat-sidebar-header .btn-sm {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 20px;
}

.chat-canals-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  -webkit-overflow-scrolling: touch;
}

/* ── Tabs navegació canals ── */
.chat-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  padding: 4px 4px 0;
  gap: 2px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--color-bg-primary);
  z-index: 2;
}

.chat-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 2px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  color: var(--color-text-tertiary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  position: relative;
  border-radius: 0;
}

.chat-tab .material-symbols-outlined {
  font-size: 16px;
  flex-shrink: 0;
  display: none;
}

/* Mòbil: mostrar icones (hi ha més espai amb 100% width) */
@media (max-width: 1023px) {
  .chat-tab .material-symbols-outlined {
    display: inline;
  }
}

.chat-tab:hover {
  color: var(--color-text-secondary);
  background: var(--color-bg-hover);
}

.chat-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.chat-tab-label {
  white-space: nowrap;
}

.chat-tab-badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1.3;
}

.chat-tab-content {
  padding-top: 4px;
}

/* ── Tab action button (FCT crear) ── */
.chat-tab-action {
  padding: var(--space-2) var(--space-3);
}

.chat-tab-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  justify-content: center;
}

.chat-tab-action-btn .material-symbols-outlined {
  font-size: 18px;
}

/* ── FCT modal membres ── */
.fct-membres-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.fct-section-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0;
}

.fct-section-label--spaced {
  margin-top: var(--space-2);
}

.fct-membre-rol {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.fct-empty-membres {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
}

/* ── Canal color bar (línia vertical formació) ── */
.chat-canal-color-bar {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Canal item ── */
.chat-canal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}

.chat-canal-item:hover {
  background: var(--color-bg-hover);
}

.chat-canal-item.active {
  background: var(--color-primary-light, rgba(19, 117, 188, 0.1));
}

.chat-canal-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-canal-icon .material-symbols-outlined {
  font-size: 20px;
  color: var(--color-text-secondary);
}

.chat-canal-icon-avatar {
  font-size: 0.8rem;
  font-weight: 700;
}

/* Icona color per tipus especial */
.chat-canal-item[data-tipus="general"] .chat-canal-icon {
  background: rgba(99, 102, 241, 0.12);
}
.chat-canal-item[data-tipus="general"] .chat-canal-icon .material-symbols-outlined {
  color: #6366f1;
}
.chat-canal-item[data-tipus="coordinacio"] .chat-canal-icon {
  background: rgba(99, 102, 241, 0.12);
}
.chat-canal-item[data-tipus="coordinacio"] .chat-canal-icon .material-symbols-outlined {
  color: #6366f1;
}
.chat-canal-item[data-tipus="professors"] .chat-canal-icon {
  background: rgba(245, 158, 11, 0.12);
}
.chat-canal-item[data-tipus="professors"] .chat-canal-icon .material-symbols-outlined {
  color: #f59e0b;
}
.chat-canal-item[data-tipus="grup"] .chat-canal-icon {
  background: rgba(59, 130, 246, 0.12);
}
.chat-canal-item[data-tipus="grup"] .chat-canal-icon .material-symbols-outlined {
  color: #3b82f6;
}
.chat-canal-item[data-tipus="claustro"] .chat-canal-icon {
  background: rgba(139, 92, 246, 0.12);
}
.chat-canal-item[data-tipus="claustro"] .chat-canal-icon .material-symbols-outlined {
  color: #8b5cf6;
}

.chat-canal-info {
  flex: 1;
  min-width: 0;
}

.chat-canal-nom {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-canal-preview {
  font-size: 0.8rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}


.chat-canal-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.chat-canal-time {
  font-size: 0.7rem;
  color: var(--color-text-tertiary);
}

.chat-canal-badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.chat-canal-item.has-unread .chat-canal-nom {
  font-weight: 700;
}

.chat-canal-item.has-unread .chat-canal-preview {
  color: var(--color-text-primary);
  font-weight: 500;
}

/* ── Area principal xat ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg-secondary, var(--color-bg-primary));
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--color-text-tertiary);
}

.chat-empty .material-symbols-outlined {
  font-size: 64px;
  opacity: 0.3;
}

.chat-empty p {
  font-size: 1rem;
}

/* ── Header canal ── */
.chat-main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
  z-index: 5;
}

.chat-back-btn {
  display: none;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  flex-shrink: 0;
}

.chat-back-btn .material-symbols-outlined {
  font-size: 20px;
}

.chat-back-btn:active {
  opacity: 0.7;
}

.chat-main-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-color-bar {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chat-header-text {
  min-width: 0;
}

.chat-main-header-info h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-membres-count {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

.chat-main-header-info {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.chat-main-header-info:hover {
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.04));
}

.chat-header-chevron {
  font-size: 20px;
  color: var(--color-text-tertiary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.chat-main-header-info[aria-expanded="true"] .chat-header-chevron {
  transform: rotate(180deg);
}

/* ── Panel de membres ── */

.chat-membres-panel {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
  overflow: hidden;
}

.chat-membres-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
}

.chat-membres-panel-header .material-symbols-outlined {
  font-size: 18px;
}

.chat-membres-panel-close {
  margin-left: auto;
}

.chat-membres-panel-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 40vh;
}

.chat-membre-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
}

.chat-membre-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.chat-membre-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-membre-nom {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-membre-rol {
  font-size: 0.7rem;
  font-weight: 500;
}

.chat-membre-tutor-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
  .chat-membre-tutor-badge {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
  }
}

/* ── Banner tauló informatiu ── */
.chat-taulon-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-info-bg, rgba(59, 130, 246, 0.08));
  color: var(--color-info-text, #2563eb);
  font-size: 0.8rem;
  font-weight: 500;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.chat-taulon-banner .material-symbols-outlined {
  font-size: 18px;
}

@media (prefers-color-scheme: dark) {
  .chat-taulon-banner {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
  }
}

/* ── Missatges scroll ── */
.chat-missatges {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-missatges-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

/* Empenta missatges al fons */
.chat-missatges-scroll::before {
  content: '';
  flex: 1;
}

/* ── Missatge bubble (Slack flat style) ── */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  padding: 4px 0;
}

.chat-msg.msg-own {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 92%;
}

.chat-msg.msg-other {
  align-self: flex-start;
}

/* DMs: sense avatar, missatges aprofiten més ample */
.chat-main[data-canal-tipus="direct"] .chat-msg.msg-other {
  max-width: 92%;
}

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.chat-msg-avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 0.6rem;
}

/* Avatar inicials a la llista de canals (preview últim missatge) */
.chat-canal-preview-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-right: 5px;
  vertical-align: middle;
}

.chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chat-msg-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Noms clicables → obrir DM */
.chat-dm-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.chat-dm-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.chat-msg-time {
  font-size: 0.7rem;
  color: var(--color-text-tertiary);
}

.chat-msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-own .chat-msg-bubble {
  background: #d0e8ff;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}

.msg-other .chat-msg-bubble {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg-bubble.msg-deleted {
  opacity: 0.5;
  font-style: italic;
}

/* ── Missatge sistema ── */
.chat-msg-sistema {
  text-align: center;
  padding: 8px 16px;
  color: var(--color-text-tertiary);
  font-size: 0.8rem;
  font-style: italic;
}

.chat-msg-sistema-academic {
  background: var(--color-bg-warning-subtle, rgba(245, 158, 11, 0.1));
  border-radius: 8px;
  margin: 4px 16px;
  padding: 10px 16px;
  font-style: normal;
  color: var(--color-text-secondary);
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Seccions canals ── */
.chat-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary);
}
.chat-section-header .material-symbols-outlined {
  font-size: 16px;
}
.chat-section-subheader {
  padding: 6px 16px 2px 28px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: capitalize;
}

/* ── Separador data ── */
.chat-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.chat-date-separator::before,
.chat-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.chat-date-separator span {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

/* ── Load more ── */
.chat-load-more {
  text-align: center;
  padding: 8px;
}

.chat-load-more button {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 12px;
}

.chat-load-more button:hover {
  text-decoration: underline;
}

/* ── Input area ── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  position: relative; /* Per dropdown mencions */
  flex-shrink: 0;
}

.chat-readonly-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-tertiary);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-readonly-banner .material-symbols-outlined {
  font-size: 18px;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 10px 16px;
  /* iOS Safari zoom fix: font-size < 16px triggers auto-zoom on focus */
  font-size: 16px;
  font-family: inherit;
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  max-height: 120px;
  line-height: 1.4;
}

.chat-input-area textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-send .material-symbols-outlined {
  font-size: 20px;
}

/* ── Connexió status ── */
.chat-connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  font-size: 0.75rem;
  background: var(--color-warning-bg, #fef3cd);
  color: var(--color-warning-text, #856404);
}

.chat-connection-status.connected {
  display: none;
}

.chat-connection-status.disconnected {
  background: var(--color-error-bg, #fee2e2);
  color: var(--color-error, #ef4444);
  animation: sseReconnectPulse 2s ease-in-out infinite;
}

@keyframes sseReconnectPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Message wrapper ── */
.chat-msg-wrapper {
  position: relative;
}

/* ── Context menu (Apple HIG) ── */
.chat-context-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  flex-direction: column;
  min-width: 180px;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
  padding: 4px 0;
}

.chat-context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  text-align: left;
  transition: background 0.1s;
}

.chat-context-menu button:hover {
  background: var(--color-bg-hover, #f3f4f6);
}

.chat-context-menu button .material-symbols-outlined {
  font-size: 20px;
  color: var(--color-text-secondary);
}

.chat-context-menu button[data-action="delete"] {
  color: #ef4444;
}
.chat-context-menu button[data-action="delete"] .material-symbols-outlined {
  color: #ef4444;
}

/* ── Reply quote (inline in message) ── */
.chat-reply-quote {
  border-left: 3px solid var(--color-primary, #2563eb);
  background: var(--color-bg-hover, rgba(0,0,0,0.04));
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-reply-quote-author {
  font-weight: 600;
  color: var(--color-primary, #2563eb);
}

.chat-reply-quote-text {
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Compose bar (reply/edit preview above input) ── */
.chat-compose-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg-elevated, #f8f9fa);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-compose-bar-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-compose-bar-icon {
  font-size: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-compose-bar-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-compose-bar-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-primary);
}

.chat-compose-bar-preview {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-compose-bar-close {
  flex-shrink: 0;
}

/* ── Edited label ── */
.chat-msg-edited {
  font-size: 0.7rem;
  color: var(--color-text-tertiary);
  margin-left: 4px;
  font-style: italic;
}

/* ── Message highlight (scroll-to animation) ── */
.chat-msg-highlight {
  animation: msgHighlight 1.5s ease;
}

@keyframes msgHighlight {
  0%, 30% { background: rgba(37, 99, 235, 0.12); }
  100% { background: transparent; }
}

/* ── Reaccions ── */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.chat-reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--color-border, #e0e0e0);
  background: var(--color-surface, #f5f5f5);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}

.chat-reaction:hover {
  background: var(--color-hover, #e8e8e8);
}

.chat-reaction.mine {
  border-color: var(--color-primary, #2563eb);
  background: rgba(37, 99, 235, 0.1);
}

.chat-reaction-count {
  font-size: 12px;
  color: var(--color-text-secondary, #666);
}

/* Emoji picker popover */
.chat-emoji-picker {
  position: absolute;
  top: -4px;
  right: 28px;
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  background: var(--color-surface-elevated, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10;
}

.chat-emoji-option {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.1s;
}

.chat-emoji-option:hover {
  background: var(--color-hover, #e8e8e8);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .chat-reaction {
    border-color: var(--color-border, #333);
    background: var(--color-surface, #1e1e1e);
  }
  .chat-reaction:hover {
    background: var(--color-hover, #2a2a2a);
  }
  .chat-reaction.mine {
    border-color: var(--color-primary, #60a5fa);
    background: rgba(96, 165, 250, 0.15);
  }
  .chat-emoji-picker {
    background: var(--color-surface-elevated, #2a2a2a);
    border-color: var(--color-border, #444);
  }
  .chat-emoji-option:hover {
    background: var(--color-hover, #333);
  }
  .chat-context-menu {
    background: var(--color-surface-elevated, #2a2a2a);
    border-color: var(--color-border, #444);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  }
  .chat-context-menu button:hover {
    background: var(--color-hover, #333);
  }
  .chat-reply-quote {
    background: rgba(255,255,255,0.06);
  }
  .chat-compose-bar {
    background: var(--color-surface-elevated, #1e1e1e);
  }
}

/* ========================================
   RESPONSIVE MÒBIL — Flex natural (no position:fixed)
   Elimina els bugs iOS Safari de position:fixed + teclat virtual
   ======================================== */

@media (max-width: 1023px) {
  /* Body flex column per que 100dvh funcioni naturalment amb el teclat */
  body[data-page="comunicacio"] {
    overflow: hidden;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic viewport — sobreescriu 100vh si el browser ho suporta */
    display: flex;
    flex-direction: column;
    padding-top: 0; /* Treure padding del header.css — el header participa al flex */
    padding-bottom: 0; /* Safety: cap padding residual */
    margin: 0;
    box-sizing: border-box;
  }

  /* Header: treure position:fixed perquè participi al flex 100dvh */
  body[data-page="comunicacio"] .app-header {
    position: relative;
    top: auto;
  }

  /* Header i tabbar fix, chat container ocupa l'espai restant */
  body[data-page="comunicacio"] #app-header {
    flex-shrink: 0;
  }

  body[data-page="comunicacio"] #app-tabbar {
    flex-shrink: 0;
  }

  /* Tabbar: treure position:fixed perquè participi al flex 100dvh */
  body[data-page="comunicacio"] .global-tab-bar {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
  }

  .chat-container {
    flex: 1;
    height: auto;
    display: flex;
    overflow: hidden;
    min-height: 0; /* Permetre que flex:1 es comprimi correctament */
  }

  /* Amagar banner onboarding push dins comunicació — evita solapament amb input */
  body[data-page="comunicacio"] .push-onboarding-banner {
    display: none !important;
  }

  .chat-sidebar {
    width: 100%;
    min-width: 100%;
  }

  .chat-main {
    display: none;
  }

  .chat-container.canal-obert .chat-sidebar {
    display: none;
  }

  .chat-container.canal-obert .chat-main {
    display: flex;
  }

  /* Amagar tabbar quan canal obert (patró WhatsApp/Telegram — guanya 56px) */
  .chat-container.canal-obert ~ #app-tabbar {
    display: none !important;
  }

  .chat-back-btn {
    display: flex !important;
  }

  /* Header xat: sticky dins el flex container */
  .chat-main-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  /* Missatges: scroll natiu amb touch */
  .chat-missatges-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Amagar tabbar quan teclat obert al xat */
  body.chat-keyboard-open #app-tabbar {
    display: none !important;
  }
}

/* Mòbil petit */
@media (max-width: 480px) {
  .chat-canal-item {
    padding: 8px 10px;
    gap: 10px;
  }

  .chat-canal-icon {
    width: 36px;
    height: 36px;
  }

  .chat-canal-icon .material-symbols-outlined {
    font-size: 18px;
  }
}

/* ── PWA standalone mode ── */
@media (display-mode: standalone) and (max-width: 1023px) {
  body[data-page="comunicacio"] {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ── Modal DM: dropdown visible ── */
#modalNouDM .modal-content {
  overflow: visible;
}
#modalNouDM .modal-body {
  overflow: visible;
  min-height: 280px;
}

/* ── @ Mencions dropdown ── */
.mention-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  margin-bottom: 4px;
  z-index: 100;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.mention-item:hover,
.mention-item.mention-highlighted {
  background: var(--color-bg-hover);
}

.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary-light, rgba(19, 117, 188, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

.mention-name {
  font-size: 0.85rem;
  color: var(--color-text-primary);
}

/* Menció dins missatge */
.chat-mention {
  background: var(--color-primary-light, rgba(19, 117, 188, 0.15));
  color: var(--color-primary);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 500;
}

/* ── Tauló canal icon (grup) ── */
.chat-canal-item[data-tipus="grup"] .chat-canal-icon {
  background: rgba(6, 182, 212, 0.12);
}
.chat-canal-item[data-tipus="grup"] .chat-canal-icon .material-symbols-outlined {
  color: #06b6d4;
}

/* ── Section headers — XATS / TAULONS principals ── */
.chat-section-header.chat-section-main {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  padding: 16px 16px 6px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

/* ── Compose Sheet trigger (taulons) ── */
.chat-compose-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
}

.chat-compose-trigger .btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.9rem;
}

/* ── Compose Sheet modal ── */
.compose-sheet .compose-title-input {
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

.compose-sheet .compose-title-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.compose-category-picker {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.compose-cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.compose-cat-btn .material-symbols-outlined {
  font-size: 18px;
}

.compose-cat-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.compose-cat-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.compose-schedule {
  margin-top: 8px;
}

.compose-schedule-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.compose-schedule-toggle input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
}

.compose-schedule-fields {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.compose-schedule-fields .form-control {
  font-size: 16px;
  flex: 1;
}

.compose-sheet .compose-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  line-height: 1.5;
}

.compose-sheet .compose-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Compose image upload */
.compose-image-upload {
  margin-bottom: 12px;
}

.compose-image-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.compose-image-dropzone:hover,
.compose-image-dropzone.dragover {
  border-color: var(--color-primary);
}

.compose-image-hint {
  font-size: 0.82rem;
  color: var(--color-text-tertiary);
}

.compose-image-preview {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.compose-image-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: contain;
}

.compose-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
}

.compose-image-remove:hover {
  background: rgba(0, 0, 0, 0.75);
}

/* ── Taulon Cards ── */
.taulon-card {
  margin-bottom: 12px;
}

.taulon-card-inner {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--color-bg-elevated);
  transition: box-shadow 0.15s;
}

.taulon-card-inner:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.taulon-scheduled .taulon-card-inner,
.taulon-card-inner.taulon-scheduled {
  border-style: dashed;
  opacity: 0.7;
}

.taulon-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.taulon-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.taulon-card-author {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--color-text-primary);
}

.taulon-card-time {
  font-size: 0.78rem;
  color: var(--color-text-tertiary);
}

.taulon-card-cat-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.taulon-badge-scheduled {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

.taulon-card-title {
  margin: 6px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.3;
}

/* Taulon card image */
.taulon-card-image {
  margin: 8px 0;
}

.taulon-card-image img {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}

.taulon-card-body {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--color-text-secondary);
  word-break: break-word;
  white-space: pre-wrap;
}

.taulon-card-footer {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ── Taulon Card Sistema (missatges automàtics) ── */
.taulon-card--sistema .taulon-card-inner {
  background: var(--color-bg-surface, var(--color-bg-secondary));
  border-style: solid;
  border-color: var(--color-border);
}

.taulon-card-sistema-avatar {
  background: var(--color-text-tertiary) !important;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.taulon-card--sistema .taulon-card-author {
  font-weight: 500;
  color: var(--color-text-tertiary);
  font-style: italic;
}

.taulon-card--sistema .taulon-card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

/* ── Undo Send ── */
.chat-msg-undo .chat-msg-bubble.chat-msg-sending {
  opacity: 0.6;
}

.chat-msg-bubble.chat-msg-error {
  opacity: 0.5;
  border: 1px solid var(--color-error, #ef4444);
}

.chat-msg-error-label {
  font-size: 0.7rem;
  color: var(--color-error, #ef4444);
  padding: 2px 0;
  text-align: right;
}

.chat-msg-error-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  justify-content: flex-end;
}

.chat-retry-btn,
.chat-discard-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-retry-btn {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.chat-retry-btn:hover {
  background: var(--color-primary-light, rgba(19, 117, 188, 0.1));
}

.chat-discard-btn {
  color: var(--color-text-tertiary);
}

.chat-discard-btn:hover {
  color: var(--color-error, #ef4444);
  border-color: var(--color-error, #ef4444);
}

.chat-undo-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  justify-content: flex-end;
}

.chat-undo-label {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  font-style: italic;
}

.chat-undo-btn {
  background: none;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-undo-btn:hover {
  background: var(--color-primary-light, rgba(19, 117, 188, 0.1));
}

/* ── DM: amagar avatar (nom suficient en xats 1:1) ── */
.chat-main[data-canal-tipus="direct"] .chat-msg-avatar {
  display: none;
}

/* ── DM amb alumne — diferenciació visual (P27) ── */
.chat-canal-item.dm-alumne .chat-canal-icon {
  background: rgba(245, 158, 11, 0.12);
}
.chat-canal-item.dm-alumne .chat-canal-icon .material-symbols-outlined {
  color: #f59e0b;
}

.chat-canal-alumne-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  vertical-align: middle;
}

/* Banner DM alumne (taronja en lloc de blau) */
.chat-taulon-banner--alumne {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #92400e !important;
  font-weight: 600;
  border-bottom: 2px solid rgba(245, 158, 11, 0.4) !important;
}

/* Fons diferent a tota l'àrea de xat quan és DM amb alumne */
.chat-main--dm-alumne {
  background: rgba(245, 158, 11, 0.04);
}
.chat-main--dm-alumne .chat-missatges-scroll {
  background: rgba(245, 158, 11, 0.04);
}
.chat-main--dm-alumne .chat-main-header {
  background: rgba(245, 158, 11, 0.06);
  border-bottom-color: rgba(245, 158, 11, 0.2);
}
.chat-main--dm-alumne .chat-input-area {
  background: rgba(245, 158, 11, 0.06);
  border-top-color: rgba(245, 158, 11, 0.2);
}

@media (prefers-color-scheme: dark) {
  .chat-canal-item.dm-alumne .chat-canal-icon {
    background: rgba(245, 158, 11, 0.18);
  }
  .chat-canal-alumne-badge {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
  }
  .chat-taulon-banner--alumne {
    background: rgba(245, 158, 11, 0.18) !important;
    color: #fbbf24 !important;
    border-bottom-color: rgba(245, 158, 11, 0.35) !important;
  }
  .chat-main--dm-alumne {
    background: rgba(245, 158, 11, 0.06);
  }
  .chat-main--dm-alumne .chat-missatges-scroll {
    background: rgba(245, 158, 11, 0.06);
  }
  .chat-main--dm-alumne .chat-main-header {
    background: rgba(245, 158, 11, 0.08);
    border-bottom-color: rgba(245, 158, 11, 0.25);
  }
  .chat-main--dm-alumne .chat-input-area {
    background: rgba(245, 158, 11, 0.08);
    border-top-color: rgba(245, 158, 11, 0.25);
  }
}

/* ── Bubbles pròpies taronja en DMs amb Alumne/Pare ── */
.chat-main--dm-alumne .msg-own .chat-msg-bubble {
  background: #fef3c7;
  color: #1a1a1a;
}
@media (prefers-color-scheme: dark) {
  .chat-main--dm-alumne .msg-own .chat-msg-bubble {
    background: #78350f;
    color: #fef3c7;
  }
}

/* ── "Respondre en privat" button ── */
.chat-reply-private {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  margin-top: 4px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-primary);
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-reply-private:hover {
  background: var(--color-primary-light, rgba(19, 117, 188, 0.1));
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
  .msg-own .chat-msg-bubble {
    background: #1e3a5f;
    color: #e0ecf8;
  }

  .chat-canal-item[data-tipus="general"] .chat-canal-icon {
    background: rgba(34, 197, 94, 0.18);
  }
  .chat-canal-item[data-tipus="coordinacio"] .chat-canal-icon {
    background: rgba(239, 68, 68, 0.18);
  }
  .chat-canal-item[data-tipus="professors"] .chat-canal-icon {
    background: rgba(245, 158, 11, 0.18);
  }
  .chat-canal-item[data-tipus="formacio"] .chat-canal-icon {
    background: rgba(59, 130, 246, 0.18);
  }
  .chat-canal-item[data-tipus="claustro"] .chat-canal-icon {
    background: rgba(139, 92, 246, 0.18);
  }
  .chat-canal-item[data-tipus="grup"] .chat-canal-icon {
    background: rgba(6, 182, 212, 0.18);
  }

  .taulon-card-inner {
    background: var(--color-bg-elevated);
    border-color: var(--color-border);
  }
  .taulon-card-inner:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  .compose-cat-btn {
    background: var(--color-bg-elevated);
    border-color: var(--color-border);
  }

  .chat-reply-private {
    background: var(--color-bg-elevated);
    border-color: var(--color-border);
  }
  .chat-reply-private:hover {
    background: rgba(96, 165, 250, 0.15);
    color: var(--color-primary);
  }

  .chat-undo-btn {
    border-color: var(--color-primary);
    color: var(--color-primary);
  }
  .chat-undo-btn:hover {
    background: rgba(96, 165, 250, 0.15);
  }
}

/* ========================================
   SWIPE-TO-ARCHIVE DMs
   ======================================== */

.dm-swipe-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.dm-swipe-content {
  position: relative;
  z-index: 2;
  background: var(--color-bg-primary);
  will-change: transform;
  touch-action: pan-y;
}

.dm-swipe-action {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  background: #ef4444;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  border-radius: 0 8px 8px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.dm-swipe-wrapper.swiping .dm-swipe-action {
  opacity: 1;
  pointer-events: auto;
}

.dm-swipe-action .material-symbols-outlined {
  font-size: 22px;
}

.dm-swipe-action:active {
  background: #dc2626;
}

/* ========================================
   DM SELECTOR — Modal nou missatge directe
   ======================================== */

.dm-selector-modal .modal-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
}

/* Search box */
.dm-search-box {
  position: relative;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.dm-search-icon {
  position: absolute;
  left: calc(var(--spacing-md) + 10px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.dm-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.dm-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(19, 117, 188, 0.12);
}

/* Role filter pills */
.dm-role-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.dm-role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: 20px;
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dm-role-pill:hover {
  border-color: var(--color-text-tertiary);
}

.dm-role-pill.active {
  font-weight: 600;
}

.dm-role-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* User list */
.dm-user-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xs) 0;
}

.dm-group-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 10px var(--spacing-md) 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: -4px;
  background: var(--color-bg-card);
  z-index: 1;
  border-bottom: 1px solid var(--color-border);
  padding-top: 14px;
}

.dm-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dm-group-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  background: var(--color-bg-elevated);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.dm-user-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: 8px var(--spacing-md);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s ease;
  text-align: left;
}

.dm-user-item:hover {
  background: var(--color-bg-hover);
}

.dm-user-item:active {
  background: var(--color-bg-active, var(--color-bg-hover));
}

.dm-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.dm-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dm-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-user-fills {
  font-size: 12px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-empty {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  color: var(--color-text-tertiary);
  font-size: 14px;
}
