/* Chat de compras con IA -- estilo WhatsApp (mismo look que tienda-demo.kexe.mx / Tienda Ya).
   El boton flotante que lo abre es el mismo de WhatsApp de siempre (ver app.blade.php); este
   archivo es solo el panel del chat una vez abierto.
   Mobile: usa --vvh/--vvt (visualViewport, puestos por chat-ia.js) en vez de 100vh/vh -- ver
   .claude/skills/chatbot-tienda, "el teclado se valida en telefono real". */

:root {
    --wa-header: #075E54;
    --wa-green: #25D366;
    --wa-bg: #ECE5DD;
}

.chat-ia-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
    z-index: 16000161;
}

.chat-ia-panel {
    position: fixed;
    right: 20px; bottom: 96px;
    width: 370px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 140px);
    background: var(--wa-bg); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    display: flex; flex-direction: column; overflow: hidden;
    z-index: 16000162;
}

.chat-ia-header {
    background: var(--wa-header); color: #fff;
    padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex: none;
}
.chat-ia-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .15);
    display: flex; align-items: center; justify-content: center; flex: none; overflow: hidden; font-size: 17px;
}
.chat-ia-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-ia-header-info { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; flex: 1; }
.chat-ia-header-info strong { font-size: 15px; }
.chat-ia-header-info span { font-size: 12px; opacity: .85; }
.chat-ia-cerrar { background: transparent; border: 0; color: #fff; font-size: 16px; padding: 6px; cursor: pointer; flex: none; }

.chat-ia-cuerpo {
    flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}

.chat-ia-msg { max-width: 85%; padding: 9px 12px; border-radius: 8px; font-size: 14px; line-height: 1.45; word-break: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.chat-ia-msg a { color: #1565c0; text-decoration: underline; }
.chat-ia-linea { margin-bottom: 6px; }
.chat-ia-linea:last-child { margin-bottom: 0; }
.chat-ia-msg.asistente { align-self: flex-start; background: #fff; color: #111b21; border-top-left-radius: 2px; }
.chat-ia-msg.cliente { align-self: flex-end; background: #DCF8C6; color: #111b21; border-top-right-radius: 2px; box-shadow: none; }
.chat-ia-msg.cliente.pendiente { opacity: .55; }
.chat-ia-msg.cliente.fallido { background: #f8d7da; }
.chat-ia-msg.cargando { align-self: flex-start; display: flex; gap: 4px; padding: 11px 14px; background: #fff; }
.chat-ia-msg.cargando span { width: 6px; height: 6px; border-radius: 50%; background: #9aa3b2; animation: chat-ia-bounce 1.2s infinite; }
.chat-ia-msg.cargando span:nth-child(2) { animation-delay: .15s; }
.chat-ia-msg.cargando span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-ia-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

.chat-ia-reintentar { align-self: flex-end; background: transparent; border: 1px solid #b91c1c; color: #b91c1c; font-size: 12px; border-radius: 10px; padding: 4px 10px; cursor: pointer; }

.chat-ia-botones { display: flex; flex-direction: column; gap: 1px; align-self: flex-start; max-width: 85%; width: 100%; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.chat-ia-boton {
    background: #fff; border: 0; color: var(--wa-header); font-size: 14px; font-weight: 600;
    padding: 11px 14px; cursor: pointer; text-align: center; text-decoration: none;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.chat-ia-boton i { font-size: 13px; }
.chat-ia-boton:hover { background: #f5f5f5; }

.chat-ia-aviso { align-self: center; background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; font-size: 12.5px; border-radius: 10px; padding: 8px 10px; text-align: center; }
.chat-ia-aviso button { margin: 4px 4px 0; background: transparent; border: 1px solid #664d03; color: #664d03; border-radius: 8px; padding: 3px 8px; font-size: 12px; cursor: pointer; }

.chat-ia-form { display: flex; gap: 8px; padding: 10px; flex: none; background: #f0f0f0; }
.chat-ia-form input { flex: 1; border: 1px solid #d1d5db; border-radius: 20px; padding: 9px 14px; font-size: 14px; min-width: 0; background: #fff; }
.chat-ia-form input:focus { outline: none; border-color: var(--wa-green); }
.chat-ia-form button { background: var(--wa-green); color: #fff; border: 0; width: 38px; height: 38px; border-radius: 50%; flex: none; cursor: pointer; }

@media (max-width: 600px) {
    .chat-ia-panel {
        right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%;
        top: var(--vvt, 0px); height: var(--vvh, 100%); max-height: none; border-radius: 0;
    }
}
