/* ============================================================
   ISA WIDGET — JDSERVICES Virtual Assistant
   Versión: v078 | www.jds.com.co
   ============================================================ */

/* --- Variables de marca JDS --- */
:root {
  --isa-purple:       #5B2C8D;
  --isa-purple-dark:  #3D1A6E;
  --isa-purple-light: #7B3FBD;
  --isa-green-wa:     #25D366;
  --isa-green-wa-dk:  #1BA851;
  --isa-white:        #FFFFFF;
  --isa-bg:           #F5F4FA;
  --isa-bubble-user:  #EDE8F7;
  --isa-text:         #1A1A2E;
  --isa-text-light:   #6B6B8A;
  --isa-shadow:       0 8px 32px rgba(91,44,141,0.28);
  --isa-radius:       18px;
  --isa-z:            99999;
}

/* ============================================================
   BOTÓN FLOTANTE
   ============================================================ */
#isa-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--isa-purple-light), var(--isa-purple-dark));
  box-shadow: var(--isa-shadow), 0 0 0 0 rgba(91,44,141,0.5);
  cursor: pointer;
  z-index: var(--isa-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s ease;
  animation: isa-pulse 3.5s infinite;
  border: none;
  padding: 0;
}

#isa-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 40px rgba(91,44,141,0.4), 0 0 0 6px rgba(91,44,141,0.12);
  animation: none;
}

#isa-btn.isa-open {
  animation: none;
  transform: scale(0.9) rotate(10deg);
}

#isa-btn img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

/* Notificación badge */
#isa-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  background: #E74C3C;
  border-radius: 50%;
  border: 2.5px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}

#isa-badge.visible {
  opacity: 1;
  transform: scale(1);
}

@keyframes isa-pulse {
  0%   { box-shadow: var(--isa-shadow), 0 0 0 0 rgba(91,44,141,0.5); }
  50%  { box-shadow: var(--isa-shadow), 0 0 0 12px rgba(91,44,141,0); }
  100% { box-shadow: var(--isa-shadow), 0 0 0 0 rgba(91,44,141,0); }
}

/* ============================================================
   PANEL DEL CHAT
   ============================================================ */
#isa-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 360px;
  height: 520px;
  background: var(--isa-white);
  border-radius: var(--isa-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 20px rgba(91,44,141,0.15);
  z-index: var(--isa-z);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  transform-origin: bottom right;
  animation: isa-slide-in 0.35s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes isa-slide-in {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ============================================================
   HEADER
   ============================================================ */
#isa-header {
  background: linear-gradient(135deg, var(--isa-purple-light) 0%, var(--isa-purple-dark) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

#isa-header::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(to bottom, rgba(91,44,141,0.08), transparent);
}

#isa-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
  background: var(--isa-purple-dark);
}

#isa-header-info {
  flex: 1;
  min-width: 0;
}

#isa-header-info strong {
  display: block;
  color: white;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

#isa-header-info span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  margin-top: 2px;
}

#isa-header-info span::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ADE80;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px #4ADE80;
  animation: isa-blink 2s infinite;
}

@keyframes isa-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#isa-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

#isa-close-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* ============================================================
   ÁREA DE MENSAJES
   ============================================================ */
#isa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--isa-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#isa-messages::-webkit-scrollbar { width: 4px; }
#isa-messages::-webkit-scrollbar-track { background: transparent; }
#isa-messages::-webkit-scrollbar-thumb { background: rgba(91,44,141,0.2); border-radius: 4px; }

/* Mensaje individual */
.isa-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: isa-msg-in 0.28s ease forwards;
}

@keyframes isa-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.isa-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--isa-purple-dark);
}

.isa-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--isa-text);
  word-break: break-word;
}

/* Burbuja asistente */
.isa-msg-assistant .isa-bubble {
  background: white;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Burbuja usuario */
.isa-msg-user {
  flex-direction: row-reverse;
}

.isa-msg-user .isa-bubble {
  background: var(--isa-bubble-user);
  color: var(--isa-purple-dark);
  border-radius: 16px 4px 16px 16px;
  font-weight: 500;
}

/* Typing indicator */
.isa-typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  align-items: center;
}

.isa-typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--isa-purple-light);
  border-radius: 50%;
  opacity: 0.4;
  animation: isa-dot 1.4s infinite;
}

.isa-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.isa-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes isa-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* Fecha / separador -->
.isa-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--isa-text-light);
  margin: 4px 0;
}

/* ============================================================
   BARRA WHATSAPP
   ============================================================ */
#isa-wa-bar {
  background: linear-gradient(135deg, #25D366, #1BA851);
  flex-shrink: 0;
}

#isa-wa-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: opacity 0.2s;
}

#isa-wa-bar a:hover {
  opacity: 0.9;
}

#isa-wa-bar a svg {
  width: 18px;
  height: 18px;
  fill: white;
  flex-shrink: 0;
}

/* ============================================================
   ÁREA DE ENTRADA
   ============================================================ */
#isa-input-area {
  padding: 10px 12px;
  background: white;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(91,44,141,0.08);
  flex-shrink: 0;
}

#isa-input {
  flex: 1;
  border: 1.5px solid rgba(91,44,141,0.15);
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--isa-text);
  background: var(--isa-bg);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

#isa-input:focus {
  border-color: var(--isa-purple-light);
  background: white;
}

#isa-input::placeholder {
  color: var(--isa-text-light);
}

#isa-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--isa-purple-light), var(--isa-purple-dark));
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(91,44,141,0.35);
}

#isa-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 16px rgba(91,44,141,0.45);
}

#isa-send-btn:active {
  transform: scale(0.95);
}

#isa-send-btn svg {
  width: 18px;
  height: 18px;
  fill: white;
  margin-left: 2px;
}

/* ============================================================
   RESPONSIVE — MÓVIL
   ============================================================ */
@media (max-width: 480px) {
  #isa-panel {
    width: calc(100vw - 20px);
    height: calc(100vh - 110px);
    bottom: 88px;
    right: 10px;
    left: 10px;
    border-radius: 16px;
  }

  #isa-btn {
    bottom: 16px;
    right: 16px;
  }
}
