/* ═══════════════════════════════════════════════════════
   VORTEX RP — Messagerie Privée
   v1.0.0 — Production
   ═══════════════════════════════════════════════════════ */

.msg-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   CONVERSATION LIST
═══════════════════════════════════════════ */
.conv-panel {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden; background: var(--bg);
}
.conv-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.conv-head h3 { font-family: 'Archivo Black', sans-serif; font-size: 16px; }
.new-msg-btn  { background: var(--accent); color: #fff; font-family: 'Archivo Black', sans-serif; font-size: 11px; letter-spacing: 1px; padding: 6px 14px; border: none; transition: all .2s; cursor: pointer; }
.new-msg-btn:hover { background: #9070ff; }

.conv-search-wrap { padding: 8px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.conv-search {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  padding: 7px 12px; color: var(--text); font-size: 12px; outline: none;
  transition: border-color .2s;
}
.conv-search:focus { border-color: var(--accent); }
.conv-search::placeholder { color: var(--muted); }

.conv-list { overflow-y: auto; flex: 1; }

.conv-item {
  padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  cursor: pointer; transition: background .15s;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  position: relative; user-select: none;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: rgba(124,92,252,.08); border-left-color: var(--accent); }
.conv-item.unread .conv-preview { color: var(--text); font-weight: 600; }
.conv-item.unread .conv-name-row { font-weight: 700; }
.conv-av-wrap { position: relative; flex-shrink: 0; }
.online-dot   { position: absolute; bottom: -1px; right: -1px; width: 9px; height: 9px; background: var(--green); border-radius: 50%; border: 2px solid var(--bg); }
.conv-info    { flex: 1; min-width: 0; }
.conv-name-row { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.conv-time    { font-size: 10px; color: var(--muted); font-family: 'JetBrains Mono', monospace; font-weight: 400; flex-shrink: 0; }
.conv-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-unread-badge { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 999px; min-width: 16px; text-align: center; }

/* ═══════════════════════════════════════════
   CHAT AREA
═══════════════════════════════════════════ */
.chat-area {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--muted); gap: 10px; user-select: none;
}
.chat-empty-icon { font-size: 52px; opacity: .25; }
.chat-empty-text { font-size: 13px; }

.chat-head {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; background: var(--surface);
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-name { font-family: 'Archivo Black', sans-serif; font-size: 15px; }
.chat-status    { font-size: 11px; font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.chat-status.online  { color: var(--green); }
.chat-status.offline { color: var(--muted); }
.chat-head-btns { display: flex; gap: 6px; }
.chat-head-btn  { background: none; border: 1px solid var(--border); color: var(--muted2); padding: 5px 10px; font-size: 13px; transition: all .2s; cursor: pointer; }
.chat-head-btn:hover { border-color: var(--accent); color: var(--accent); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.date-sep {
  text-align: center; font-size: 10px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace; padding: 8px 0;
  display: flex; align-items: center; gap: 12px; user-select: none;
}
.date-sep::before, .date-sep::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

.msg-row { display: flex; align-items: flex-end; gap: 7px; animation: slideInLeft .2s ease both; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-content { max-width: 68%; }
.msg-meta    { font-size: 10px; color: var(--muted); font-family: 'JetBrains Mono', monospace; padding: 0 4px; margin-bottom: 3px; }
.msg-meta.mine { text-align: right; }
.msg-bubble  { padding: 9px 13px; font-size: 13px; line-height: 1.55; word-break: break-word; }
.msg-bubble.theirs { background: var(--surface2); border: 1px solid var(--border); }
.msg-bubble.mine   { background: var(--accent); color: #fff; }
.msg-read    { font-size: 10px; color: rgba(255,255,255,.65); margin-left: 5px; }

.typing-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; animation: fadeUp .2s ease; }
.typing-text { font-size: 11px; color: var(--muted); font-style: italic; }
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dot  { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typingBounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

.chat-input-area {
  padding: 12px 20px; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-wrap {
  flex: 1; background: var(--surface2); border: 1px solid var(--border2);
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px;
  transition: border-color .2s;
}
.chat-input-wrap:focus-within { border-color: var(--accent); }
.chat-textarea  { background: none; border: none; outline: none; color: var(--text); font-size: 13px; resize: none; flex: 1; max-height: 100px; line-height: 1.55; }
.chat-textarea::placeholder { color: var(--muted); }
.attach-btn     { background: none; border: none; color: var(--muted2); font-size: 15px; padding: 2px; transition: color .15s; cursor: pointer; flex-shrink: 0; }
.attach-btn:hover { color: var(--accent); }
.send-btn {
  background: var(--accent); border: none; color: #fff;
  font-family: 'Archivo Black', sans-serif; font-size: 12px;
  letter-spacing: 1px; padding: 10px 18px; transition: all .2s;
  cursor: pointer; flex-shrink: 0; align-self: flex-end;
}
.send-btn:hover { background: #9070ff; box-shadow: 0 4px 16px rgba(124,92,252,.4); }

/* ── Mobile back button ── */
.chat-back-btn { display: none; background: none; border: none; color: var(--muted2); font-size: 20px; padding: 4px 10px 4px 0; cursor: pointer; transition: color .15s; }
.chat-back-btn:hover { color: var(--accent); }

/* ═══════════════════════════════════════════
   RESPONSIVE MESSAGES
═══════════════════════════════════════════ */
@media (max-width: 800px) {
  .msg-layout { grid-template-columns: 220px 1fr; }
}
@media (max-width: 600px) {
  .msg-layout { grid-template-columns: 1fr; }
  .conv-panel { display: none; }
  .conv-panel.show { display: flex; position: fixed; inset: var(--topbar-h) 0 var(--mob-nav-h) 0; z-index: 100; background: var(--bg); }
  .chat-area  { height: calc(100vh - var(--topbar-h) - var(--mob-nav-h)); }
  .chat-messages { padding: 12px 14px; }
  .chat-input-area { padding: 10px 14px; }
  .chat-head { padding: 10px 14px; }
  .msg-content { max-width: 82%; }
  .chat-back-btn { display: flex !important; }
  .send-btn { padding: 10px 14px; }
}
