/* ==========================================================================
   Bandeja de WhatsApp (js/mensajes.js, V042) y Ajustes › WhatsApp (js/ajustes-whatsapp.js).
   Mismos componentes que el resto: banners, chips, pills, kv, campos de la entrada; solo tokens de css/tokens.css.
   ========================================================================== */
.msj-pagina { display: flex; flex-direction: column; gap: var(--s4); }
.msj-pagina h1:focus { outline: none; }
.msj-pagina h1:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.msj-cabecera h1 { flex: 1 1 auto; min-width: 0; font-size: var(--fs-xl); overflow-wrap: anywhere; }
.msj-cabecera .msj-nuevo { flex: none; min-height: var(--tap); }
.msj-sub { margin: calc(var(--s2) * -1) 0 0; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }

/* La bandeja */
.msj-buscar { display: flex; gap: var(--s2); }
.msj-buscar .btn { flex: none; min-height: var(--tap-lg); }
.msj-filtros { margin-top: 0; }
.msj-filtros .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.msj-filtros .chip[aria-pressed="true"] .count { background: var(--surface); color: var(--ink); }
.msj-conexion label { display: block; margin-bottom: var(--s1); font-size: var(--fs-sm); font-weight: 600; }
.msj-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.msj-item {
  display: flex; gap: var(--s3); align-items: center; min-height: var(--tap-lg); padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-radius: var(--r-md); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: inherit; text-decoration: none;
  border-left: 4px solid transparent;
}
.msj-item[data-pendiente="si"] { border-left-color: var(--warn); }
.msj-item .grow { flex: 1 1 6em; min-width: 0; display: flex; flex-direction: column; gap: var(--s1); }
.msj-item > svg:last-child { flex: none; color: var(--ink-2); }
.msj-avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: var(--fs-sm);
}
.msj-fila { display: flex; gap: var(--s2); align-items: baseline; justify-content: space-between; min-width: 0; }
.msj-nombre { font-weight: 700; overflow-wrap: anywhere; }
.msj-hora { flex: none; font-size: var(--fs-xs); color: var(--ink-2); }
.msj-resumen { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msj-pills { display: flex; flex-wrap: wrap; gap: var(--s1); }
.msj-pills .pill, .msj-pill-asistente { display: inline-flex; align-items: center; gap: 4px; }
.msj-pills .pill svg.ic { width: 14px; height: 14px; }

/* Quién atiende */
.msj-estado { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); }
.msj-estado > svg.ic { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.msj-estado p { margin: 0; }
.msj-estado-t { font-weight: 700; }
.msj-estado-s { font-size: var(--fs-sm); color: var(--ink-2); }
.msj-acciones { margin-top: calc(var(--s2) * -1); }
.msj-sugerencia { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--info-soft); }
.msj-sugerencia p { margin: 0; }
.msj-sug-t { display: flex; gap: var(--s1); align-items: center; font-size: var(--fs-sm); font-weight: 700; color: var(--info); }
.msj-sug-t svg.ic { width: 18px; height: 18px; }
.msj-sug-x { margin-top: var(--s1); white-space: pre-wrap; overflow-wrap: anywhere; }
.msj-sugerencia .btn { margin-top: var(--s2); min-height: var(--tap); }

