/* ═══════════════════════════════════════════════════════════════════
   diaspora.ro — Chat 1:1 Complet v1.0  (STEP 10)
   Typing 3 puncte, read receipt, online status, reactions, reply,
   forward, edit/delete, mesaj vocal, fișiere, GIF, link preview,
   mute, vanish mode, search în conversație
   Mobile-first. Dark + Light mode. Zero dependențe externe.
   ═══════════════════════════════════════════════════════════════════ */

/* ══ Layout principal ════════════════════════════════════════════ */
.ch-wrap {
  display: flex; flex-direction: column;
  height: 100vh; max-height: 100dvh;
  background: var(--bg, #09011a);
  position: relative; overflow: hidden;
}
@media (min-width: 768px) {
  .ch-wrap { flex-direction: row; }
}

/* ══ Sidebar conversații ════════════════════════════════════════ */
.ch-sidebar {
  width: 100%; flex-shrink: 0;
  border-right: 1px solid var(--border, rgba(255,255,255,.08));
  display: flex; flex-direction: column;
  background: var(--card, #0d0520);
}
@media (min-width: 768px) { .ch-sidebar { width: 320px; } }

.ch-sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
}
.ch-sidebar-title { font-size: 16px; font-weight: 700; color: var(--ink, #f1f5f9); flex: 1; }
.ch-sidebar-action {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--card2, #120a2e); color: var(--muted, #64748b); font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.ch-sidebar-action:hover { color: var(--brand, #a855f7); }

.ch-conv-list { flex: 1; overflow-y: auto; }
.ch-conv-list::-webkit-scrollbar { width: 4px; }
.ch-conv-list::-webkit-scrollbar-thumb { background: var(--border, rgba(255,255,255,.1)); border-radius: 2px; }

.ch-conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; transition: background .1s; position: relative;
}
.ch-conv-item:hover { background: var(--card2, #120a2e); }
.ch-conv-item.active { background: color-mix(in srgb, var(--brand,#a855f7) 10%, var(--card2,#120a2e)); }
.ch-conv-item.unread .ch-conv-name { font-weight: 700; }

.ch-conv-av {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--card2, #120a2e);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: var(--muted, #64748b);
  position: relative;
}
.ch-conv-av img { width: 100%; height: 100%; object-fit: cover; }
.ch-online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--card, #0d0520);
  background: #94a3b8;
}
.ch-online-dot.online { background: #22c55e; }

.ch-conv-body { flex: 1; min-width: 0; }
.ch-conv-name { font-size: 14px; font-weight: 500; color: var(--ink, #f1f5f9); }
.ch-conv-preview {
  font-size: 12px; color: var(--muted, #64748b);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.ch-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.ch-conv-time { font-size: 11px; color: var(--muted, #64748b); }
.ch-conv-badge {
  min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand, #a855f7);
  color: #fff; font-size: 10px; font-weight: 700; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}
.ch-conv-muted-icon { font-size: 12px; color: var(--muted, #64748b); }

/* ══ Header conversație ══════════════════════════════════════════ */
.ch-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  flex-shrink: 0; background: var(--card, #0d0520);
}
.ch-back-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: transparent; color: var(--ink2, #94a3b8); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  display: none;
}
@media (max-width: 767px) { .ch-back-btn { display: flex; } }
.ch-header-av { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--card2, #120a2e); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--muted, #64748b); }
.ch-header-av img { width: 100%; height: 100%; object-fit: cover; }
.ch-header-body { flex: 1; }
.ch-header-name { font-size: 14px; font-weight: 700; color: var(--ink, #f1f5f9); }
.ch-header-status { font-size: 11px; color: var(--muted, #64748b); margin-top: 1px; }
.ch-header-status.online { color: #22c55e; }
.ch-header-actions { display: flex; gap: 6px; }
.ch-header-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: transparent; color: var(--ink2, #94a3b8); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.ch-header-btn:hover { background: var(--card2, #120a2e); color: var(--ink, #f1f5f9); }

/* ══ Mesaje ══════════════════════════════════════════════════════ */
.ch-messages {
  flex: 1; overflow-y: auto; padding: 12px 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.ch-messages::-webkit-scrollbar { width: 4px; }
.ch-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* Date separator */
.ch-date-sep {
  text-align: center; padding: 8px 0;
}
.ch-date-sep span {
  font-size: 11px; color: var(--muted, #64748b);
  background: var(--card2, #120a2e); padding: 3px 10px; border-radius: 10px;
}

/* Mesaj */
.ch-msg {
  display: flex; align-items: flex-end; gap: 6px; max-width: 75%;
}
.ch-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.ch-msg.theirs { align-self: flex-start; }

.ch-msg-av {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--card2, #120a2e); display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--muted, #64748b);
}
.ch-msg-av img { width: 100%; height: 100%; object-fit: cover; }

.ch-msg-bubble {
  padding: 8px 12px; border-radius: 18px;
  max-width: 100%; word-break: break-word;
  position: relative; transition: background .12s;
}
.ch-msg.mine   .ch-msg-bubble { background: var(--brand, #a855f7); color: #fff; border-radius: 18px 18px 4px 18px; }
.ch-msg.theirs .ch-msg-bubble { background: var(--card2, #120a2e); color: var(--ink, #f1f5f9); border-radius: 18px 18px 18px 4px; }
.ch-msg.mine.deleted   .ch-msg-bubble { background: rgba(168,85,247,.25); }
.ch-msg.theirs.deleted .ch-msg-bubble { background: rgba(255,255,255,.04); }

.ch-msg-text { font-size: 14px; line-height: 1.4; }
.ch-msg.deleted .ch-msg-text { font-style: italic; opacity: .6; }

/* Reply citat */
.ch-msg-reply {
  border-left: 3px solid rgba(255,255,255,.4); padding-left: 8px;
  margin-bottom: 6px; font-size: 12px; opacity: .8;
  cursor: pointer; border-radius: 0 4px 4px 0;
}
.ch-msg.theirs .ch-msg-reply { border-color: var(--brand, #a855f7); opacity: .7; }

/* GIF în mesaj */
.ch-msg-gif { border-radius: 12px; overflow: hidden; max-width: 240px; margin-top: 4px; }
.ch-msg-gif img { width: 100%; display: block; }

/* Fișier */
.ch-msg-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px;
  background: rgba(0,0,0,.2); margin-top: 4px;
  text-decoration: none; color: inherit;
}
.ch-msg-file-icon { font-size: 24px; flex-shrink: 0; }
.ch-msg-file-name { font-size: 13px; font-weight: 500; word-break: break-all; }
.ch-msg-file-size { font-size: 11px; opacity: .6; }

/* Voice */
.ch-msg-voice {
  display: flex; align-items: center; gap: 8px; min-width: 160px;
}
.ch-voice-play-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.2); color: #fff; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ch-voice-waveform {
  flex: 1; height: 24px; display: flex; align-items: center; gap: 2px;
}
.ch-voice-bar {
  flex: 1; border-radius: 2px; background: rgba(255,255,255,.3);
  transition: background .12s;
}
.ch-voice-bar.played { background: rgba(255,255,255,.8); }
.ch-voice-time { font-size: 11px; opacity: .7; flex-shrink: 0; }

/* Link preview */
.ch-msg-link-preview {
  border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.1); margin-top: 6px; cursor: pointer;
  background: rgba(0,0,0,.3); max-width: 280px;
  text-decoration: none; display: block;
}
.ch-msg-link-preview:hover { opacity: .85; }
.ch-msg-link-img { width: 100%; height: 120px; object-fit: cover; display: block; }
.ch-msg-link-body { padding: 8px 10px; }
.ch-msg-link-domain { font-size: 10px; color: var(--muted, #64748b); text-transform: uppercase; margin-bottom: 2px; }
.ch-msg-link-title  { font-size: 12px; font-weight: 600; color: var(--ink, #f1f5f9); line-height: 1.3; }

/* Meta (timp, edit, read receipt) */
.ch-msg-meta {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; opacity: .6; margin-top: 3px;
}
.ch-msg.mine .ch-msg-meta { justify-content: flex-end; }
.ch-msg-edited { font-style: italic; }
.ch-msg-receipt { font-size: 12px; }
.ch-msg-receipt.sent       { opacity: .5; }
.ch-msg-receipt.delivered  { opacity: .75; }
.ch-msg-receipt.seen       { color: #22c55e; opacity: 1; }

/* Reacții pe mesaj */
.ch-msg-reactions {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px;
}
.ch-msg-rxn-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(255,255,255,.1); font-size: 12px; cursor: pointer;
  transition: background .1s;
}
.ch-msg-rxn-chip:hover { background: rgba(255,255,255,.18); }
.ch-msg-rxn-chip.mine  { background: color-mix(in srgb, var(--brand,#a855f7) 25%, rgba(255,255,255,.1)); }
.ch-msg-rxn-count      { font-size: 11px; font-weight: 700; }

/* ══ Typing indicator ════════════════════════════════════════════ */
.ch-typing {
  display: none; align-items: flex-end; gap: 6px; padding: 4px 12px;
}
.ch-typing.visible { display: flex; }
.ch-typing-dots {
  display: flex; gap: 3px; align-items: center;
  padding: 10px 14px; border-radius: 18px 18px 18px 4px;
  background: var(--card2, #120a2e);
}
.ch-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted, #64748b);
  animation: ch-typing .6s ease-in-out infinite;
}
.ch-typing-dot:nth-child(2) { animation-delay: .1s; }
.ch-typing-dot:nth-child(3) { animation-delay: .2s; }
@keyframes ch-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ══ Reply preview bar ═══════════════════════════════════════════ */
.ch-reply-bar {
  display: none; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--card2, #120a2e);
  border-left: 3px solid var(--brand, #a855f7);
  margin: 0 8px; border-radius: 0 8px 0 0;
}
.ch-reply-bar.visible { display: flex; }
.ch-reply-bar-text { flex: 1; font-size: 12px; color: var(--ink2, #94a3b8); }
.ch-reply-bar-name { font-size: 11px; font-weight: 700; color: var(--brand, #a855f7); }
.ch-reply-cancel   { font-size: 16px; cursor: pointer; color: var(--muted, #64748b); border: none; background: none; flex-shrink: 0; }

/* ══ Compose ══════════════════════════════════════════════════════ */
.ch-compose {
  padding: 8px 12px 12px;
  background: var(--card, #0d0520);
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  flex-shrink: 0;
}
.ch-compose-row { display: flex; align-items: flex-end; gap: 8px; }
.ch-compose-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.ch-compose-tool-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: transparent; color: var(--muted, #64748b); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color .12s;
}
.ch-compose-tool-btn:hover { color: var(--brand, #a855f7); }
.ch-compose-tool-btn.recording { color: #ef4444; animation: ch-pulse .8s ease-in-out infinite; }
@keyframes ch-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.ch-compose-input-wrap { flex: 1; position: relative; }
.ch-compose-input {
  width: 100%; padding: 10px 14px; border-radius: 22px;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  background: var(--card2, #120a2e); color: var(--ink, #f1f5f9);
  font-size: 14px; outline: none; resize: none;
  min-height: 44px; max-height: 120px; overflow-y: auto;
  transition: border-color .15s;
}
.ch-compose-input:focus { border-color: var(--brand, #a855f7); }
.ch-compose-input:empty:before { content: attr(data-placeholder); color: var(--muted, #64748b); pointer-events: none; }

.ch-send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--brand, #a855f7); color: #fff; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: .4; pointer-events: none; transition: opacity .12s, transform .1s;
}
.ch-send-btn.enabled { opacity: 1; pointer-events: all; }
.ch-send-btn:active  { transform: scale(.9); }

/* ══ Vanish mode banner ══════════════════════════════════════════ */
.ch-vanish-banner {
  display: none; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; background: color-mix(in srgb, var(--brand,#a855f7) 12%, var(--card,#0d0520));
  font-size: 12px; color: var(--brand, #a855f7); font-weight: 600; flex-shrink: 0;
}
.ch-vanish-banner.active { display: flex; }

/* ══ Search bar ══════════════════════════════════════════════════ */
.ch-search-bar {
  display: none; padding: 8px 14px;
  background: var(--card, #0d0520);
  border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
}
.ch-search-bar.visible { display: flex; gap: 8px; align-items: center; }
.ch-search-input {
  flex: 1; padding: 7px 12px; border-radius: 18px;
  border: 1px solid var(--brand, #a855f7); background: var(--card2, #120a2e);
  color: var(--ink, #f1f5f9); font-size: 13px; outline: none;
}
.ch-search-close { border: none; background: none; color: var(--muted, #64748b); font-size: 18px; cursor: pointer; }

/* ══ Context menu mesaj ══════════════════════════════════════════ */
.ch-msg-ctx-menu {
  position: fixed; z-index: 9800;
  background: var(--card, #0d0520); border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 14px; overflow: hidden; min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.ch-ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; cursor: pointer; font-size: 14px;
  color: var(--ink2, #94a3b8); transition: background .1s;
}
.ch-ctx-item:hover { background: var(--card2, #120a2e); color: var(--ink, #f1f5f9); }
.ch-ctx-item.danger { color: #ef4444; }
.ch-ctx-item.danger:hover { background: rgba(239,68,68,.08); }

/* ══ Emoji picker pentru react pe mesaj ════════════════════════ */
.ch-rxn-picker {
  position: absolute; z-index: 9800;
  display: flex; gap: 6px; padding: 8px 12px;
  background: var(--card, #0d0520);
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 30px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ch-rxn-btn {
  font-size: 22px; border: none; background: transparent; cursor: pointer;
  transition: transform .12s; line-height: 1;
}
.ch-rxn-btn:hover { transform: scale(1.35) translateY(-3px); }

/* ══ Mute menu ═══════════════════════════════════════════════════ */
.ch-mute-menu {
  position: absolute; right: 12px; top: 50px; z-index: 800;
  background: var(--card, #0d0520);
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px; overflow: hidden; min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); display: none;
}
.ch-mute-menu.open { display: block; }
.ch-mute-item {
  padding: 10px 16px; cursor: pointer; font-size: 14px;
  color: var(--ink2, #94a3b8); transition: background .1s;
}
.ch-mute-item:hover { background: var(--card2, #120a2e); color: var(--ink, #f1f5f9); }

/* ══ Animații ════════════════════════════════════════════════════ */
@keyframes ch-slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ch-slide-in-left {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: none; }
}
.ch-msg.mine.new   { animation: ch-slide-in-right .2s ease both; }
.ch-msg.theirs.new { animation: ch-slide-in-left  .2s ease both; }

/* ══ Empty state ════════════════════════════════════════════════ */
.ch-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted, #64748b); text-align: center; padding: 32px;
}
.ch-empty-icon { font-size: 48px; }
.ch-empty-text { font-size: 15px; }

/* ══ Light mode ══════════════════════════════════════════════════ */
[data-theme="light"] .ch-sidebar,
[data-theme="light"] .ch-header  { background: #fff; }
[data-theme="light"] .ch-msg.theirs .ch-msg-bubble { background: #f1f5f9; color: #0f172a; }
[data-theme="light"] .ch-compose { background: #fff; }
[data-theme="light"] .ch-compose-input { background: #f8fafc; color: #0f172a; }
[data-theme="light"] .ch-msg-ctx-menu,
[data-theme="light"] .ch-rxn-picker,
[data-theme="light"] .ch-mute-menu { background: #fff; }
[data-theme="light"] .ch-conv-item:hover { background: #f8fafc; }
