/* ═══════════ Fase 5 · Chat privado + convivencia (denuncias, bloqueos, moderación) ═══════════ */

/* Comunes: badge numérico, botón peligro, hoja de acciones, motivos de denuncia */
.dot-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; display: inline-block;
}
.dot-badge[hidden] { display: none; }
.hdr-msg { position: relative; }
.hdr-msg .dot-badge { position: absolute; top: -4px; right: -4px; box-shadow: 0 0 0 2px var(--bg-primary); }
#header-user { display: flex; align-items: center; gap: .5rem; }
.menu-grid a { position: relative; }
.menu-grid a .dot-badge { position: absolute; top: 8px; right: 10px; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.06); }
.btn-denunciar { color: var(--text-secondary); }
.btn-denunciar .lucide { color: var(--danger); }

.lista-check { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .4rem; color: var(--text-secondary); }

.den-motivos { display: flex; flex-direction: column; gap: .45rem; }
.den-opt {
  display: flex; align-items: center; gap: .7rem; min-height: 46px; padding: .55rem .85rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-primary); cursor: pointer; font-size: 14px;
}
.den-opt input { width: 18px; height: 18px; accent-color: var(--danger); margin: 0; flex-shrink: 0; }
.den-opt:hover { background: var(--bg-secondary); }
.den-opt.sel, .den-opt:focus-within { border-color: var(--danger); background: rgba(192,57,43,.06); }
.field.invalid .den-opt { border-color: var(--danger); }

.hoja { display: flex; flex-direction: column; gap: .35rem; }
.hoja-op {
  display: flex; align-items: center; gap: .8rem; min-height: 50px; padding: .6rem .9rem; border-radius: 12px;
  border: 0; background: var(--bg-secondary); color: var(--text-primary); font-size: 15px; font-weight: 500; text-align: left;
}
.hoja-op .lucide { width: 20px; height: 20px; color: var(--accent); }
.hoja-op.peligro, .hoja-op.peligro .lucide { color: var(--danger); }
.hoja-op:hover { background: var(--bg-tertiary); }

.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }

