/**
 * 3D ArtDesk - Chat Styles
 * Chat bubbles, mentions, rich text editor
 */

/* === Rich Text Editor === */
.rte {
  min-height: 140px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  outline: none;
  background: #fff;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rte:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 90, 100, 0.15);
}

.rte:empty::before {
  content: attr(placeholder);
  color: #99a;
  pointer-events: none;
}

.rte img {
  display: block;
  max-height: 250px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 6px auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
}

/* Drop feedback */
.rte.drop-hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(14, 90, 100, 0.18);
  background: #f7faff;
}

.rte.drop-error {
  border-color: var(--bad);
  box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.15);
  animation: dropBlink 0.6s ease;
}

@keyframes dropBlink {
  0% { background: #fff; }
  50% { background: #fff4f4; }
  100% { background: #fff; }
}

/* === RTE Toolbar === */
.rte-wrap {
  position: relative;
  margin-top: 6px;
}

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #fafbff;
  border: 1.5px solid var(--border);
  border-bottom: 0;
  padding: 6px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.rte-toolbar .rtb {
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  line-height: 1;
  transition: box-shadow var(--transition);
}

.rte-toolbar .rtb:hover {
  box-shadow: var(--shadow);
}

.rte-toolbar .rtb:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rte-toolbar .rt-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 2px;
}

.rte-wrap .rte {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* === File Attachments in RTE === */
.rte .file-attach {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin: 8px 0;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.rte .file-attach:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.rte .file-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #f7f7fb;
  font-weight: 800;
  text-transform: uppercase;
  flex-shrink: 0;
}

.rte .file-meta {
  font-size: 0.95rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.rte .file-meta small {
  color: #6b7280;
}

.rte .file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.rte .file-preview-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.rte .file-preview-btn:hover {
  text-decoration: underline;
}

/* File type colors */
.file-ext-pdf .file-thumb { background: #fee2e2; border-color: #fecaca; }
.file-ext-doc .file-thumb,
.file-ext-docx .file-thumb { background: #e0ecff; border-color: #c7ddff; }
.file-ext-xls .file-thumb,
.file-ext-xlsx .file-thumb { background: #e6f7ee; border-color: #c9efd9; }
.file-ext-ppt .file-thumb,
.file-ext-pptx .file-thumb { background: #fff0e1; border-color: #ffe2c2; }
.file-ext-txt .file-thumb { background: #f2f2f2; border-color: #e5e5e5; }

/* === Chat Lists === */
#chatList, #tchatList, .inline-chat .ic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* === Chat Message Bubbles === */
.msg {
  display: flex;
}

.msg.me {
  justify-content: flex-start;
}

.msg.other {
  justify-content: flex-end;
}

.msg .bubble {
  max-width: min(78%, 720px);
  padding: 10px 12px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg.me .bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-left-radius: 6px;
}

.msg.other .bubble {
  background: #1f2a2e;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.bubble .chat-content {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble .chat-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}

.bubble .chat-content a {
  color: #fff;
  text-decoration: underline;
}

.bubble .meta {
  margin-top: 6px;
  font-size: var(--font-size-sm);
  opacity: 0.85;
}

.bubble pre, .bubble code {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble pre {
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
  border-radius: var(--radius-sm);
  overflow: auto;
}

/* === Inline Chat (in modals) === */
.inline-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.inline-chat .ic-list {
  flex: 1;
  overflow: auto;
  background: #f8f9fb;
  border-radius: var(--radius-lg);
  padding: 8px;
}

.inline-chat .ic-editor {
  min-height: 84px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: #fff;
  overflow: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.inline-chat .ic-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

/* === Mentions === */
.mention {
  background: rgba(14, 90, 100, 0.12);
  border-radius: 4px;
  padding: 0 2px;
}

.mention-click {
  background: rgba(14, 90, 100, 0.12);
  border-radius: 4px;
  padding: 0 2px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

/* In bubbles */
.bubble .mention-click {
  background: rgba(255, 255, 255, 0.18);
}

.has-my-mention {
  outline: 2px solid rgba(42, 166, 184, 0.35);
}

.hi-msg {
  animation: hiBlink 1.4s ease 1;
  box-shadow: 0 0 0 3px rgba(14, 90, 100, 0.20) inset;
}

@keyframes hiBlink {
  0% { background: #fffbe6; }
  100% { background: #fff; }
}

/* Mention Suggestions Dropdown */
.mention-suggest {
  position: absolute;
  z-index: var(--z-modal);
  max-height: 220px;
  overflow: auto;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  min-width: 240px;
}

.mention-suggest div {
  padding: 8px 10px;
  cursor: pointer;
}

.mention-suggest div:hover,
.mention-suggest .active {
  background: #f5f7fa;
}

/* === Chat Modal Specific === */
#modalProjChat .box,
#modalTaskChat .box {
  max-width: 700px;
}

#chatList, #tchatList {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fafbff;
}
