/* ═══════════════════════════════════════════════════════════════════
   AGRON · Chat de consultas (v4.59 · Etapa 3c)
   Mismo componente en escritorio (panel lateral) y móvil (/m).
   Paleta AGRON, radius 0. Capas: debajo de los popups (z-index 100).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Escritorio: botón flotante y panel lateral ───────────────────── */
.ch-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px 0 14px;
  background: #E5B050; color: #1a1a16; border: none; border-radius: 0;
  font-family: 'Figtree', sans-serif; font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(90, 70, 30, 0.28); cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.ch-fab:hover { background: #d9a03c; box-shadow: 0 8px 22px rgba(90, 70, 30, 0.34); }
.ch-fab .ph { font-size: 20px; }
.ch-fab.ch-oculto { display: none; }

.ch-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
  width: 440px; max-width: 100vw; background: #fff;
  border-left: 1px solid #D7C3A0; box-shadow: -10px 0 30px rgba(26, 26, 22, 0.12);
  transform: translateX(100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.ch-drawer.abierto { transform: translateX(0); }

/* ── Componente ──────────────────────────────────────────────────── */
.ch { display: flex; flex-direction: column; height: 100%; min-height: 0; font-family: 'Figtree', sans-serif; color: #1a1a16; }

.ch-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  height: 56px; padding: 0 10px; border-bottom: 1px solid #ede6d8; background: #fdfaf6;
}
.ch-titulo { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding-left: 4px; }
.ch-titulo .ph { color: #B88955; font-size: 18px; }
.ch-btn-icon {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 0; color: #5a4f3a; cursor: pointer; font-size: 17px;
}
.ch-btn-icon:hover, .ch-btn-icon.activo { border-color: #D7C3A0; background: #fff; color: #1a1a16; }

.ch-cuerpo { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: #fff; }
.ch-cuerpo[hidden], .ch-hist[hidden], .ch-pie[hidden] { display: none !important; }

.ch-vacio { text-align: center; color: #5a4f3a; padding: 28px 8px 0; }
.ch-vacio > .ph { font-size: 38px; color: #D7C3A0; }
.ch-vacio p { font-size: 13px; line-height: 1.5; margin: 10px auto 18px; max-width: 320px; }
.ch-sugerencias { display: flex; flex-direction: column; gap: 8px; }
.ch-sug {
  text-align: left; padding: 10px 12px; background: #fdfaf6; border: 1px solid #ede6d8; border-radius: 0;
  font-family: inherit; font-size: 12.5px; color: #1a1a16; cursor: pointer; line-height: 1.35;
}
.ch-sug:hover { border-color: #E5B050; background: #fffaf0; }

.ch-msg { display: flex; flex-direction: column; margin-bottom: 14px; }
.ch-usuario { align-items: flex-end; }
.ch-globo { max-width: 92%; font-size: 13px; line-height: 1.5; }
.ch-usuario .ch-globo { background: #f5ead0; padding: 9px 12px; color: #1a1a16; }
.ch-asistente .ch-globo { background: #fff; padding: 2px 2px; }
.ch-error .ch-globo { background: #fdf3e0; border-left: 3px solid #E5B050; padding: 8px 12px; color: #7a4f10; }

.ch-globo p { margin: 0 0 8px; }
.ch-globo p:last-child { margin-bottom: 0; }
.ch-globo p.ch-h { font-weight: 600; margin-top: 10px; }
.ch-globo ul, .ch-globo ol { margin: 0 0 8px 18px; padding: 0; }
.ch-globo li { margin: 2px 0; }
.ch-globo li.ch-sub { margin-left: 16px; list-style: circle; }
.ch-globo strong { font-weight: 600; }
.ch-globo code { font-family: 'DM Mono', monospace; font-size: 11.5px; background: #f8f4ee; padding: 0 3px; }
.ch-globo a { color: #2c7a90; text-decoration: none; border-bottom: 1px solid rgba(44, 122, 144, .35); white-space: nowrap; }
.ch-globo a:hover { border-bottom-color: #2c7a90; }
.ch-globo a .ph { margin-right: 3px; vertical-align: -1px; }

.ch-tabla { overflow-x: auto; margin: 4px 0 10px; border: 1px solid #ede6d8; }
.ch-tabla table { border-collapse: collapse; width: 100%; font-size: 12px; }
.ch-tabla th { background: #fdfaf6; color: #5a4f3a; font-weight: 600; text-align: left; padding: 6px 8px;
  border-bottom: 1px solid #D7C3A0; white-space: nowrap; font-size: 11px; }
.ch-tabla td { padding: 5px 8px; border-bottom: 1px solid #f1ebe0; white-space: nowrap; }
.ch-tabla tr:last-child td { border-bottom: none; }

.ch-fuentes { margin-top: 6px; font-size: 11px; color: #9a8f78; display: flex; align-items: center; gap: 5px; }
.ch-fuentes .ph { font-size: 12px; }

.ch-esperando .ch-globo { display: flex; align-items: center; gap: 10px; color: #9a8f78; font-size: 12.5px; padding: 6px 2px; }
.ch-puntos { display: inline-flex; gap: 4px; }
.ch-puntos i { width: 6px; height: 6px; background: #E5B050; animation: ch-p 1.2s infinite ease-in-out; }
.ch-puntos i:nth-child(2) { animation-delay: .15s; }
.ch-puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes ch-p { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ch-pie { flex: 0 0 auto; border-top: 1px solid #ede6d8; padding: 10px 12px 10px; background: #fdfaf6; }
.ch-caja { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid #D7C3A0; padding: 6px 6px 6px 10px; }
.ch-caja:focus-within { border-color: #E5B050; }
.ch-input {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  font-family: 'Figtree', sans-serif; font-size: 13.5px; line-height: 1.4; color: #1a1a16; max-height: 140px; padding: 4px 0;
}
.ch-enviar {
  flex: 0 0 auto; width: 34px; height: 34px; border: none; border-radius: 0; background: #E5B050; color: #1a1a16;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer;
}
.ch-enviar:hover { background: #d9a03c; }
.ch-ocupado .ch-enviar { opacity: .45; pointer-events: none; }
.ch-nota { margin-top: 6px; font-size: 10.5px; color: #9a8f78; line-height: 1.35; }

.ch-hist { flex: 1; overflow-y: auto; background: #fff; }
.ch-hist-tit { font-size: 10.5px; font-weight: 700; color: #9a8f78; text-transform: uppercase; letter-spacing: .06em; padding: 14px 16px 6px; }
.ch-hist-cargando { padding: 30px 16px; text-align: center; color: #9a8f78; font-size: 13px; }
.ch-hist-item { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid #f1ebe0; cursor: pointer; }
.ch-hist-item:hover { background: #fdfaf6; }
.ch-hist-txt { flex: 1; min-width: 0; }
.ch-hist-nombre { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-hist-meta { font-size: 11px; color: #9a8f78; margin-top: 2px; }
.ch-hist-item.ch-confirmar { background: #fdf3e0; }
.ch-hist-item.ch-confirmar .ch-hist-meta { color: #a32d2d; }
.ch-hist-item.ch-confirmar .ch-hist-borrar { color: #a32d2d; border-color: #e8b4b4; }

/* ── Móvil ───────────────────────────────────────────────────────── */
.ch-movil .ch-head { height: 54px; }
.ch-movil .ch-globo { font-size: 15px; max-width: 96%; }
.ch-movil .ch-sug { font-size: 14px; padding: 12px 14px; }
.ch-movil .ch-input { font-size: 16px; }   /* 16px evita el zoom automático de iOS */
.ch-movil .ch-tabla table { font-size: 13px; }
.ch-movil .ch-pie { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

@media (max-width: 520px) {
  .ch-drawer { width: 100vw; }
  .ch-fab { right: 14px; bottom: 14px; }
}