/* ───────── Layout del chat ───────── */
.en-chat .wa-float, .en-chat .site-footer { display: none !important; }
.chat-container { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.chat-shell {
  display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - var(--header-h) - 2.5rem);
  min-height: 460px; border: 1px solid var(--border); border-radius: var(--radius-l); overflow: hidden;
  background: var(--bg-primary); box-shadow: 0 18px 50px -30px var(--shadow);
}
.chat-lista { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--bg-secondary); }
.chat-lista-head { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; padding: 1.1rem 1.1rem .6rem; }
.chat-lista-head h1 { margin: .1rem 0 0; font-size: 24px; letter-spacing: -.02em; }
.chat-lista-head .badge { background: var(--danger); color: #fff; }
.chat-buscar { padding: 0 1.1rem .8rem; }
.chat-buscar > .lucide { left: 2rem; }
.chat-buscar input {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-primary); font: inherit; font-size: 14px; padding-right: .8rem;
}
.chat-buscar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-convs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 .5rem .75rem; }
.conv {
  width: 100%; display: flex; align-items: center; gap: .75rem; padding: .7rem .65rem; border: 0; border-radius: 14px;
  background: transparent; color: var(--text-primary); text-align: left; min-height: 64px; position: relative;
}
.conv:hover { background: var(--bg-tertiary); }
.conv.activa { background: var(--bg-primary); box-shadow: inset 3px 0 0 var(--accent), 0 2px 10px -6px var(--shadow); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top { display: flex; align-items: center; gap: .4rem; }
.conv-top strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-top .badge { font-size: 10px; padding: 1px 6px; }
.conv-top time { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.conv-prev { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-prev .vos { color: var(--text-muted); }
.conv-prev .ico-bloq { width: 13px; height: 13px; color: var(--danger); vertical-align: -2px; margin-right: 3px; }
.conv.no-leida .conv-top strong, .conv.no-leida .conv-prev { color: var(--text-primary); font-weight: 700; }
.conv.no-leida .conv-top time { color: var(--accent); font-weight: 600; }
.conv-skel { height: 64px; margin: .35rem .6rem; border-radius: 14px; background: linear-gradient(90deg, var(--bg-tertiary), var(--bg-primary), var(--bg-tertiary)); background-size: 200% 100%; animation: chatSkel 1.2s infinite linear; }
@keyframes chatSkel { to { background-position: -200% 0; } }
.chat-empty { padding: 2rem 1rem; }
.chat-empty img { max-width: 170px; }
.chat-placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ───────── Hilo ───────── */
.chat-hilo { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative;
  background: var(--bg-primary);
  background-image: radial-gradient(circle at 1px 1px, var(--bg-tertiary) 1px, transparent 0); background-size: 22px 22px; }
.hilo-head {
  display: flex; align-items: center; gap: .6rem; padding: .65rem .9rem; border-bottom: 1px solid var(--border);
  background: var(--bg-primary); min-height: 66px;
}
.hilo-back { display: none; }
.hilo-quien { display: flex; align-items: center; gap: .7rem; min-width: 0; flex: 1; color: var(--text-primary); }
.hilo-quien > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.hilo-quien strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hilo-quien small { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hilo-msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem 1.1rem .5rem; display: flex; flex-direction: column; }
.hilo-mas { text-align: center; margin-bottom: .75rem; }
.hilo-aviso {
  align-self: center; max-width: 520px; display: flex; gap: .55rem; align-items: flex-start; font-size: 12px; line-height: 1.45;
  color: var(--text-secondary); background: var(--bg-secondary); border: 1px dashed var(--border); border-radius: 12px; padding: .55rem .8rem; margin-bottom: .9rem;
}
.hilo-aviso .lucide { width: 16px; height: 16px; color: var(--success); flex-shrink: 0; margin-top: 1px; }
.hilo-vacio { text-align: center; padding: 2.5rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.hilo-vacio h3 { margin: .6rem 0 0; }
.hilo-dia { text-align: center; margin: .9rem 0 .6rem; }
.hilo-dia span { font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border); padding: 3px 12px; border-radius: 999px; }

.msg { display: flex; margin: 2px 0; }
.msg.mio { justify-content: flex-end; }
.burbuja {
  max-width: min(78%, 560px); padding: .5rem .75rem .35rem; border-radius: 18px; font-size: 15px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: anywhere; cursor: pointer; position: relative; outline: none;
  -webkit-user-select: text; user-select: text;
}
.burbuja:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.msg.suyo .burbuja { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.mio .burbuja { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.msg.mio .burbuja a { color: inherit; text-decoration: underline; }
.burbuja .meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; font-size: 11px; opacity: .75; margin-top: 2px; }
.burbuja .meta .lucide { width: 14px; height: 14px; }
.msg.mio .tilde.leido { color: var(--sun); opacity: 1; }
.msg.enviando .burbuja { opacity: .7; }
.msg.error .burbuja { background: var(--bg-primary); color: var(--danger); border: 1px solid var(--danger); }
.msg.moderado .burbuja, .msg.eliminado .burbuja {
  background: transparent; color: var(--text-muted); border: 1px dashed var(--border); font-style: italic; font-size: 13px; cursor: default;
}
.msg.moderado .burbuja > .lucide, .msg.eliminado .burbuja > .lucide { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }

.hilo-compose { border-top: 1px solid var(--border); background: var(--bg-primary); padding: .6rem .75rem; padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }
.hilo-compose form { display: flex; align-items: flex-end; gap: .5rem; position: relative; }
.hilo-compose textarea {
  flex: 1; resize: none; min-height: 46px; max-height: 140px; padding: .7rem 1rem; border-radius: 22px;
  border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font: inherit; font-size: 15px; line-height: 1.4;
}
.hilo-compose textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hilo-compose .contador { position: absolute; right: 64px; top: -20px; font-size: 11px; color: var(--text-muted); }
.hilo-enviar { width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%; flex-shrink: 0; }
.hilo-cerrado { display: flex; align-items: center; gap: .6rem; justify-content: center; flex-wrap: wrap; font-size: 14px; color: var(--text-secondary); padding: .35rem; text-align: center; }
.hilo-cerrado .lucide { width: 18px; height: 18px; color: var(--text-muted); }

@media (max-width: 900px) {
  .chat-shell { grid-template-columns: 1fr; }
  .chat-shell .chat-hilo { display: none; }
  .chat-shell.con-hilo .chat-lista { display: none; }
  .chat-shell.con-hilo .chat-hilo { display: flex; }
  .hilo-back { display: inline-flex; }
}
@media (max-width: 768px) {
  .chat-container { padding: 0; }
  .chat-shell { border: 0; border-radius: 0; box-shadow: none; min-height: 0;
    height: calc(100vh - var(--header-h) - var(--footer-h) - env(safe-area-inset-bottom)); }
  .en-chat .main-content { padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); }
  /* Hilo abierto: pantalla completa estilo app, sin footer nav */
  .chat-hilo-abierto .app-footer-nav { display: none; }
  .chat-hilo-abierto .main-content { padding-bottom: 0; }
  .chat-hilo-abierto .chat-shell { height: calc(100vh - var(--header-h)); }
  .burbuja { max-width: 84%; }
}
@supports (height: 100dvh) {
  .chat-shell { height: calc(100dvh - var(--header-h) - 2.5rem); }
  @media (max-width: 768px) {
    .chat-shell { height: calc(100dvh - var(--header-h) - var(--footer-h) - env(safe-area-inset-bottom)); }
    .chat-hilo-abierto .chat-shell { height: calc(100dvh - var(--header-h)); }
  }
}

/* ───────── Mi perfil: privacidad y bloqueados ───────── */
.bloq-list { display: flex; flex-direction: column; gap: .5rem; }
.bloq-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-primary); }
.bloq-item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bloq-item .info small { color: var(--text-muted); font-size: 12px; }

/* ───────── Moderación (admin) ───────── */
.mod-kpis { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.mod-kpi { flex: 1 1 140px; padding: .9rem 1rem; border-radius: var(--radius-m); background: var(--bg-secondary); border: 1px solid var(--border); }
.mod-kpi strong { display: block; font-size: 26px; letter-spacing: -.03em; }
.mod-kpi span { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.mod-kpi.alerta { border-color: var(--danger); background: rgba(192,57,43,.06); }
.mod-kpi.alerta strong { color: var(--danger); }
.mod-filtros { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.mod-filtros .chips { flex: 1 1 100%; }
.mod-filtros .input-icon { flex: 1 1 240px; }
.mod-filtros input, .mod-filtros select {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-primary);
  color: var(--text-primary); font: inherit; font-size: 14px; padding: .5rem .8rem;
}
.mod-filtros .input-icon input { padding-left: 2.6rem; }
.mod-filtros select { flex: 0 1 200px; width: auto; }
.mod-lista { display: flex; flex-direction: column; gap: .75rem; }
.den-card {
  border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--bg-primary); padding: 1rem 1.1rem;
  display: grid; grid-template-columns: 1fr auto; gap: .75rem 1rem; position: relative; overflow: hidden;
}
.den-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--border); }
.den-card.pendiente::before { background: var(--danger); }
.den-card.revisada::before { background: var(--sun); }
.den-card.resuelta::before { background: var(--success); }
.den-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; grid-column: 1 / -1; }
.den-top .badge { text-transform: capitalize; }
.den-top time { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.den-obj { grid-column: 1 / -1; background: var(--bg-secondary); border-radius: 12px; padding: .65rem .8rem; font-size: 14px; }
.den-obj .label { display: block; margin-bottom: 2px; }
.den-obj q { quotes: '“' '”'; white-space: pre-wrap; overflow-wrap: anywhere; }
.den-quien { font-size: 13px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 2px; }
.den-quien strong { color: var(--text-primary); }
.den-motivo { grid-column: 1 / -1; font-size: 14px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.den-acciones { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; }
.den-resolucion { grid-column: 1 / -1; font-size: 13px; color: var(--text-secondary); border-top: 1px dashed var(--border); padding-top: .6rem; }
.badge.rojo { background: rgba(192,57,43,.12); color: var(--danger); }
.badge.verde { background: rgba(31,138,59,.12); color: var(--success); }
@media (max-width: 768px) {
  .den-card { grid-template-columns: 1fr; padding: .9rem; }
  .den-acciones .btn { flex: 1 1 auto; }
}

/* Header con sesión (ícono de mensajes): que nada se pise */
.app-header .brand { flex-shrink: 0; }
.header-nav { min-width: 0; overflow: hidden; }
@media (max-width: 1440px) { .app-header.con-sesion .user-chip .hide-mobile { display: none !important; } .app-header.con-sesion .user-chip { padding-right: .25rem; } }
@media (max-width: 1180px) { .app-header.con-sesion .header-nav { margin-left: .5rem; } .app-header.con-sesion .header-nav a { padding: .5rem .55rem; } }
@media (max-width: 480px) { .app-header.con-sesion .brand-name { display: none; } .app-header.con-sesion .loc-pill { max-width: 170px; } }
.den-top .badge { text-transform: none; letter-spacing: .01em; }
.mod-kpi { flex: 0 1 220px; }

/* Admin pagos */
.admin-pagos .chip.sm { min-height: 44px; }
.admin-pagos .den-quien, .admin-pagos .den-obj, .admin-pagos .den-top { min-width: 0; overflow-wrap: anywhere; }
.admin-pagos .mod-kpi strong { overflow-wrap: anywhere; }
.admin-pagos .ap-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.ap-check { display: flex; align-items: center; gap: .6rem; min-height: 44px; cursor: pointer; }
.field .ap-check input { appearance: auto; -webkit-appearance: checkbox; width: 22px; min-height: 22px; height: 22px; flex-shrink: 0; padding: 0; accent-color: var(--accent); }
.ap-precio-fila { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 44px; gap: .6rem; align-items: end; margin-bottom: .6rem; }
.ap-precio-fila label { min-width: 0; }
.ap-precio-fila input { margin-top: .35rem; }
.ap-webhook { display: flex; flex-wrap: wrap; gap: .5rem; }
.ap-webhook input { flex: 1 1 240px; min-width: 0; }
.ap-comprobante { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 12px; }
.admin-pagos-modal .modal-footer { flex-shrink: 0; }
