/* Mensajes Directos (David 2026-07-22) — compartido por /mensajes/ (página
   completa) y el popup de escritorio (openMessagesPopup() en mensajes.js).
   Antes vivía como <style> inline solo en /mensajes/index.php; se movió
   aquí para que el popup (que se abre desde CUALQUIER página de la red
   social en escritorio) también tenga estos estilos disponibles. */
.msg-shell{ max-width:900px; margin:0 auto; padding:0; }
.msg-header{ display:flex; align-items:center; gap:10px; padding:16px; }
.msg-header h1{ display:flex; align-items:center; gap:8px; font-family:var(--font-heading); font-size:20px; margin:0; flex:1; }
.msg-new-btn{ background:none; border:1px solid var(--card-border); color:var(--text-light); width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.msg-new-btn:hover{ border-color:var(--accent); color:var(--accent-soft); }

.msg-list{ display:flex; flex-direction:column; }
.msg-conv-row{ display:flex; align-items:center; gap:12px; padding:12px 16px; background:none; border:none; width:100%; text-align:left; cursor:pointer; color:var(--text-light); border-bottom:1px solid var(--card-border); }
.msg-conv-row:hover{ background:rgba(255,255,255,.04); }
.msg-conv-row.unread .msg-conv-name{ font-weight:800; }
.msg-conv-row.unread .msg-conv-preview{ color:var(--text-light); font-weight:600; }
.msg-avatar{ position:relative; width:48px; height:48px; border-radius:50%; overflow:hidden; flex-shrink:0; background:var(--bg-dark-2); }
.msg-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.msg-status-dot{ position:absolute; bottom:0; right:0; width:11px; height:11px; border-radius:50%; border:2px solid var(--bg-dark); }
.msg-conv-info{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.msg-conv-name{ font-size:14.5px; font-weight:700; }
.msg-conv-preview{ font-size:13px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.msg-conv-meta{ display:flex; flex-direction:column; align-items:flex-end; gap:6px; flex-shrink:0; }
.msg-conv-time{ font-size:11px; color:var(--text-muted); }
.msg-unread-badge{ background:var(--accent); color:#fff; font-size:10.5px; font-weight:800; border-radius:10px; min-width:18px; height:18px; display:flex; align-items:center; justify-content:center; padding:0 5px; }
.msg-empty{ display:flex; flex-direction:column; align-items:center; gap:10px; text-align:center; color:var(--text-muted); padding:60px 24px; }
.msg-empty svg{ opacity:.4; }

/* Vista de conversación — en la página completa la altura es relativa al
   viewport; dentro del popup (ancho/alto fijos) se llena al 100% del
   contenedor en su lugar, ver reglas .msg-popup-body más abajo. */
.msg-thread-view{ display:none; flex-direction:column; height:calc(100dvh - 130px); }
body.app-shell-mode .msg-thread-view{ height:calc(100dvh - 160px); }
.msg-thread-header{ display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--card-border); }
.msg-thread-back{ background:none; border:none; color:var(--text-light); cursor:pointer; width:32px; height:32px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.msg-thread-person{ display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.msg-thread-name{ font-weight:700; font-size:14.5px; }
.msg-thread-status{ font-size:11.5px; color:var(--text-muted); }
.msg-thread-body{ flex:1; overflow-y:auto; padding:14px 14px 6px; display:flex; flex-direction:column; gap:8px; }
.msg-bubble{ max-width:72%; padding:9px 13px; border-radius:16px; font-size:14px; line-height:1.4; word-wrap:break-word; white-space:pre-wrap; }
.msg-bubble-them{ align-self:flex-start; background:var(--bg-dark-2); color:var(--text-light); border-bottom-left-radius:4px; }
.msg-bubble-me{ align-self:flex-end; background:var(--accent); color:#fff; border-bottom-right-radius:4px; }
.msg-bubble-image{ padding:4px; max-width:60%; }
.msg-bubble-image img{ width:100%; border-radius:12px; display:block; cursor:pointer; }
.msg-voice-bubble{ display:flex; align-items:center; gap:10px; min-width:190px; }
.msg-voice-play{ background:rgba(255,255,255,.18); border:none; color:inherit; width:30px; height:30px; border-radius:50%; flex-shrink:0; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.msg-bubble-them .msg-voice-play{ background:rgba(255,255,255,.08); }
.msg-voice-track{ flex:1; height:4px; border-radius:2px; background:rgba(255,255,255,.25); overflow:hidden; }
.msg-bubble-them .msg-voice-track{ background:var(--card-border); }
.msg-voice-fill{ height:100%; width:0%; background:currentColor; opacity:.9; }
.msg-voice-time{ font-size:11.5px; opacity:.85; flex-shrink:0; }

.msg-compose{ display:flex; align-items:center; gap:8px; padding:10px 14px calc(10px + env(safe-area-inset-bottom)); border-top:1px solid var(--card-border); }
.msg-compose-btn{ background:none; border:none; color:var(--text-muted); width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; }
.msg-compose-btn:hover{ color:var(--accent-soft); background:rgba(255,255,255,.06); }
.msg-compose-input{ flex:1; min-width:0; padding:10px 16px; border-radius:20px; border:1px solid var(--card-border); background:var(--bg-dark-2); color:var(--text-light); font-family:var(--font-body); font-size:14px; }
.msg-compose-input:focus{ outline:none; border-color:var(--accent); }
.msg-mic-btn.recording{ color:#fff; background:var(--accent); animation:msgRecPulse 1.2s infinite; }
@keyframes msgRecPulse{ 0%,100%{ box-shadow:0 0 0 0 rgba(247,2,6,.5); } 50%{ box-shadow:0 0 0 8px rgba(247,2,6,0); } }
.msg-record-indicator{ display:none; align-items:center; gap:8px; padding:0 14px 10px; font-size:13px; color:var(--accent-soft); }
.msg-record-indicator.active{ display:flex; }
.msg-record-dot{ width:8px; height:8px; border-radius:50%; background:var(--accent); animation:msgRecPulse 1.2s infinite; }
.msg-record-cancel{ margin-left:auto; background:none; border:none; color:var(--text-muted); cursor:pointer; font-size:12.5px; text-decoration:underline; }

/* Selector de amigo para nueva conversación + lightbox de imagen */
.msg-modal-overlay{ position:fixed; inset:0; z-index:2000; display:none; align-items:flex-end; justify-content:center; background:rgba(0,0,0,.55); }
.msg-modal-overlay.image-lightbox{ align-items:center; }
.msg-modal-panel{ position:relative; background:rgba(20,20,24,.98); width:100%; max-width:480px; border-radius:18px 18px 0 0; max-height:75vh; overflow-y:auto; padding:16px 0 calc(16px + env(safe-area-inset-bottom)); }
.msg-modal-panel::before{ content:''; display:block; width:36px; height:4px; border-radius:2px; background:var(--card-border); margin:0 auto 12px; }
.msg-modal-title{ padding:0 18px 10px; font-weight:800; font-size:15px; }
.msg-picker-row{ display:flex; align-items:center; gap:12px; padding:10px 18px; width:100%; background:none; border:none; color:var(--text-light); cursor:pointer; text-align:left; font-size:14px; font-weight:600; }
.msg-picker-row:hover{ background:rgba(255,255,255,.05); }
.msg-lightbox-img{ max-width:92vw; max-height:88vh; border-radius:10px; }
.msg-lightbox-close{ position:absolute; top:-40px; right:0; background:none; border:none; color:#fff; cursor:pointer; }

/* ---------- Popup de escritorio (openMessagesPopup(), layout.js) ---------- */
/* David 2026-07-22: "tiene que ser una versión popup del botón de
   dangercraft.shop/mensajes totalmente funcional... por pop up". Ancla
   sobre el círculo de Mensajes de la barra inferior — mismo ancho/alto fijo
   que ya usaba dcc-chat.js para su panel, look consistente con el resto de
   sheets/paneles flotantes del sitio. */
.msg-popup{
  position:fixed; right:24px; bottom:88px; z-index:1500;
  width:380px; height:560px; max-height:calc(100vh - 120px);
  background:var(--card-bg); border:1px solid var(--card-border); border-radius:16px;
  box-shadow:0 24px 48px -16px rgba(0,0,0,.6);
  display:flex; flex-direction:column; overflow:hidden;
  opacity:0; transform:translateY(12px) scale(.98); pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
}
.msg-popup.open{ opacity:1; transform:none; pointer-events:auto; }
.msg-popup-header{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:12px 14px; border-bottom:1px solid var(--card-border);
  font-weight:800; font-size:14px; flex-shrink:0;
}
.msg-popup-header span{ display:flex; align-items:center; gap:8px; }
.msg-popup-close{ background:none; border:none; color:var(--text-muted); cursor:pointer; width:28px; height:28px; display:flex; align-items:center; justify-content:center; border-radius:8px; }
.msg-popup-close:hover{ color:var(--text-light); background:rgba(255,255,255,.06); }
.msg-popup-body{ flex:1; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
.msg-popup-body .msg-shell{ max-width:none; height:100%; display:flex; flex-direction:column; }
.msg-popup-body #msg-mount{ flex:1; min-height:0; display:flex; flex-direction:column; }
.msg-popup-body #msg-list-view{ flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; }
.msg-popup-body .msg-list{ flex:1; }
/* El popup ya tiene su propio título "Mensajes" en msg-popup-header — el
   h1 interno de appHtml() sería redundante ahí, se oculta solo en este
   contexto (el botón de nueva conversación se queda). */
.msg-popup-body .msg-header h1{ display:none; }
.msg-popup-body .msg-header{ justify-content:flex-end; padding:10px 12px; }
/* Alturas viewport-relative no aplican dentro de un panel de tamaño fijo. */
.msg-popup-body .msg-thread-view{ height:100%; }
@media (max-width:480px){
  .msg-popup{ right:12px; left:12px; width:auto; bottom:88px; }
}
