:root {
    --primary: #ff6b81;
    --secondary: #a29bfe;
    --gradient: linear-gradient(135deg, #ff6b81 0%, #a29bfe 100%);
    --bot-bg: #f0f3ff;
    --user-bg: #e8f7ff;
}

/* Botón flotante */
.chatbot-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gradient);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 107, 129, 0.4);
    z-index: 9999; /* Muy alto para estar encima de todo */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    font-size: 1.5rem;
}

.chatbot-btn:hover {
    transform: scale(1.1) rotate(-10deg);
    box-shadow: 0 8px 25px rgba(255, 107, 129, 0.6);
}

.chatbot-btn.notification-active {
    background: #ff9f43; /* Naranja de alerta */
    animation: pulse-notification 2s infinite;
}

@keyframes pulse-notification {
    0% { box-shadow: 0 0 0 0 rgba(255, 159, 67, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 159, 67, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 159, 67, 0); }
}

/* Contenedor principal */
.chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: #ffffff; /* Asegurar fondo blanco sólido */
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    display: none; /* Oculto por defecto */
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid #e0e0e0; /* Borde sutil para definición */
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.chatbot-header {
    background: var(--gradient);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chatbot-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-family: 'Poppins', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Área de mensajes */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    animation: fadeIn 0.3s ease;
    max-width: 85%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.bot .message-content {
    background: var(--bot-bg);
    color: #2d3436;
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.2);
}

.message-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
    padding: 0 5px;
}

.message.user .message-time {
    text-align: right;
}

/* Opciones rápidas */
.quick-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.quick-option {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px 15px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
    font-family: 'Poppins', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-option:hover {
    background: var(--bot-bg);
    border-color: var(--secondary);
    color: var(--primary);
    transform: translateX(5px);
}

/* Input area */
.chat-input-container {
    padding: 15px;
    border-top: 1px solid #eee;
    background: #ffffff;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #f8f9fa;
    padding: 5px 5px 5px 15px;
    border-radius: 30px;
    border: 1px solid #eee;
    transition: border-color 0.3s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.1);
}

#chatInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    outline: none;
}

.send-btn {
    background: var(--gradient);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.1);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bot-bg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 15px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-container {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        height: 70vh;
        bottom: 90px;
    }
}

/* --- CARRUSEL DE PRODUCTOS EN CHAT --- */
.chat-product-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    margin-top: 5px;
    margin-bottom: 15px;
    scrollbar-width: none; /* Firefox */
}

.chat-product-carousel::-webkit-scrollbar {
    display: none; /* Chrome */
}

.chat-product-card {
    min-width: 130px;
    max-width: 130px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid #eee;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.chat-product-card:hover {
    transform: translateY(-3px);
}

.chat-product-img {
    width: 100%;
    height: 90px;
    object-fit: cover;
}

.chat-product-info {
    padding: 8px;
    text-align: center;
}

.chat-product-title {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dark);
}

.chat-product-price {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
}

.chat-product-btn {
    display: block;
    width: 100%;
    background: var(--bot-bg);
    color: var(--primary);
    border: none;
    padding: 4px;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}

.chat-product-btn:hover {
    background: var(--secondary);
    color: white;
}