/* ----------------------------------------------
   🎬 ANIMACIONES
-------------------------------------------------- */
@keyframes aparecerBoton {
    from { transform: scale(0.3); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

@keyframes abrirChat {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ----------------------------------------------
   🧱 CONTENEDOR DEL CHAT
-------------------------------------------------- */
#asistente-ia-chat {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 320px;
    height: 420px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
    font-family: Arial, sans-serif;
    transform-origin: bottom left;
    animation: abrirChat 0.4s ease forwards;
    opacity: 0;
}

/* ✅ Mostrar chat al activarlo vía JS */
#asistente-ia-chat.active {
    display: flex !important;
    opacity: 1;
}

/* ----------------------------------------------
   🧠 ENCABEZADO DEL CHAT
-------------------------------------------------- */
#asistente-ia-chat > div:first-child {
    background-color: #f0f0f0;
    padding: 10px;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

#asistente-ia-chat .assistant-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* ----------------------------------------------
   💬 ÁREA DE MENSAJES
-------------------------------------------------- */
#asistente-ia-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.4;
    scroll-behavior: smooth;
}

/* ----------------------------------------------
   🔡 CAMPO DE ENTRADA
-------------------------------------------------- */
#asistente-ia-chat input[type="text"] {
    width: 100%;
    border: 1px solid #ccc;
    padding: 8px;
    box-sizing: border-box;
    font-size: 14px;
}

/* ----------------------------------------------
   🎯 BOTÓN FLOTANTE
-------------------------------------------------- */
#asistente-ia-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    animation: aparecerBoton 0.5s ease-out;
}

#asistente-ia-toggle {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#asistente-ia-toggle:hover {
    background-color: #005a8c;
}


/* ----------------------------------------------
   📱 RESPONSIVE
-------------------------------------------------- */
@media screen and (max-width: 768px) {
    #asistente-ia-chat {
        width: 95vw;
        height: 90vh;
        left: 2.5vw;
        bottom: 100px;
        font-size: 15px;
    }

    #asistente-ia-messages {
        padding: 6px;
    }

    #asistente-ia-chat input[type="text"] {
        padding: 10px;
        font-size: 16px;
    }

    .message-text {
        max-width: 85%;
        font-size: 15px;
    }

    .btn-link {
        font-size: 14px;
        padding: 6px 8px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
    }
}


/* ----------------------------------------------
   💬 MENSAJES
-------------------------------------------------- */
.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    animation: fadeUp 0.3s ease-out;
    opacity: 1;
}

.message.user {
    flex-direction: row-reverse;
    text-align: right;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.message-text {
    background: #f1f1f1;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 75%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-text {
    background-color: #d1e7dd;
}

.message.assistant .message-text {
    background-color: #e0f3ff;
}

.message.system .message-text {
    background-color: #eee;
    font-style: italic;
    color: #666;
}

/* ----------------------------------------------
   🌐 LINKS E IMÁGENES
-------------------------------------------------- */
.message-text a {
    color: #0073aa;
    text-decoration: underline;
    word-break: break-word;
}

.message-text img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-text img:hover {
    transform: scale(1.03);
}

/* ----------------------------------------------
   🔘 BOTONES ENLACES PERSONALIZADOS (whatsapp, redes, etc)
-------------------------------------------------- */
.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #eee;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: #000;
    font-weight: bold;
    font-size: 13px;
    margin-top: 4px;
    margin-bottom: 4px;
    transition: background 0.2s ease;
}
.btn-link:hover {
    background-color: #ccc;
}

.btn-link.whatsapp    { background-color: #25D366; color: white; }
.btn-link.instagram   { background-color: #E1306C; color: white; }
.btn-link.facebook    { background-color: #3b5998; color: white; }
.btn-link.linkedin    { background-color: #0077b5; color: white; }
.btn-link.youtube     { background-color: #FF0000; color: white; }
.btn-link.tiktok      { background-color: #010101; color: white; }
.btn-link.drive       { background-color: #0F9D58; color: white; }
.btn-link.wetransfer  { background-color: #21B8E5; color: white; }
.btn-link.generic     { background-color: orange; color: white; }

.btn-link i {
    font-size: 16px;
}

.btn-link.other {
    background-color: orange;
    color: white;
}

/* ----------------------------------------------
   🔘 Estilos de Carga de imagenes
-------------------------------------------------- */

.chat-image-wrapper {
    margin-top: 10px;
    text-align: left;
}

.chat-image {
    max-width: 100%;
    border-radius: 8px;
    height: auto;
    display: block;
}
