/* ═══ Floakly Messages ═══ */

/* ── Bubble Wrapper (group messages with avatar) ── */
.bubble-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 4px;
}

.bubble-wrapper.mine {
    flex-direction: row-reverse;
}

.bubble-wrapper .bubble {
    margin: 0;
}

/* ── Date Separator ── */
.msg-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 8px;
}
.msg-date-separator span {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-chat);
  padding: 0 8px;
}

/* ── Message Row ── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}
.msg-row.me   { flex-direction: row-reverse; }
.msg-row.them { flex-direction: row; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 16px;
}

.msg-content-wrap {
  display: flex; flex-direction: column;
  max-width: 65%;
}
.msg-row.me   .msg-content-wrap { align-items: flex-end; }
.msg-row.them .msg-content-wrap { align-items: flex-start; }

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.msg-time.me   { text-align: right; }
.msg-time.them { text-align: left; padding-left: 4px; }

.msg-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.msg-status .read { color: var(--online); }

/* ── Bubble Text ── */
.bubble {
  padding: 10px 14px;
  font-size: var(--font-size-base);
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  cursor: default;
}
.bubble.them {
  background: var(--bg-bubble-them);
  color: var(--text-bubble-them);
  border-radius: 18px 18px 18px 4px;
}
.bubble.me {
  background: var(--bg-bubble-me);
  color: var(--text-bubble-me);
  border-radius: 18px 18px 4px 18px;
}

/* ── Bubble Media (image) ── */
.bubble-media {
  max-width: 260px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.bubble-media img {
  width: 100%;
  display: block;
  object-fit: cover;
  border-radius: 12px;
  transition: opacity 0.15s;
}
.bubble-media img:hover { opacity: 0.92; }
.bubble-media.loading {
  width: 200px; height: 140px;
  background: #f3f4f6;
  display: flex; align-items: center; justify-content: center;
}

/* ── Bubble File ── */
.bubble-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-file);
  background: var(--bg-file-bubble);
  border: 0.5px solid var(--border);
  max-width: 260px;
  cursor: default;
}
.file-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.file-icon.pdf  { background: #fee2e2; color: #dc2626; }
.file-icon.doc  { background: #dbeafe; color: #1d4ed8; }
.file-icon.xls  { background: #dcfce7; color: #15803d; }
.file-icon.img  { background: #ede9fe; color: #4f36c8; }
.file-icon.generic { background: #f3f4f6; color: #6b7280; }

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.file-download-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.file-download-btn:hover { background: var(--border); }

/* ── Reaction ── */
.msg-reaction {
  position: absolute;
  bottom: -10px;
  right: 8px;
  font-size: 14px;
  background: var(--reaction-bg);
  border: 1px solid var(--reaction-border);
  border-radius: 10px;
  padding: 1px 5px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.1s;
}
.msg-reaction:hover { transform: scale(1.15); }
.msg-row.me .msg-reaction {
  right: auto;
  left: 8px;
}

/* ── Context menu ── */
.msg-context-menu {
  position: fixed;
  background: #fff;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 1000;
  min-width: 160px;
}
.msg-context-menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none; background: transparent;
  text-align: left;
  font-size: 13px; color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  font-family: var(--font-sans);
}
.msg-context-menu button:hover { background: var(--bg-conv-hover); }
.msg-context-menu button.danger { color: var(--danger); }
.msg-context-menu button.danger:hover { background: var(--danger-bg); }

/* ── Emoji picker ── */
.emoji-picker {
  position: absolute;
  bottom: 72px; left: 12px;
  background: #fff;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 8px;
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.emoji-picker button {
  width: 36px; height: 36px;
  border: none; background: transparent;
  font-size: 20px; cursor: pointer;
  border-radius: 6px;
}
.emoji-picker button:hover { background: var(--bg-conv-hover); }

/* ── Message layers (orig + corr + trans) ── */
.msg-orig {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}
.msg-corr {
  font-size: 11px;
  color: #d97706;
  font-style: italic;
  display: block;
}
.msg-trans {
  font-size: 15px;
  color: var(--primary);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 0.5px solid var(--border-light);
  font-style: italic;
}

/* ── Reply bar ── */
.reply-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-composer);
  border-top: 0.5px solid var(--border-light);
  font-size: 12px;
}
.reply-label { color: var(--text-muted); }
.reply-preview-text { color: var(--text-secondary); }

/* ── Attachment Preview (clipboard paste / drag-drop) ── */
.attachment-preview {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-composer);
  border-top: 0.5px solid var(--border-light);
  position: relative;
}
.attachment-preview.hidden { display: none; }

.attachment-preview-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.attachment-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-preview-thumb .file-icon-preview {
  font-size: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.attachment-preview-thumb .file-ext {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
}

.attachment-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.attachment-preview-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-preview-size {
  font-size: 11px;
  color: var(--text-muted);
}

.attachment-preview-remove {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.12s;
}
.attachment-preview-remove:hover { background: rgba(0,0,0,0.75); }
