/* ===== COMMENTS — Chat, comentários e toolbar ===== */

.detail-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* Altura fixa garante o scroll independente da cadeia flex */
  height: 340px;
  max-height: 340px;
  /* Scrollbar sempre visível */
  overflow-y: scroll;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d8 transparent;
}

.detail-chat-messages::-webkit-scrollbar       { width: 4px; }
.detail-chat-messages::-webkit-scrollbar-track { background: transparent; }
.detail-chat-messages::-webkit-scrollbar-thumb {
  background: #d0d0d8;
  border-radius: 4px;
  transition: background 0.2s;
}
.detail-chat-messages:hover::-webkit-scrollbar-thumb { background: #b0b0bc; }

.detail-chat-empty {
  text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem; line-height: 1.7;
}

/* Trello-style comments */
.trello-comment { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.1rem 0; }

.tc-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.8rem; flex-shrink: 0; color: #fff;
}
.tc-avatar.attendant, .tc-avatar.superadmin { background: #1d4ed8; }
.tc-avatar.requester { background: var(--accent); }

.tc-body { flex: 1; min-width: 0; }

.tc-header {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.3rem; flex-wrap: wrap; position: relative;
}

.tc-author { font-weight: 700; font-size: 0.8rem; }

.tc-role {
  font-size: 0.62rem; font-family: var(--font-mono); font-weight: 700;
  border-radius: 4px; padding: 0.05rem 0.35rem;
}
.tc-role.attendant, .tc-role.superadmin { background: #dbeafe; color: #1d4ed8; }
.tc-role.requester { background: #fee2e2; color: var(--accent2); }

.tc-ts { font-size: 0.65rem; color: var(--muted); font-family: var(--font-mono); }

.tc-content {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
  border-left: 3px solid var(--border2);
  transition: border-left-color 0.15s;
}

.trello-comment:not(.mine) .tc-content { background: var(--surface); }
.trello-comment.mine       .tc-content { background: #e2e2e8; border-left-color: var(--accent); }
.trello-comment:hover      .tc-content { border-left-color: var(--accent); }

/* Comment actions */
.tc-comment-actions {
  display: flex; align-items: center; gap: 0.25rem;
  margin-left: auto; flex-shrink: 0; opacity: 0; transition: opacity 0.15s;
}
.trello-comment:hover .tc-comment-actions,
.tc-comment-actions:focus-within { opacity: 1; }

.tc-action-btn {
  width: 24px; height: 24px; border-radius: 5px;
  border: 1px solid var(--border2); background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s; flex-shrink: 0;
}
.tc-action-btn.edit:hover   { border-color: var(--accent);  color: var(--accent); }
.tc-action-btn.delete:hover { border-color: var(--accent3); color: var(--accent3); }
.tc-action-btn.save:hover   { border-color: #16a34a; color: #16a34a; }
.tc-action-btn.cancel:hover { border-color: var(--accent3); color: var(--accent3); }

.tc-content.tc-editing {
  outline: 2px solid var(--accent); border-radius: 6px;
  padding: 0.5rem 0.7rem; background: var(--surface); min-height: 40px; cursor: text;
}

/* Toolbar */
.comment-toolbar {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.5rem 1.4rem; border-top: 1px solid var(--border2);
  background: var(--surface2); flex-shrink: 0;
}

.ct-btn {
  width: 30px; height: 28px; border: 1px solid var(--border2); border-radius: 5px;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s;
}
.ct-btn:hover { border-color: var(--accent); color: var(--accent); }

.ct-sep { width: 1px; height: 18px; background: var(--border2); margin: 0 0.1rem; }

.ct-select {
  border: 1px solid var(--border2); border-radius: 5px; background: var(--surface);
  color: var(--muted); font-size: 0.75rem; font-family: var(--font-display);
  padding: 0.2rem 0.4rem; cursor: pointer; outline: none; height: 28px;
}
.ct-select:focus { border-color: var(--accent); }

/* Input area */
.detail-chat-input-area {
  display: flex; gap: 0.6rem; align-items: flex-end;
  padding: 0.7rem 1.4rem; border-top: 1px solid var(--border2);
  background: var(--surface); flex-shrink: 0;
}

.detail-chat-editor {
  flex: 1; min-height: 42px; max-height: 130px; overflow-y: auto;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 10px;
  padding: 0.6rem 0.85rem; font-family: var(--font-display); font-size: 0.88rem;
  color: var(--text); line-height: 1.5; outline: none; word-break: break-word;
  transition: border-color 0.2s;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d8 transparent;
}
.detail-chat-editor::-webkit-scrollbar       { width: 3px; }
.detail-chat-editor::-webkit-scrollbar-thumb { background: #d0d0d8; border-radius: 3px; }
.detail-chat-editor:focus { border-color: var(--accent); }
.detail-chat-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }

.detail-chat-send {
  height: 40px; padding: 0 1rem;
  background: var(--accent); border: none; border-radius: 10px;
  color: #fff; font-size: 0.82rem; font-weight: 700; font-family: var(--font-display);
  cursor: pointer; white-space: nowrap; transition: all 0.15s; flex-shrink: 0;
}
.detail-chat-send:hover { background: var(--accent2); transform: translateY(-1px); }

/* System message */
.chat-msg.system {
  display: flex; gap: 0.5rem; justify-content: center;
  font-size: 0.75rem; color: var(--muted); font-family: var(--font-mono);
}

/* Hide old comment-entry */
.comment-entry { display: none !important; }

/* ===== TEMA ESCURO — comments.css ===== */
body.dark-mode .detail-chat-messages::-webkit-scrollbar-thumb { background: #44445a; }
body.dark-mode .detail-chat-messages:hover::-webkit-scrollbar-thumb { background: #5a5a7a; }
body.dark-mode .detail-chat-editor::-webkit-scrollbar-thumb { background: #44445a; }
body.dark-mode .tc-avatar.attendant,
body.dark-mode .tc-avatar.superadmin { background: #1d4ed8; }
body.dark-mode .tc-role.attendant,
body.dark-mode .tc-role.superadmin   { background: #0f1f3d; color: #93c5fd; }
body.dark-mode .tc-action-btn.save:hover { border-color: #22c55e; color: #86efac; }
body.dark-mode .trello-comment:not(.mine) .tc-content { background: var(--surface2); color: var(--text); }
body.dark-mode .trello-comment.mine .tc-content       { background: #1e293b; color: var(--text); border-left-color: var(--accent); }
body.dark-mode .trello-comment:hover .tc-content      { border-left-color: var(--accent); }
body.dark-mode .tc-author  { color: var(--text); }
body.dark-mode .tc-ts      { color: var(--muted); }
body.dark-mode .chat-msg.system { background: var(--surface2); color: var(--muted); }
body.dark-mode .detail-chat-editor {
  background: var(--surface2); color: var(--text); border-color: var(--border2);
}
body.dark-mode .detail-chat-editor:focus { border-color: var(--accent); }
.mention-tag {
  color: #2563eb;
  font-weight: 700;
  background: #eff6ff;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
body.dark-mode .mention-tag { background: #0f1f3d; color: #93c5fd; }