/* El hilo: entrantes a la izquierda, salientes a la derecha (como en el teléfono) */
.msj-hilo {
  display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-radius: var(--r-md); background: var(--ground);
  box-shadow: inset 0 0 0 1px var(--line); max-height: min(60vh, 560px); overflow-y: auto; overscroll-behavior: contain;
}
.msj-dia { align-self: center; margin: var(--s2) 0; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.msj-dia span { padding: 2px var(--s3); border-radius: var(--r-pill); background: var(--surface-2); }
.msj-m { display: flex; flex-direction: column; max-width: min(86%, 520px); }
.msj-m[data-dir="entrante"] { align-self: flex-start; }
.msj-m[data-dir="saliente"] { align-self: flex-end; align-items: flex-end; }
.msj-m[data-sistema="si"] { align-self: center; max-width: 100%; }
.msj-origen { display: flex; gap: 4px; align-items: center; margin: 0 0 2px; padding: 0 var(--s2); font-size: var(--fs-xs); color: var(--ink-2); }
.msj-origen svg.ic { width: 14px; height: 14px; }
.msj-burbuja {
  position: relative; padding: var(--s2) var(--s3); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--card-shadow);
  overflow-wrap: anywhere;
}
.msj-m[data-dir="entrante"] .msj-burbuja { border-top-left-radius: var(--r-sm); }
.msj-m[data-dir="saliente"] .msj-burbuja { background: var(--accent-soft); border-top-right-radius: var(--r-sm); }
.msj-m[data-origen="asistente"] .msj-burbuja, .msj-m[data-origen="externo"] .msj-burbuja { background: var(--info-soft); }
.msj-m[data-sistema="si"] .msj-burbuja { background: var(--surface-2); font-size: var(--fs-sm); color: var(--ink-2); }
.msj-texto { margin: 0; white-space: pre-wrap; }
.msj-plantilla { display: flex; gap: var(--s1); align-items: center; margin: var(--s1) 0 0; font-size: var(--fs-xs); color: var(--ink-2); }
.msj-plantilla svg.ic { width: 14px; height: 14px; }
.msj-foto { display: block; max-width: 100%; max-height: 320px; border-radius: var(--r-sm); margin-bottom: var(--s1); }
.msj-medio { margin-top: var(--s1); min-height: var(--tap); }
.msj-burbuja .help { display: flex; gap: var(--s1); align-items: center; margin-top: var(--s1); }
.msj-burbuja .help svg.ic { width: 16px; height: 16px; }
.msj-pie { display: flex; gap: var(--s1); align-items: center; justify-content: flex-end; margin-top: 2px; font-size: var(--fs-xs); color: var(--ink-2); }
.msj-ticks { display: inline-flex; align-items: center; }
.msj-ticks svg.ic { width: 16px; height: 16px; }
.msj-ticks[data-estado="leido"] { color: var(--info); }
.msj-ticks[data-estado="fallido"] { color: var(--crit); }
.msj-ticks[data-estado="incierto"] { color: var(--warn); }
.msj-aviso { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: var(--s1) 0 0; padding: var(--s2) var(--s3); border-radius: var(--r-md); font-size: var(--fs-sm); }
.msj-aviso[data-tono="crit"] { background: var(--crit-soft); color: var(--crit); }
.msj-aviso[data-tono="warn"] { background: var(--warn-soft); color: var(--warn); }
.msj-aviso > svg.ic { width: 18px; height: 18px; flex: none; }
.msj-aviso > span { flex: 1 1 12em; }
.msj-aviso .btn { min-height: var(--tap); }
.msj-reintentado { font-weight: 600; }
.msj-m .help { margin: var(--s1) 0 0; }

/* Responder */
.msj-redactor { display: flex; flex-direction: column; gap: var(--s2); }
.msj-caja { display: flex; gap: var(--s2); align-items: flex-end; }
.msj-area { min-height: var(--tap-lg); padding: var(--s3) var(--s4); font-size: var(--fs-md); resize: vertical; }
.msj-caja .msj-area { flex: 1 1 auto; min-width: 0; }
.msj-enviar { flex: none; min-height: var(--tap-lg); }
.msj-redactor .help, .msj-sin-permiso { display: flex; gap: var(--s2); align-items: flex-start; margin: 0; }
.msj-redactor .help svg.ic, .msj-sin-permiso svg.ic { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.msj-redactor .btn { align-self: flex-start; min-height: var(--tap); }
@container app (max-width: 400px) { .msj-enviar-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }

/* Notas internas y línea de tiempo */
.msj-notas .help, .msj-eventos .help { margin: var(--s1) 0 0; }
.msj-notas-lista, .msj-eventos-lista { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.msj-notas-lista li { padding: var(--s3); border-radius: var(--r-md); background: var(--warn-soft); }
.msj-notas-lista li p:first-child { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msj-notas-lista .btn { margin-top: var(--s1); min-height: var(--tap); }
.msj-nota-form { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3); }
.msj-nota-form .btn { align-self: flex-start; min-height: var(--tap); }
.msj-eventos-lista li { padding: var(--s2) 0; border-top: 1px solid var(--line); }
.msj-eventos-lista p { margin: 0; }
.msj-kv { margin-bottom: 0; }

/* Ajustes › WhatsApp */
.wa-acciones { display: flex; flex-wrap: wrap; gap: var(--s1); width: 100%; }
.wa-acciones .btn { min-height: var(--tap); }
.wa-peligro { color: var(--crit); }
.wa-error { display: flex; gap: var(--s1); align-items: flex-start; color: var(--crit); }
.wa-error svg.ic { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.wa-form { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.wa-menu { margin-top: var(--s2); }
.wa-bloque { border: 0; margin: 0 0 var(--s2); padding: var(--s3); border-radius: var(--r-md); background: var(--surface-2); }
.wa-dias { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s2); }
.wa-dia { display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.wa-dia input { width: 20px; height: 20px; accent-color: var(--accent); }
.wa-dia:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
