/* AsesorChat.css — Estructura IDÉNTICA al chat de usuarios (#Chat/.cePanel)
   Clave: overlay con altura real (inset:0), card height:100%, body flex:1 overflow:auto */

.asesor-chat-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999;
  background: rgba(15, 23, 32, 0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 16px; box-sizing: border-box;
  /* Animación igual al carrito */
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform .5s cubic-bezier(.34,1.56,.64,1), opacity .35s ease;
  /* transform-origin se setea dinámicamente en JS */
}
.asesor-chat-overlay.abierto {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Botón flotante */
#asesor-chat-fab {
  position: fixed; right: 20px; top: 50%; z-index: 99900;
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: transparent; overflow: hidden;
  color: #fff; font-size: 24px; cursor: grab;
  box-shadow: 0 4px 20px rgba(43, 138, 99, 0.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .14s, box-shadow .14s;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#asesor-chat-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 28px rgba(43, 138, 99, 0.55); }
.asesor-fab-img { width: 42px; height: 42px; object-fit: contain; pointer-events: none; }
#asesor-chat-fab:active { cursor: grabbing; }

/* Card — Flex column. JS ajusta height al visualViewport en mobile.
   Desktop: max 420×600. Mobile: 100% (JS sobreescribe).
   La animación de escala la maneja el overlay (transform-origin dinámico). */
.asesor-chat-card {
  width: min(420px, 100%);
  height: min(600px, 100%);
  max-height: 100%;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

/* Header — sticky top, siempre visible */
.asesor-chat-header {
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: linear-gradient(135deg, #1a3a2a, #1b7a50);
  color: #fff;
}
.asesor-chat-header-left { display: flex; align-items: center; gap: 10px; }
.asesor-chat-avatar { width: 34px; height: 34px; object-fit: contain; background: transparent; border-radius: 50%; }
.asesor-chat-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.asesor-chat-subtitle { font-size: 12px; opacity: .75; margin-top: 2px; }
.asesor-chat-close {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.asesor-chat-close:hover { background: rgba(255,255,255,.28); }

/* Body — flex:1 para ocupar espacio sobrante, scroll interno */
.asesor-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 10px 8px;
  background: #f6f8fa;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

/* Welcome */
.asesor-chat-welcome { text-align: center; padding: 30px 16px; }
.asesor-chat-welcome-icon { margin-bottom: 12px; }
.asesor-chat-welcome-icon img { width: 72px; height: 72px; object-fit: contain; }
.asesor-chat-welcome-title { font-weight: 700; font-size: 16px; color: #0f2a3d; margin-bottom: 8px; }
.asesor-chat-welcome-text { font-size: 14px; color: #6a7681; line-height: 1.5; max-width: 300px; margin: 0 auto; }

/* Burbujas */
.asesor-chat-bubble {
  max-width: 94%; padding: 8px 12px; border-radius: 16px;
  font-size: 17px; font-weight: 500; line-height: 1.45; word-break: break-word;
  white-space: pre-wrap;
  animation: asesorBubble .14s ease;
}
@keyframes asesorBubble { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

.asesor-chat-bubble code {
  background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px;
  font-size: 15px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.asesor-chat-bubble strong { font-weight: 700; }

.asesor-chat-bubble--user {
  align-self: flex-end; background: linear-gradient(135deg, #2fa06f, #1b7a50);
  color: #fff; border-bottom-right-radius: 4px;
}
.asesor-chat-bubble--bot {
  align-self: flex-start; background: #fff; color: #1a2a3a;
  border: 1px solid #e2e6eb; border-bottom-left-radius: 4px;
}
.asesor-chat-bubble--bot-error {
  align-self: flex-start; background: #fff3f3; color: #c0392b;
  border: 1px solid #fdd; border-bottom-left-radius: 4px; font-size: 13px;
}

/* Typing dots */
.asesor-chat-typing { display: flex; gap: 4px; padding: 4px 0; }
.asesor-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #bcc4cd; animation: asesorDot .8s infinite ease-in-out;
}
.asesor-chat-typing span:nth-child(2) { animation-delay: .12s; }
.asesor-chat-typing span:nth-child(3) { animation-delay: .24s; }
@keyframes asesorDot { 0%, 40%, 100% { opacity: .3; transform: scale(.8) } 20% { opacity: 1; transform: scale(1.1) } }

/* Sugerencias — botones debajo de cada respuesta del bot */
.asesor-chat-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid #e8ecf0;
}
.asesor-chat-suggestion-btn {
  background: #f0f4f8; border: 1px solid #d7dce2; border-radius: 16px;
  padding: 6px 14px; font-size: 15px; color: #1a3a2a; cursor: pointer;
  font-family: inherit; line-height: 1.4; text-align: left;
  transition: background .12s, border-color .12s;
  max-width: 100%; word-break: break-word;
}
.asesor-chat-suggestion-btn:active,
.asesor-chat-suggestion-btn:hover {
  background: #dff0e5; border-color: #2b8a63;
}

/* Footer — sticky bottom, siempre sobre el teclado */
.asesor-chat-footer {
  flex-shrink: 0;
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #eef1f4; background: #fff;
}
.asesor-chat-input {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 14px; border: 1px solid #d7dbe0; border-radius: 22px;
  font-size: 16px; outline: none; transition: border .12s;
  font-family: inherit; line-height: 1.45; resize: none;
  max-height: 120px; overflow-y: hidden;
}
/* textarea hereda altura minima de 1 linea */
.asesor-chat-input { min-height: 42px; }
.asesor-chat-input:focus { border-color: #2b8a63; box-shadow: 0 0 0 2px rgba(43,138,99,.15); }
.asesor-chat-send {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, #2fa06f, #1b7a50);
  color: #fff; font-size: 16px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, filter .12s;
}
.asesor-chat-send:hover { filter: brightness(1.08); }
.asesor-chat-send:active { transform: scale(.93); }
.asesor-chat-send:disabled { filter: grayscale(.4) brightness(.9); cursor: default; }

/* Mobile — card 100% (JS ajusta al visualViewport en iOS) */
@media (max-width: 500px) {
  .asesor-chat-overlay { padding: 0; }
  .asesor-chat-overlay.abierto { align-items: stretch; justify-content: stretch; }
  .asesor-chat-card {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  #asesor-chat-fab { right: 16px; }
}

/* ── Menú contextual long-press en burbujas ───── */
.asesor-ctx-menu {
  position: fixed; z-index: 100001;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  min-width: 160px; overflow: hidden;
  animation: asesorCtxIn .12s ease;
}
@keyframes asesorCtxIn { from { opacity: 0; transform: scale(.92) } to { opacity: 1; transform: scale(1) } }
.asesor-ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px 16px; border: none;
  background: none; font-size: 15px; color: #1a2a3a;
  cursor: pointer; font-family: inherit;
  border-bottom: 1px solid #f0f0f0;
  transition: background .1s;
}
.asesor-ctx-item:last-child { border-bottom: none; }
.asesor-ctx-item:active { background: #f0f4f8; }
.asesor-ctx-icon { font-size: 18px; width: 24px; text-align: center; }

/* ── Panel reproductor de voz ─────────────────── */
.asesor-tts-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100002;
  background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.15);
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  animation: asesorTtsUp .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes asesorTtsUp { from { transform: translateY(100%) } to { transform: translateY(0) } }
.asesor-tts-panel.closing { animation: asesorTtsDown .2s ease forwards; }
@keyframes asesorTtsDown { to { transform: translateY(100%) } }

.asesor-tts-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.asesor-tts-title { font-weight: 700; font-size: 16px; color: #1a2a3a; }
.asesor-tts-close {
  background: #f0f4f8; border: none; width: 28px; height: 28px;
  border-radius: 50%; font-size: 14px; color: #6a7681; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.asesor-tts-controls {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.asesor-tts-btn {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: #1b7a50; color: #fff; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.asesor-tts-btn:active { transform: scale(.9); }
.asesor-tts-voice-wrap { flex: 1; }
.asesor-tts-voice-select {
  width: 100%; padding: 10px 12px; border: 1px solid #d7dbe0;
  border-radius: 8px; font-size: 14px; background: #fafbfc;
  font-family: inherit; color: #1a2a3a;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236a7681' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.asesor-tts-progress {
  height: 4px; background: #e8ecf0; border-radius: 2px;
  overflow: hidden;
}
.asesor-tts-progress-bar {
  height: 100%; background: #1b7a50; border-radius: 2px;
  width: 0%; transition: width .1s linear;
}
/* Tabs para voces sistema vs Google */
.asesor-tts-tab {
  flex: 1; padding: 8px 10px; border: 1px solid #d7dbe0;
  border-radius: 8px; background: #f0f4f8; font-size: 13px;
  font-weight: 600; color: #6a7681; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.asesor-tts-tab.active {
  background: #1b7a50; color: #fff; border-color: #1b7a50;
}
