/* ============================================= */
/* ===== ESTILOS PARA EL CHATBOT FLOTANTE ====== */
/* ============================================= */

/* --- Contenedor Principal del Chat (Inicialmente Oculto) --- */
.chat-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 350px;
    max-width: 90vw;
    height: 500px;
    max-height: 70vh;
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    /* Lógica de visibilidad para el efecto pop-up */
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    z-index: 1000;
}

/* --- Estado Visible --- */
/* Esta es la regla clave que hace que el pop-up aparezca */
.chat-container.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

/* --- Botón para Abrir/Cerrar el Chat --- */
.chatbot-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1001;
    transition: transform 0.2s ease;
}

.chatbot-btn:hover {
    transform: scale(1.1);
}

/* --- Encabezado del Chat --- */
.chat-header {
    background-color: #007bff;
    color: white;
    padding: 15px;
    font-weight: bold;
    text-align: center;
    border-radius: 15px 15px 0 0;
}

/* --- Área de Mensajes --- */
.chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Estilo general para cada burbuja de mensaje --- */
.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* --- Mensajes del Usuario (derecha) --- */
.user-message {
    align-self: flex-end;
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

/* --- Mensajes del Bot (izquierda) --- */
.bot-message {
    align-self: flex-start;
    background-color: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* --- Indicador de "Escribiendo..." --- */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Área de Entrada de Texto --- */
.chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
}

#user-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
}

#send-button {
    background-color: #007bff;
    border: none;
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- Botones de Sugerencia (Respuestas Rápidas) --- */
.quick-replies-permanent {
    padding: 5px 10px 10px 10px;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-reply-btn {
    background-color: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.2s;
}

.quick-reply-btn:hover {
    background-color: #e0e0e0;
}

/* --- Tarjetas de Productos Recomendados --- */
.products-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-self: stretch;
}

a.product-card-link {
    text-decoration: none;
    color: inherit;
}

.product-card {
    display: flex;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    background-color: #f9f9f9;
    transition: box-shadow 0.2s;
}

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.product-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.product-card .product-info {
    padding: 8px 12px;
}

.product-card .product-name {
    font-weight: bold;
    font-size: 0.9em;
    margin: 0 0 4px 0;
}

.product-card .product-price {
    font-size: 0.85em;
    color: #555;
    margin: 0;
}

/* --- Diseño Responsivo para Móviles --- */
@media (max-width: 480px) {
    .chat-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }

    .chatbot-btn {
        bottom: 15px;
        right: 15px;
    }
}