/* Lovendo · Widget de mensajes (messages.js). Colores y tipografía del tema (var(--…)); nada nuevo.
   Capas: barra superior 100 · navegación inferior 200 · botón «Mensajes» y acceso a la encuesta 450 · fichas 500 · ofertas 600 ·
   panel de mensajes 610 · diálogos de cuenta/encuesta 700–720 · valoración 820 · avisos 900. */

/* nombre y título largos: una línea con puntos suspensivos; al tocar se ve el texto completo (y queda en el atributo title) */
#lv-msgw .chat-seller-name, #lv-msgw .chat-product-ref { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lv-msgw .chat-info.expanded { max-height: 38vh; max-height: 38dvh; overflow-y: auto; }
#lv-msgw .chat-info.expanded .chat-seller-name, #lv-msgw .chat-info.expanded .chat-product-ref { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
#lv-msgw .chat-messages { flex: 1; min-height: 120px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.lvmw-sr { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.lvmw[hidden] { display: none !important; }

/* ── botón «Mensajes» ── */
.lvmw-btn { position: fixed; right: 24px; bottom: 24px; z-index: 450; display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px;
  border: none; border-radius: 999px; background: var(--coral); color: #fff; font-family: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 28px rgba(23,41,59,.22); transition: background .15s, transform .15s; }
.lvmw-btn:hover { background: var(--coral-dark); }
.lvmw-btn .material-symbols-outlined { font-size: 20px; }
.lvmw-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #fff; color: var(--coral-dark); font-size: 12px; font-weight: 800;
  align-items: center; justify-content: center; line-height: 1; }
html.lvmw-open .lvmw-btn { visibility: hidden; }   /* con el panel abierto, el botón no compite con «Enviar» ni con «Cerrar» */

/* ── panel (lista + conversación) ── */
.lvmw-panel { position: fixed; right: 24px; bottom: 24px; z-index: 610; width: 380px; max-width: calc(100vw - 32px);
  height: 600px; height: min(600px, calc(100dvh - 48px)); max-height: calc(100vh - 48px);
  flex-direction: column; background: var(--white); border: 1px solid var(--border); border-radius: var(--r-xl, 28px); overflow: hidden;
  box-shadow: 0 24px 64px rgba(23,41,59,.28); font-family: inherit; color: var(--ink); }
.lvmw-view { display: none; flex-direction: column; flex: 1; min-height: 0; }
#lv-msgw .lvmw-view { padding: 0; margin: 0; }   /* las páginas dan relleno a todo <section> */
.lvmw-view.open { display: flex; }
#lv-msgw .chat-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
#lv-msgw .chat-av { width: 36px; height: 36px; border-radius: 50%; background: var(--coral); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; }
#lv-msgw .chat-av .material-symbols-outlined { color: #fff; font-size: 20px; }
#lv-msgw .lvmw-titles, #lv-msgw .chat-info { min-width: 0; flex: 1 1 auto; }
#lv-msgw .chat-info { cursor: pointer; border-radius: var(--r-sm, 8px); }
#lv-msgw .chat-seller-name { font-size: 14px; font-weight: 700; }
#lv-msgw .chat-product-ref { font-size: 12px; color: var(--ink-soft); }
#lv-msgw .chat-close { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; flex-shrink: 0; }
#lv-msgw .lvmw-back { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--white); color: var(--ink-mid); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; padding: 0; }
#lv-msgw .lvmw-back[hidden] { display: none; }
#lv-msgw .lvmw-sub { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--border); }
#lv-msgw .lvmw-sub[hidden] { display: none; }
#lv-msgw .lvmw-listing { flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--coral-dark); text-decoration: none; padding: 6px 4px; white-space: nowrap; }
#lv-msgw .lvmw-listing[hidden] { display: none; }
#lv-msgw .lvmw-listing:hover { text-decoration: underline; }
#lv-msgw #chat-review-btn { flex-shrink: 0; background: var(--coral-light); color: var(--coral-dark); border: 1px solid var(--coral-mid); border-radius: 999px; font-family: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 10px; cursor: pointer; align-items: center; gap: 4px; }
#lv-msgw #chat-review-btn .material-symbols-outlined { font-size: 16px; }
#lv-msgw .lvmw-list { flex: 1; overflow-y: auto; padding: 8px; }
#lv-msgw .chat-msg { max-width: 78%; }
#lv-msgw .chat-msg.them { align-self: flex-start; }
#lv-msgw .chat-msg.me { align-self: flex-end; }
#lv-msgw .chat-bubble { padding: 10px 14px; border-radius: var(--r-md, 14px); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
#lv-msgw .chat-msg.them .chat-bubble { background: var(--surface); color: var(--ink); }
#lv-msgw .chat-msg.me .chat-bubble { background: var(--coral); color: #fff; }
#lv-msgw .chat-time { font-size: 10px; color: var(--ink-soft); margin-top: 3px; padding: 0 4px; }
#lv-msgw .chat-msg.me .chat-time { text-align: right; }
#lv-msgw .quick-replies { display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px; scrollbar-width: none; border-top: 1px solid var(--border); }
#lv-msgw .qr { flex-shrink: 0; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--border); font-family: inherit; font-size: 12px; font-weight: 600; color: var(--ink-mid); cursor: pointer; background: var(--white); white-space: nowrap; }
#lv-msgw .qr[hidden] { display: none; }
#lv-msgw .qr:hover { border-color: var(--coral); color: var(--coral-dark); background: var(--coral-light); }
#lv-msgw .chat-input-row { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--white); }
#lv-msgw .chat-input { flex: 1; min-width: 0; padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 999px; font-size: 16px; font-family: inherit; outline: none; background: var(--white); color: var(--ink); }
#lv-msgw .chat-input:focus { border-color: var(--coral); }
#lv-msgw .chat-send { background: var(--coral); color: #fff; border: none; border-radius: 50%; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; font-size: 16px; }
#lv-msgw .chat-send:hover { background: var(--coral-dark); }
#lv-msgw .chat-send:disabled, #lv-msgw .chat-input:disabled, #lv-msgw .qr:disabled { opacity: .55; cursor: default; }
.lvmw-status { padding: 8px 14px; background: var(--amber-light); color: var(--ink); font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--amber); }
.lvmw-status[hidden] { display: none; }

/* poco alto disponible (teclado abierto, móvil horizontal, zoom): el panel usa todo el alto y se quitan las respuestas rápidas */
@media (max-height: 560px) {
  .lvmw-panel { top: 0; bottom: 0; height: auto; max-height: none; border-radius: 0; }
  #lv-msgw .chat-header { padding: 8px 14px; }
  #lv-msgw .quick-replies { display: none; }
}
/* móvil: el botón queda sobre la navegación inferior (área segura incluida); el panel ocupa la pantalla visible (también con teclado) */
@media (max-width: 639px) {
  .lvmw-btn { right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); padding: 11px 16px; }
  .lvmw-panel { right: 0; left: 0; bottom: auto; top: var(--lvmw-top, 0px); width: 100%; max-width: none; height: 100vh; height: var(--lvmw-vh, 100dvh); max-height: none; border-radius: 0; border: none; }
  #lv-msgw .chat-input-row { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  html.lvmw-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .lvmw-btn { transition: none; } }
