/* chat-asesor.js — panel de chat en vivo con asesor (landing). Autónomo. */

/* puntito de disponibilidad en la opción del menú */
#chat-widget-asesor-btn { position: relative; }
.chat-menu-asesor .asesor-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1;
  margin-left: auto; flex: 0 0 9px;
}
.chat-menu-asesor .asesor-dot.on {
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25);
}

/* panel */
.asesor-panel {
  position: fixed; bottom: 24px; left: 24px; z-index: 2147483000;
  width: 360px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 48px);
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.28);
  display: none; flex-direction: column;
  font-family: 'Plus Jakarta Sans', 'Segoe UI', Roboto, Arial, sans-serif;
}
.asesor-panel.active { display: flex; animation: asesorUp .22s ease-out; }
@keyframes asesorUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 480px) { .asesor-panel { left: 8px; right: 8px; width: auto; bottom: 8px; height: calc(100vh - 16px); } }

.asesor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; background: linear-gradient(135deg, #6C3AED 0%, #4C1D95 100%); color: #fff;
}
.asesor-head-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.asesor-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; flex: 0 0 38px;
}
.asesor-title { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.asesor-status { font-size: .72rem; color: rgba(255,255,255,.82); margin-top: 2px; }
.asesor-status.on::before { content: '● '; color: #6ee7b7; }
.asesor-status.off::before { content: '● '; color: #fca5a5; }
.asesor-x { background: none; border: 0; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.asesor-x:hover { background: rgba(255,255,255,.15); }

.asesor-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f8fafc; }

/* form pre-chat */
.asesor-intro { padding: 16px 16px 8px; font-size: .86rem; color: #475569; line-height: 1.4; }
.asesor-form { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 9px; }
.asesor-form input, .asesor-form select, .asesor-form textarea {
  width: 100%; border: 1px solid #d7dce5; border-radius: 10px; padding: 10px 12px;
  font-size: .88rem; color: #0f172a; background: #fff; outline: none; box-sizing: border-box; font-family: inherit;
}
.asesor-form input:focus, .asesor-form select:focus, .asesor-form textarea:focus { border-color: #6C3AED; }
.asesor-form textarea { resize: vertical; }
.asesor-btn {
  width: 100%; border: 0; border-radius: 10px; padding: 12px; cursor: pointer;
  background: linear-gradient(135deg, #6C3AED 0%, #4C1D95 100%); color: #fff; font-weight: 700; font-size: .9rem;
}
.asesor-btn:hover { filter: brightness(1.05); }
.asesor-btn:disabled { opacity: .6; cursor: default; }
.asesor-err { color: #dc2626; font-size: .78rem; min-height: 1em; }

/* gracias (fuera de línea) */
.asesor-gracias { padding: 26px 20px; text-align: center; color: #334155; font-size: .9rem; line-height: 1.5; }
.asesor-gracias a { color: #6C3AED; font-weight: 700; text-decoration: none; }
.asesor-check {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 14px; background: #dcfce7; color: #16a34a;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}

/* chat en vivo */
.asesor-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.asesor-row { display: flex; }
.asesor-row-out { justify-content: flex-end; }
.asesor-row-in { justify-content: flex-start; }
.asesor-bubble { max-width: 80%; padding: 9px 12px; border-radius: 14px; font-size: .87rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }
.asesor-row-in .asesor-bubble { background: #fff; color: #0f172a; border: 1px solid #e6e9ef; border-bottom-left-radius: 4px; }
.asesor-row-out .asesor-bubble { background: linear-gradient(135deg, #6C3AED 0%, #4C1D95 100%); color: #fff; border-bottom-right-radius: 4px; }
.asesor-send { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e6e9ef; background: #fff; }
.asesor-send input { flex: 1; border: 1px solid #d7dce5; border-radius: 20px; padding: 10px 14px; font-size: .88rem; outline: none; }
.asesor-send input:focus { border-color: #6C3AED; }
.asesor-send button { border: 0; width: 40px; height: 40px; border-radius: 50%; background: #6C3AED; color: #fff; cursor: pointer; flex: 0 0 40px; }
.asesor-send button:hover { background: #4C1D95; }

/* aviso proactivo: destello del panel cuando el asesor abre/escribe solo */
.asesor-panel.asesor-attn { animation: asesor-attn-pulse 0.7s ease-in-out 3; }
@keyframes asesor-attn-pulse {
  0%, 100% { box-shadow: 0 18px 50px rgba(15, 23, 42, .22); }
  50%      { box-shadow: 0 0 0 4px rgba(108, 58, 237, .55), 0 18px 50px rgba(108, 58, 237, .45); }
}
