/* BOTÓN */
#alexx-chat-toggle {
    position: fixed;
    bottom: 90px;
    right: 20px;
    left: auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    padding: 4px;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
    overflow: hidden;
    z-index: 2147483647;
}

#alexx-chat-toggle .alexx-toggle-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: #ffffff;

    border: 2px solid #1e88e5;
    box-sizing: border-box;

    display: block;
}

/* CONTENEDOR */
#alexx-chat-container {
    position: fixed;
    bottom: 160px;
    right: 20px;
    left: auto;
    width: 320px;
    height: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
    display: none;
    flex-direction: column;
    z-index: 2147483647;
}

#alexx-chat-container.open {
    display: flex;
}

/* HEADER */
#alexx-chat-header {
    background: #1e88e5;
    color: #fff;
    padding: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* MENSAJES */
#alexx-chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background: #fafafa;
}

/* INPUT */
#alexx-chat-input {
    display: flex;
    align-items: flex-end;   /* 👈 CLAVE para textarea */
    padding: 8px;
    border-top: 1px solid #ddd;
}

#alexx-user-message {
    flex: 1;
    padding: 8px 10px;
    resize: none;              /* evita que el usuario rompa el layout */
    overflow-y: auto;
    min-height: 38px;          /* altura inicial tipo input */
    max-height: 120px;         /* límite de crecimiento */
    line-height: 1.4;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
}

#alexx-send-message {
    margin-left: 6px;
    background: #1e88e5;
    color: #fff;
    border: none;
    padding: 8px 12px;
}

/* BURBUJAS */
.alexx-message {
    position: relative;
    max-width: 82%;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 14px;
    font-size: 13px;
}

.alexx-message-bot {
    background: #e3f2fd;
    color: #0d47a1; 
    margin-right: auto;
}

.alexx-message-bot::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 14px;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #e3f2fd;
}

.alexx-message-user {
    background: #1565c0;
    color: #fff;
    margin-left: auto;
    text-align: right;
}

.alexx-message-user::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 14px;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #1565c0;
}

/* FIX <p> IA */
.alexx-message p {
    margin: 0;
}
.alexx-message p + p {
    margin-top: 6px;
}

/* INDICADOR ESCRIBIENDO */
#alexx-typing-indicator {
    max-width: 60px;
    display: flex;
    justify-content: center;
}

.alexx-typing-dot {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.alexx-typing-dot:nth-child(2) { animation-delay: .2s; }
.alexx-typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typing {
    0% { opacity: .3 }
    50% { opacity: 1 }
    100% { opacity: .3 }
}

/* 🫧 Burbuja de icono de chat */
#alexx-burbuja {
  position: fixed;
  right: 20px;        /* alineado al inicio del botón */
  bottom: 170px;      /* suficiente aire vertical */
  max-width: 260px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
  padding: 14px 38px 14px 16px;
  z-index: 2147483646; /* justo debajo del botón */
  cursor: pointer;
}

.alexx-burbuja-avatar{
  position:absolute;
  left: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.alexx-burbuja-avatar-fallback{
  position:absolute;
  left: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#f2f2f2;
}

.alexx-burbuja-texto{
  font-size: 14px;
  line-height: 1.25;
  color: #222;
}

.alexx-burbuja-cerrar{
  position:absolute;
  right: 10px;
  top: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 28px;
  cursor:pointer;
  color:#666;
}

.alexx-typing {
  background: #e8f1ff;
  padding: 10px 14px;
  border-radius: 18px;
  width: fit-content;
  display: flex;
  gap: 4px;
}

.alexx-typing .dot {
  width: 6px;
  height: 6px;
  background: #3b82f6;
  border-radius: 50%;
  animation: alexx-bounce 1.4s infinite ease-in-out both;
}

.alexx-typing .dot:nth-child(1) { animation-delay: -0.32s; }
.alexx-typing .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes alexx-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.alexx-typing::before,
.alexx-typing::after {
  display: none !important;
}

#alexx-user-message::-webkit-scrollbar {
    width: 6px;
}
#alexx-user-message::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.25);
    border-radius: 3px;
}

/* 📱 Ajustes móvil */
@media (max-width: 480px) {

  #alexx-chat-container {
    width: calc(100% - 20px);
    right: 10px;
    bottom: 90px;
    height: 70vh;
  }

  #alexx-chat-input {
    padding: 6px;
  }

  #alexx-user-message {
    font-size: 16px;   /* evita zoom automático en iOS */
    max-height: 100px;
  }

  #alexx-send-message {
    padding: 8px 10px;
    font-size: 14px;
  }
}
