/* =========================================================
   mural "WhatsApp" - replica visual de WhatsApp Web
   Medidas en rem: toda la interfaz escala junto con el tamaño
   de letra raíz (ver "Escala", mismo patron que el resto de
   murales de VISTAS/, ej. mailv/styles.css).
   ========================================================= */

:root {
  --wa-header: #075e54;
  --wa-header-dark: #1f2c34;
  --wa-panel: #ffffff;
  --wa-panel-2: #f0f2f5;
  --wa-hover: #f5f6f6;
  --wa-border: #e9edef;
  --wa-text: #111b21;
  --wa-muted: #667781;
  --wa-chat-bg: #efeae2;
  --wa-bubble-ajena: #ffffff;
  --wa-bubble-propia: #d9fdd3;
  --wa-check: #53bdeb;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wa-header: #1f2c34;
    --wa-header-dark: #1f2c34;
    --wa-panel: #111b21;
    --wa-panel-2: #202c33;
    --wa-hover: #202c33;
    --wa-border: #222d34;
    --wa-text: #e9edef;
    --wa-muted: #8696a0;
    --wa-chat-bg: #0b141a;
    --wa-bubble-ajena: #202c33;
    --wa-bubble-propia: #005c4b;
    --wa-check: #53bdeb;
    color-scheme: dark;
  }
}

/* ---------- Escala (mismo patron que mailv/styles.css) ---------- */
html { font-size: 100%; }
@media (min-width: 1800px) { html { font-size: 106.25%; } }
@media (min-width: 2400px) { html { font-size: 125%; } }
@media (min-width: 3200px) { html { font-size: 150%; } }
html.tv { font-size: 18px; }
@media (max-width: 1100px) { html.tv { font-size: 16px; } }
@media (min-width: 1600px) { html.tv { font-size: 24px; } }
@media (min-width: 2400px) { html.tv { font-size: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { background: var(--wa-chat-bg); color: var(--wa-text); font: 1rem/1.4 "Segoe UI", Helvetica, Arial, sans-serif; overflow: hidden; }

.app { display: flex; width: 100%; height: 100vh; }

/* ---------- Sidebar (lista de chats) ---------- */
.sidebar { width: 26rem; max-width: 36vw; min-width: 16rem; background: var(--wa-panel); border-right: 1px solid var(--wa-border); display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 1rem 1.1rem; background: var(--wa-header); color: #fff; flex: none; }
.brand-mark { font-size: 1.4rem; }
.brand-name { font-weight: 600; font-size: 1.05rem; }

.chat-list { flex: 1; overflow-y: auto; }
.sidebar-vacio { padding: 2rem 1.2rem; color: var(--wa-muted); text-align: center; font-size: 0.9rem; }

.chat-item { display: flex; width: 100%; align-items: center; gap: 0.75rem; padding: 0.7rem 1rem; border: none; background: none; text-align: left; cursor: pointer; border-bottom: 1px solid var(--wa-border); color: var(--wa-text); font: inherit; }
.chat-item:hover { background: var(--wa-hover); }
.chat-item.activo { background: var(--wa-panel-2); }

.avatar { flex: none; width: 3rem; height: 3rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.05rem; }

.chat-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.chat-item-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.chat-item-nombre { font-weight: 600; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-hora { flex: none; font-size: 0.76rem; color: var(--wa-muted); }
.chat-item-preview { color: var(--wa-muted); font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Panel principal (conversacion) ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--wa-chat-bg); }

.chat-header { flex: none; display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 1.1rem; background: var(--wa-panel); border-bottom: 1px solid var(--wa-border); min-height: 3.9rem; }
.chat-header:empty { background: var(--wa-panel-2); }
.chat-header-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-header-txt strong { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-txt small { color: var(--wa-muted); font-size: 0.78rem; }
.btn-automatico { flex: none; border: 1px solid var(--wa-check); color: var(--wa-check); background: none; border-radius: 1.2rem; padding: 0.35rem 0.9rem; font: inherit; font-size: 0.82rem; cursor: pointer; }
.btn-automatico:hover { background: var(--wa-check); color: #fff; }

.messages { flex: 1; overflow-y: auto; padding: 1rem 5%; display: flex; flex-direction: column; gap: 0.18rem; }
.sin-seleccion { margin: auto; color: var(--wa-muted); text-align: center; font-size: 0.95rem; max-width: 20rem; }

.burbuja { display: flex; max-width: 72%; }
.burbuja.propia { align-self: flex-end; justify-content: flex-end; }
.burbuja.ajena { align-self: flex-start; }
.burbuja-cuerpo { position: relative; padding: 0.4rem 0.6rem 0.35rem; border-radius: 0.5rem; box-shadow: 0 1px 0.4px rgba(0,0,0,.13); display: inline-flex; flex-direction: column; gap: 0.1rem; }
.burbuja.ajena .burbuja-cuerpo { background: var(--wa-bubble-ajena); border-top-left-radius: 0; }
.burbuja.propia .burbuja-cuerpo { background: var(--wa-bubble-propia); border-top-right-radius: 0; }
.burbuja-nombre { font-size: 0.82rem; font-weight: 700; }
.burbuja-texto { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; padding-right: 2.6rem; }
.burbuja.media .burbuja-texto { font-style: italic; color: var(--wa-muted); }
.burbuja-hora { position: absolute; right: 0.55rem; bottom: 0.3rem; font-size: 0.68rem; color: var(--wa-muted); }

/* Barra de "escribir" decorativa (mural de solo lectura, nunca envia nada) */
.composer { flex: none; display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1.1rem; background: var(--wa-panel); }
.composer-icon { font-size: 1.3rem; opacity: 0.55; }
.composer-input { flex: 1; background: var(--wa-panel-2); border-radius: 1.4rem; padding: 0.55rem 1rem; color: var(--wa-muted); font-size: 0.88rem; }

/* ---------- Aviso de conexion (mismo patron que mailv/calv) ---------- */
.avisos-fijos { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 35; display: flex; justify-content: flex-end; pointer-events: none; }
.avisos-fijos > * { pointer-events: auto; max-width: 70%; }
.estado-conexion { padding: 0.5rem 0.875rem; border-radius: 99px; font-size: 0.85rem; font-weight: 600; box-shadow: 0 6px 18px rgba(16,24,40,.25); background: #b42318; color: #fff; }
.estado-conexion[hidden] { display: none; }

/* ---------- Angosto: sidebar se reduce, no se apila (mural, no celular) ---------- */
@media (max-width: 760px) {
  .sidebar { width: 11.5rem; min-width: 9rem; }
  .chat-item-preview, .chat-header-txt small { display: none; }
  .burbuja { max-width: 86%; }
}
@media (max-width: 480px) {
  .sidebar { width: 4.6rem; min-width: 4.6rem; }
  .chat-item { flex-direction: column; gap: 0.3rem; padding: 0.55rem 0.3rem; text-align: center; }
  .chat-item-txt { width: 100%; align-items: center; }
  .chat-item-top { flex-direction: column; gap: 0; }
  .chat-item-hora { display: none; }
  .chat-item-nombre { font-size: 0.68rem; max-width: 100%; }
  .composer-input { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .burbuja { max-width: 94%; }
}
