Thailand and Cambodia have agreed an "immediate and unconditional" ceasefire after deadly border clashes.