/* Botón flotante del chatbot */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.chatbot-toggle-icon {
    width: 32px;
    height: 32px;
    color: white;
}

/* Contenedor principal del chatbot */
#chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.chatbot-hidden {
    transform: translateY(100%) scale(0.8);
    opacity: 0;
    pointer-events: none;
}

/* Header del chatbot */
#chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.chatbot-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-ai-icon {
    width: 24px;
    height: 24px;
    color: white;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

#chatbot-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Área de mensajes */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e8ed;
    border-bottom-left-radius: 5px;
}

/* Contenedor de input */
#chatbot-input-container {
    padding: 12px;
    background: white;
    border-top: 1px solid #e1e8ed;
    display: flex;
    gap: 8px;
    align-items: center;
}

#chatbot-language {
    padding: 8px 6px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 12px;
    background: white;
    min-width: 110px;
    max-width: 110px;
    cursor: pointer;
    flex-shrink: 0;
}

#chatbot-language:focus {
    outline: none;
    border-color: #667eea;
}

#chatbot-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 22px;
    outline: none;
    font-size: 13px;
    min-width: 0;
}

#chatbot-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

#chatbot-send {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 22px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 85px;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    max-width: 80px;
}

.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: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsivo */
@media (max-width: 768px) {
    #chatbot-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        right: 20px;
        bottom: 90px;
        max-width: 400px;
    }
    
    #chatbot-toggle {
        bottom: 20px;
        right: 20px;
    }
    
    #chatbot-language {
        min-width: 95px;
        max-width: 95px;
        font-size: 11px;
        padding: 8px 4px;
    }
    
    #chatbot-input {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    #chatbot-send {
        min-width: 75px;
        padding: 8px 16px;
        font-size: 12px;
    }
    
    #chatbot-input-container {
        padding: 10px;
        gap: 6px;
    }
}

/* Scrollbar personalizada */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animación suave para el ícono del chatbot */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
    }
    100% {
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

#chatbot-toggle {
    animation: pulse 2s infinite;
}

#chatbot-toggle:hover {
    animation: none;
}